blob: 6e24d90967d0d613f75af488d7cbcc47f818720c [file] [log] [blame]
<?xml version="1.0"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!--
- Example binding to bind the "form2" form to the bean "Form2Bean"
-
- The id attributes on the elements in this file map to widgets in the
- form definition. The path attributes are JXPath expressions addressing
- properties of the bean.
-
- It would be an interesting exercise to generate this file from
- javadoc-tags in the bean using an xdoclet-like approach.
-->
<fb:context xmlns:fb="http://apache.org/cocoon/forms/1.0#binding" path="/" >
<!-- The email value will not be saved because of the @direction="load" -->
<fb:value id="email" path="email" direction="load"/>
<fb:value id="ipaddress" path="ipAddress"/>
<fb:value id="birthday" path="birthday"/>
<fb:value id="number" path="aNumber"/>
<fb:value id="choose" path="choose"/>
<fb:value id="sex" path="sex"/>
<!--<fb:value id="enable" path="enable" direction="load"/>-->
<fb:javascript id="enable" path="enable" direction="save">
<!--<fb:load-form>
widget.setValue(java.lang.Boolean.FALSE);
</fb:load-form>-->
<fb:save-form>
jxpathPointer.setValue(java.lang.Boolean.TRUE);
</fb:save-form>
</fb:javascript>
<!--
- An aggregatefield is a special kind of widget that lets
- the user edit the value of multiple widgets through one text box,
- or single widgets through multiple boxes. (see also samples in
- ../aggregate directory). In this case it is used to map the different
- parts of a phone number to different bean properties.
-->
<fb:aggregate id="phone" path="." >
<fb:value id="number" path="phoneNumber"/>
<fb:value id="zone" path="phoneZone"/>
<fb:value id="cntr" path="phoneCountry"/>
</fb:aggregate>
<fb:multi-value id="drinks" parent-path="." row-path="drinks" direction="both"/>
<!--
- 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="."
row-path="contacts">
<fb:identity>
<!-- compare to xml-binding: the convertor is not needed here -->
<fb:value id="id" path="id"/>
</fb:identity>
<fb:on-bind>
<!-- executed on updates AND right after the insert -->
<fb:value id="firstname" path="firstName"/>
<fb:value id="middleInitial" path="middleInitial"/>
<fb:value id="lastname" path="lastName"/>
<fb:value id="phone" path="phone"/>
<fb:value id="email" path="email"/>
<fb:value id="preferred" path="preferred"/>
</fb:on-bind>
<fb:on-delete-row>
<fb:delete-node/>
</fb:on-delete-row>
<fb:on-insert-row>
<fb:insert-bean classname="org.apache.cocoon.forms.samples.Contact"
addmethod="addContact"/>
</fb:on-insert-row>
</fb:repeater>
</fb:context>