blob: 345dc0476d1a65e3e4d3622bd103f0434388694e [file] [log] [blame]
<fb:context
xmlns:fb="http://apache.org/cocoon/forms/1.0#binding"
xmlns:fd="http://apache.org/cocoon/forms/1.0#definition"
path="/data/wrapper/context" >
<fb:context path="info">
<!-- the email value will not be saved because of the @direction="load" -->
<fb:value id="email" path="email" direction="load"/>
<!-- jxpath binds to nodes as well as to attributes -->
<fb:value id="number" path="number/@value">
<!-- for non-string datatypes, a convertor must be specified. These are
the same convertors as can be used in form definitions, but require an
extra datatype attribute. Here we use the default convertor for longs. -->
<fd:convertor datatype="integer"/>
</fb:value>
<fb:value id="choose" path="choose/@value">
<fd:convertor datatype="boolean"/>
</fb:value>
<!-- one entry field in the client maps through aggregate fields -->
<fb:aggregate id="phone" path="phone" >
<!-- to multiple fields in the XML file -->
<fb:value id="number" path="number" />
<fb:value id="zone" path="zone" />
<fb:value id="cntr" path="@cntr" />
</fb:aggregate>
</fb:context>
<fb:value id="ipaddress" path="ipaddress">
<fb:on-update>
<!-- if the value has changed, the attribute will be set -->
<fb:set-attribute name="changed" value="true"/>
</fb:on-update>
</fb:value>
<fb:value id="birthday" path="birthday">
<fd:convertor datatype="date" type="formatting">
<fd:patterns>
<fd:pattern>yyyy-MM-dd</fd:pattern>
</fd:patterns>
</fd:convertor>
</fb:value>
<fb:multi-value id="drinks" parent-path="drinks" row-path="drink"/>
<!--
- Repeater requires unique identification mechanism of the row-nodes.
- (it is of course possible to implement other binding strategies)
-
- Important NOTE: When adding rows, the row-path is used inside
- jxpath-createPath context, as a consequence it cannot have dependent
- children or predicates.
-->
<fb:repeater id="contacts"
parent-path="contacts"
row-path="contact">
<fb:identity>
<fb:value id="id" path="@id">
<!-- optional convertor to use for mapping the unique id -->
<fd:convertor datatype="long" />
</fb:value>
</fb:identity>
<fb:on-bind>
<!-- executed on updates AND right after the insert -->
<fb:value id="firstname" path="firstname" />
<fb:value id="lastname" path="lastname" />
<fb:value id="phone" path="phone/@nr" />
<fb:value id="email" path="email" />
</fb:on-bind>
<fb:on-delete-row>
<!-- chose on of these to test -->
<!--
<fb:set-attribute name="row-state" value="deleted" />
-->
<fb:delete-node />
</fb:on-delete-row>
<fb:on-insert-row>
<!-- The insert-node element contains a piece of template XML to be
inserted for new rows. Alternatively, you could also add a "src"
attribute on the insert-node element pointing to an external source
to retrieve the template from. -->
<fb:insert-node>
<!-- template inserted by the binding for new rows (mapping new nodes) -->
<contact id="" row-state="new">
<firstname/><lastname/><phone nr=""/><email/>
</contact>
</fb:insert-node>
</fb:on-insert-row>
</fb:repeater>
</fb:context>