You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by br...@apache.org on 2003/07/24 14:42:20 UTC
cvs commit: cocoon-2.1/src/blocks/woody/samples/forms form2_bind_bean.xml form2_bind_xml.xml form2_data.xml form2_jx.xml form2_model.xml form2_template.xsp
bruno 2003/07/24 05:42:20
Modified: src/blocks/woody/samples/forms form2_bind_bean.xml
form2_bind_xml.xml form2_data.xml form2_jx.xml
form2_model.xml form2_template.xsp
Log:
Extended example with a Date and integer field
Revision Changes Path
1.3 +2 -0 cocoon-2.1/src/blocks/woody/samples/forms/form2_bind_bean.xml
Index: form2_bind_bean.xml
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/blocks/woody/samples/forms/form2_bind_bean.xml,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- form2_bind_bean.xml 23 Jul 2003 21:08:55 -0000 1.2
+++ form2_bind_bean.xml 24 Jul 2003 12:42:19 -0000 1.3
@@ -13,6 +13,8 @@
<!-- the email value will not be saved because of the @readonly -->
<wb:field id="email" path="email" readonly="true"/>
<wb:field id="ipaddress" path="ipAddress"/>
+ <wb:field id="birthday" path="birthday"/>
+ <wb:field id="number" path="aNumber"/>
<!-- An aggregatefield is a special kind of widget that lets
the user edit the value of multiple widgets through one text box
1.2 +18 -26 cocoon-2.1/src/blocks/woody/samples/forms/form2_bind_xml.xml
Index: form2_bind_xml.xml
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/blocks/woody/samples/forms/form2_bind_xml.xml,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- form2_bind_xml.xml 23 Jul 2003 15:18:22 -0000 1.1
+++ form2_bind_xml.xml 24 Jul 2003 12:42:19 -0000 1.2
@@ -3,39 +3,23 @@
| Binding template between
| - form_data file (backend)
| - and form_model file
- | Mappings
- | woody-widget <> backend-xpath
- | __________________________________________________
- | {context} /data/wrapper/context
- | {relative info context} info
- | email email
- | somebool - - - - not implemented yet
- | account account/@size
- | number1 number
- | drinks - - - - not implemented yet
- | phone phone
- | cntr @cntr
- | zone zone
- | number number
- |
- | ipaddress ipaddress
-
- | {contacts-repeater} contacts | each row = contact
- | firstname firstname
- | lastname lastname
- | email email
- | phone phone/@nr
-->
<wb:context
xmlns:wb="http://apache.org/cocoon/woody/binding/1.0"
+ xmlns:wd="http://apache.org/cocoon/woody/definition/1.0"
path="/data/wrapper/context" >
<wb:context path="info">
<!-- the email value will not be saved because of the @readonly -->
<wb:field id="email" path="email" readonly="true"/>
+
<!-- jxpath binds to nodes as well as to attributes -->
- <wb:field id="account" path="account/@size" />
- <wb:field id="number1" path="number" />
+ <wb:field 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. -->
+ <wd:convertor datatype="long"/>
+ </wb:field>
<!-- one entry field in the client maps through aggregate fields -->
<wb:aggregate id="phone" path="phone" >
@@ -48,11 +32,19 @@
</wb:context>
- <wb:field id="ipaddress" path="ipaddress" >
+ <wb:field id="ipaddress" path="ipaddress">
<wb:on-update>
<!-- if the value has changed, the attribute will be set -->
- <wb:set-attribute name="changed" value="true" />
+ <wb:set-attribute name="changed" value="true"/>
</wb:on-update>
+ </wb:field>
+
+ <wb:field id="birthday" path="birthday">
+ <wd:convertor datatype="date" type="formatting">
+ <wd:patterns>
+ <wd:pattern>yyyy-MM-dd</wd:pattern>
+ </wd:patterns>
+ </wd:convertor>
</wb:field>
1.2 +3 -6 cocoon-2.1/src/blocks/woody/samples/forms/form2_data.xml
Index: form2_data.xml
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/blocks/woody/samples/forms/form2_data.xml,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- form2_data.xml 22 Jul 2003 11:50:45 -0000 1.1
+++ form2_data.xml 24 Jul 2003 12:42:19 -0000 1.2
@@ -4,11 +4,7 @@
<info>
<email boolBindingWorks="false">yourname@yourdomain.com</email>
- <account size="3" />
- <number>22234</number>
- <drinks> <!-- no binding available yet -->
- <drink>Leffe</drink>
- </drinks>
+ <number value="3"/>
<phone cntr="32">
<zone>2</zone>
@@ -17,6 +13,7 @@
</info>
<ipaddress changed="false">10.34.44.78</ipaddress>
+ <birthday>1960-04-10</birthday>
<contacts>
<contact id="1" row-state="original">
@@ -33,4 +30,4 @@
</contact>
</contacts>
-</context></wrapper></data>
\ No newline at end of file
+</context></wrapper></data>
1.3 +4 -0 cocoon-2.1/src/blocks/woody/samples/forms/form2_jx.xml
Index: form2_jx.xml
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/blocks/woody/samples/forms/form2_jx.xml,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- form2_jx.xml 23 Jul 2003 15:54:40 -0000 1.2
+++ form2_jx.xml 24 Jul 2003 12:42:19 -0000 1.3
@@ -6,6 +6,10 @@
Phone: +${form2bean.phoneCountry}-${form2bean.phoneZone}-${form2bean.phoneNumber}
<br/>
IP Address: ${form2bean.ipAddress}
+ <br/>
+ birthday: ${form2bean.birthday}
+ <br/>
+ number: ${form2bean.aNumber}
<table border="1">
<tr>
1.3 +28 -1 cocoon-2.1/src/blocks/woody/samples/forms/form2_model.xml
Index: form2_model.xml
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/blocks/woody/samples/forms/form2_model.xml,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- form2_model.xml 23 Jul 2003 15:19:20 -0000 1.2
+++ form2_model.xml 24 Jul 2003 12:42:19 -0000 1.3
@@ -37,7 +37,7 @@
</wd:validation>
</wd:aggregatefield>
- <wd:field id="ipaddress" required="true">
+ <wd:field id="ipaddress">
<wd:label>Please enter your IP address</wd:label>
<wd:datatype base="string">
<wd:validation>
@@ -45,6 +45,33 @@
<wd:failmessage>Invalid IP address.</wd:failmessage>
</wd:regexp>
</wd:validation>
+ </wd:datatype>
+ </wd:field>
+
+ <wd:field id="birthday" required="true">
+ <wd:label>Your birthday (dd/MM/yyyy):</wd:label>
+ <wd:datatype base="date">
+ <wd:convertor>
+ <wd:patterns>
+ <wd:pattern>dd/MM/yyyy</wd:pattern>
+ <!-- The above pattern is a non-locale-specific pattern. You can
+ also add locale-specific patterns by adding more wd:pattern elements
+ here, with a locale attribute on them. -->
+ </wd:patterns>
+ </wd:convertor>
+ </wd:datatype>
+ </wd:field>
+
+ <wd:field id="number" required="true">
+ <wd:label>Select a number:</wd:label>
+ <wd:datatype base="long">
+ <wd:selection-list>
+ <wd:item value="1"/>
+ <wd:item value="2"/>
+ <wd:item value="3"/>
+ <wd:item value="4"/>
+ <wd:item value="5"/>
+ </wd:selection-list>
</wd:datatype>
</wd:field>
1.3 +14 -3 cocoon-2.1/src/blocks/woody/samples/forms/form2_template.xsp
Index: form2_template.xsp
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/blocks/woody/samples/forms/form2_template.xsp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- form2_template.xsp 23 Jul 2003 15:18:47 -0000 1.2
+++ form2_template.xsp 24 Jul 2003 12:42:19 -0000 1.3
@@ -17,15 +17,18 @@
<li>the email address is marked in the binding as "read-only", meaning it
will only be bound from bean/xml to form, but not in the other
direction. So you won't see it changed in the bean or the XML.</li>
- <li>the binding supports currently only string properties (will change
- soon). It also doesn't support all widget types yet (e.g. the
+ <li>The binding doesn't support all widget types yet (e.g. the
multivaluefield is currently not yet supported).</li>
+ <li>Note how, in the XML binding, the date is formatted according XML
+ Schema date format in the XML, while it is displayed in another format
+ to the user, and is stored in the form model as a Java Date
+ object (useful for date-specific validations).</li>
</ul>
<p>If you're running the XML-binding demo, then after successful submit
you'll see the updated XML.</p>
<p>If you're running the bean-binding demo, then after successful submit
you'll be shown a page that uses the JXTemplateGenerator to extract
- data from the bean.</p>
+ data from the bean (to show that the bean really has been updated).</p>
<form method="POST">
<xsp:attribute name="action"><xsp:expr><jpath:continuation/>+".continue"</xsp:expr></xsp:attribute>
<table border="1">
@@ -40,6 +43,14 @@
<tr>
<td valign="top"><wt:widget-label id="ipaddress"/></td>
<td valign="top"><wt:widget id="ipaddress"/></td>
+ </tr>
+ <tr>
+ <td valign="top"><wt:widget-label id="birthday"/></td>
+ <td valign="top"><wt:widget id="birthday"/></td>
+ </tr>
+ <tr>
+ <td valign="top"><wt:widget-label id="number"/></td>
+ <td valign="top"><wt:widget id="number"/></td>
</tr>
</table>