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