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-binding.xml < prev    next >
Encoding:
Extensible Markup Language  |  2004-07-12  |  3.0 KB  |  82 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. <!-- Example binding to bind the "form2" form to the bean "Form2Bean" -->
  18.  
  19. <!-- The id attributes on the elements in this file map to widgets in the
  20.      form definition. The path attributes are JXPath expressions addressing
  21.      properties of the bean. -->
  22.  
  23. <!-- It would be an interesting exercise to generate this file from
  24.      javadoc-tags in the bean using an xdoclet-like approach. -->
  25.  
  26. <fb:context xmlns:fb="http://apache.org/cocoon/forms/1.0#binding" path="/" >
  27.  
  28.   <!-- the email value will not be saved because of the @direction="load" -->
  29.   <fb:value id="email" path="email" direction="load"/>
  30.   <fb:value id="ipaddress" path="ipAddress"/>
  31.   <fb:value id="birthday" path="birthday"/>
  32.   <fb:value id="number" path="aNumber"/>
  33.   <fb:value id="choose" path="choose"/>
  34.   <fb:value id="sex" path="sex"/>
  35.  
  36.   <!-- An aggregatefield is a special kind of widget that lets
  37.   the user edit the value of multiple widgets through one text box
  38.   (see also the form definition for how this works). In this case
  39.   it is used to map the different parts of a phone number to different
  40.   bean properties. -->
  41.   <fb:aggregate id="phone" path="." >
  42.     <fb:value id="number" path="phoneNumber"/>
  43.     <fb:value id="zone"   path="phoneZone"/>
  44.     <fb:value id="cntr"   path="phoneCountry"/>
  45.   </fb:aggregate>
  46.  
  47.   <fb:multi-value id="drinks" parent-path="." row-path="drinks" direction="load"/>
  48.  
  49.   <!-- repeater requires unique identification mechanism of the row-nodes -->
  50.   <!-- (it is of course possible to implement other binding strategies) -->
  51.   <fb:repeater id="contacts"
  52.     parent-path="."
  53.     row-path="contacts"
  54.     unique-row-id="id"
  55.     unique-path="@id">
  56.  
  57.     <!-- compare to xml-binding: the convertor is not needed here -->
  58.  
  59.     <!-- important note: the row-path is used inside jxpath-createPath context,
  60.     as a consequence it cannot have dependent children or predicates -->
  61.  
  62.     <fb:on-bind>
  63.       <!-- executed on updates AND right after the insert -->
  64.       <fb:value id="firstname" path="firstName"/>
  65.       <fb:value id="lastname" path="lastName"/>
  66.       <fb:value id="phone" path="phone"/>
  67.       <fb:value id="email" path="email"/>
  68.     </fb:on-bind>
  69.  
  70.     <fb:on-delete-row>
  71.       <fb:delete-node/>
  72.     </fb:on-delete-row>
  73.  
  74.     <fb:on-insert-row>
  75.       <fb:insert-bean
  76.         classname="org.apache.cocoon.forms.samples.Contact"
  77.         addmethod="addContact"/>
  78.     </fb:on-insert-row>
  79.   </fb:repeater>
  80.  
  81. </fb:context>
  82.