home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 December / PCpro_2004_12.ISO / files / webserver / xampp / xampp-cocoon-addon-1.4.9-installer.exe / form2_bind_xml.xml < prev    next >
Encoding:
Extensible Markup Language  |  2004-07-12  |  4.1 KB  |  122 lines

  1. <?xml version="1.0"?>
  2. <!--
  3.   Copyright 1999-2004 The Apache Software Foundation
  4.  
  5.   Licensed under the Apache License, Version 2.0 (the "License");
  6.   you may not use this file except in compliance with the License.
  7.   You may obtain a copy of the License at
  8.  
  9.       http://www.apache.org/licenses/LICENSE-2.0
  10.  
  11.   Unless required by applicable law or agreed to in writing, software
  12.   distributed under the License is distributed on an "AS IS" BASIS,
  13.   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14.   See the License for the specific language governing permissions and
  15.   limitations under the License.
  16. -->
  17.  
  18. <!--
  19.   - Binding template between
  20.   -   * form_data file (backend)
  21.   -   * and form_model file
  22.   -->
  23. <fb:context 
  24.             xmlns:fb="http://apache.org/cocoon/forms/1.0#binding" 
  25.             xmlns:fd="http://apache.org/cocoon/forms/1.0#definition" 
  26.             path="/data/wrapper/context" >
  27.  
  28.   <fb:context path="info">
  29.     <!-- the email value will not be saved because of the @direction="load" -->
  30.     <fb:value id="email"   path="email"   direction="load"/>
  31.  
  32.     <!-- jxpath binds to nodes as well as to attributes -->
  33.     <fb:value id="number" path="number/@value">
  34.       <!-- for non-string datatypes, a convertor must be specified. These are
  35.       the same convertors as can be used in form definitions, but require an
  36.       extra datatype attribute. Here we use the default convertor for longs. -->
  37.       <fd:convertor datatype="integer"/>
  38.     </fb:value>
  39.  
  40.     <fb:value id="choose" path="choose/@value">
  41.       <fd:convertor datatype="boolean"/>
  42.     </fb:value>
  43.  
  44.     <!-- one entry field in the client maps through aggregate fields -->
  45.     <fb:aggregate id="phone" path="phone" >
  46.       <!-- to multiple fields in the XML file -->
  47.       <fb:value id="number" path="number" />
  48.       <fb:value id="zone"   path="zone"   />
  49.       <fb:value id="cntr"   path="@cntr"  />
  50.     </fb:aggregate>
  51.     
  52.   </fb:context>
  53.   
  54.   
  55.   <fb:value id="ipaddress" path="ipaddress">
  56.     <fb:on-update>
  57.       <!-- if the value has changed, the attribute will be set -->
  58.       <fb:set-attribute name="changed" value="true"/>
  59.     </fb:on-update>
  60.   </fb:value>
  61.  
  62.   <fb:value id="birthday" path="birthday">
  63.     <fd:convertor datatype="date" type="formatting">
  64.       <fd:patterns>
  65.         <fd:pattern>yyyy-MM-dd</fd:pattern>
  66.       </fd:patterns>
  67.     </fd:convertor>
  68.   </fb:value>
  69.  
  70.   <fb:multi-value id="drinks" parent-path="drinks" row-path="drink"/>
  71.  
  72.   <!--
  73.     - Repeater requires unique identification mechanism of the row-nodes.
  74.     - (it is of course possible to implement other binding strategies)
  75.     -
  76.     - Important NOTE: When adding rows, the row-path is used inside
  77.     - jxpath-createPath context, as a consequence it cannot have dependent
  78.     - children or predicates.
  79.     -->
  80.   <fb:repeater id="contacts"
  81.                parent-path="contacts"
  82.                row-path="contact">
  83.  
  84.     <fb:identity>
  85.       <fb:value id="id" path="@id">
  86.         <!-- optional convertor to use for mapping the unique id -->
  87.         <fd:convertor datatype="long" />
  88.       </fb:value>
  89.     </fb:identity>
  90.  
  91.     <fb:on-bind>
  92.         <!-- executed on updates AND right after the insert -->
  93.       <fb:value id="firstname" path="firstname" />
  94.       <fb:value id="lastname"  path="lastname"  />
  95.       <fb:value id="phone"     path="phone/@nr" />
  96.       <fb:value id="email"     path="email"     />
  97.     </fb:on-bind>
  98.  
  99.     <fb:on-delete-row>
  100.         <!-- chose on of these to test -->
  101.         <!--
  102.       <fb:set-attribute name="row-state" value="deleted" />
  103.       -->
  104.       <fb:delete-node />
  105.     </fb:on-delete-row>
  106.  
  107.     <fb:on-insert-row>
  108.       <!-- The insert-node element contains a piece of template XML to be
  109.       inserted for new rows. Alternatively, you could also add a "src"
  110.       attribute on the insert-node element pointing to an external source
  111.       to retrieve the template from. -->
  112.       <fb:insert-node>
  113.         <!-- template inserted by the binding for new rows (mapping new nodes) -->
  114.         <contact id="" row-state="new">
  115.           <firstname/><lastname/><phone nr=""/><email/>
  116.         </contact>              
  117.       </fb:insert-node>
  118.     </fb:on-insert-row>
  119.   </fb:repeater>
  120.  
  121. </fb:context>
  122.