blob: 5a83a71c91926c3c25ce8ae6a89e46a55699ece6 [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.
-->
<wb:context
xmlns:wb="http://apache.org/cocoon/woody/binding/1.0"
xmlns:wd="http://apache.org/cocoon/woody/definition/1.0"
path="/" >
<!--
| This file shows the different possibilities for (single) Value Binding
| of the Binding Framework in Cocoon Forms (aka Woody).
-->
<!--
| SECTION 1. Default simple value-binding
-->
<wb:value id="simple"
path="simple" />
<!--
| SECTION 2. Playing around with @direction
-->
<!-- Binding only during load() -->
<wb:value id="readonly"
path="readOnly" direction="load"/>
<!-- Binding only during save() -->
<wb:value id="writeonly"
path="writeOnly" direction="save"/>
<!-- Binding working to different targets for
load() and save() -->
<wb:value id="diff"
path="diffIn" direction="load"/>
<wb:value id="diff"
path="diffOut" direction="save"/>
<!--
| SECTION 3. Using the 'on-update'
-->
<!-- Binding executing additional action on save()
if the value changed -->
<wb:value id="onupdate"
path="onUpdate" >
<wb:on-update>
<wb:javascript id="onupdate" path="..">
<wb:load-form />
<wb:save-form>
var countPointer = jxpathContext.getPointer('updateCount');
var count = parseInt(countPointer.getValue()) + 1;
countPointer.setValue(count);
</wb:save-form>
</wb:javascript>
</wb:on-update>
</wb:value>
<!--
| SECTION 4. Matching value types and data-conversion
-->
<!-- Boolean Binding just works -->
<wb:value id="bool"
path="bool">
<wd:convertor datatype="boolean" />
</wb:value>
<!-- Converting data-types to/from String values -->
<wb:value id="date"
path="date" >
<wd:convertor datatype="date" >
<wd:patterns>
<wd:pattern>yyyyMMdd</wd:pattern>
</wd:patterns>
</wd:convertor>
</wb:value>
</wb:context>