You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by ts...@apache.org on 2005/03/27 22:31:43 UTC

svn commit: r159183 [2/4] - in lenya/sandbox: ./ lenya/ lenya/usecases/ lenya/usecases/cformedit/ lenya/usecases/cformedit/flow/ lenya/usecases/cformedit/forms/ lenya/usecases/cformedit/forms/binding/ lenya/usecases/cformedit/resources/

Added: lenya/sandbox/lenya/usecases/cformedit/forms/binding/06namespaced-data.xml
URL: http://svn.apache.org/viewcvs/lenya/sandbox/lenya/usecases/cformedit/forms/binding/06namespaced-data.xml?view=auto&rev=159183
==============================================================================
--- lenya/sandbox/lenya/usecases/cformedit/forms/binding/06namespaced-data.xml (added)
+++ lenya/sandbox/lenya/usecases/cformedit/forms/binding/06namespaced-data.xml Sun Mar 27 12:31:20 2005
@@ -0,0 +1,29 @@
+<?xml version="1.0"?>
+<!--
+  Copyright 1999-2004 The Apache Software Foundation
+
+  Licensed 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.
+-->
+<test>
+    <html:html xmlns:html="http://www.w3.org/1999/xhtml">
+        <html:head>
+            <html:title>some title</html:title>
+        </html:head>
+    </html:html>
+    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+        <xsl:template name="template-name"/>
+    </xsl:stylesheet>
+    <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
+        <fo:page-sequence><fo:flow flow-name="flow-name" /></fo:page-sequence>
+    </fo:root>
+</test>

Added: lenya/sandbox/lenya/usecases/cformedit/forms/binding/06namespaced-def.xml
URL: http://svn.apache.org/viewcvs/lenya/sandbox/lenya/usecases/cformedit/forms/binding/06namespaced-def.xml?view=auto&rev=159183
==============================================================================
--- lenya/sandbox/lenya/usecases/cformedit/forms/binding/06namespaced-def.xml (added)
+++ lenya/sandbox/lenya/usecases/cformedit/forms/binding/06namespaced-def.xml Sun Mar 27 12:31:20 2005
@@ -0,0 +1,35 @@
+<?xml version="1.0"?>
+<!--
+  Copyright 1999-2004 The Apache Software Foundation
+
+  Licensed 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.
+-->
+<fd:form
+  xmlns:fd="http://apache.org/cocoon/forms/1.0#definition"
+  xmlns:i18n="http://apache.org/cocoon/i18n/2.1">
+
+  <fd:widgets>
+    <fd:field id="title">
+      <fd:label>Enter an HTML title</fd:label>
+      <fd:datatype base="string" />
+    </fd:field>
+    <fd:field id="template">
+      <fd:label>Enter an XSL template name</fd:label>
+      <fd:datatype base="string" />
+    </fd:field>  
+    <fd:field id="flowname">
+      <fd:label>And now a XSL:FO flow name</fd:label>
+      <fd:datatype base="string" />
+    </fd:field>  
+  </fd:widgets>
+</fd:form>

Added: lenya/sandbox/lenya/usecases/cformedit/forms/binding/done.jx
URL: http://svn.apache.org/viewcvs/lenya/sandbox/lenya/usecases/cformedit/forms/binding/done.jx?view=auto&rev=159183
==============================================================================
--- lenya/sandbox/lenya/usecases/cformedit/forms/binding/done.jx (added)
+++ lenya/sandbox/lenya/usecases/cformedit/forms/binding/done.jx Sun Mar 27 12:31:20 2005
@@ -0,0 +1,62 @@
+<?xml version="1.0"?>
+<!--
+  Copyright 1999-2004 The Apache Software Foundation
+
+  Licensed 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.
+-->
+
+<page xmlns:jx="http://apache.org/cocoon/templates/jx/1.0">
+
+  <jx:macro name="dumpBean">
+    <jx:parameter name="bean"/>
+    <table cellspacing="2" cellpadding="1" bgcolor="#222222">
+      <jx:forEach select="#{$bean/*}">
+          <tr>
+            <td bgcolor="#eeeeee">#{local-name(.)}</td>
+            <td bgcolor="#ffffff">
+              <jx:choose>
+                <jx:when test="#{starts-with(.,'[object ')}">
+                  <dumpBean bean="#{.}" />
+                </jx:when>
+                <jx:otherwise>
+                  <pre>#{.}</pre>
+                </jx:otherwise>
+              </jx:choose>
+            </td>
+          </tr>
+      </jx:forEach>
+    </table>
+  </jx:macro>
+
+
+  <title>BindingSample :: Result</title>
+  <content>
+    <i>Contents of the #{./backendType} BEAN after using the binding for save():</i>
+    <br/>
+    
+    <blockquote>
+      <dumpBean bean="#{./bean}" />
+    </blockquote>
+    
+    <i>Same sample using different backend-models: 
+      <a href="./binding-#{./sampleCode}-JS.flow">JS</a> - 
+      <a href="./binding-#{./sampleCode}-Java.flow">Java</a> - 
+      <a href="./binding-#{./sampleCode}-XML.flow">XML</a>
+    </i>
+    
+    <br/>
+    
+    <i>Other <a href="./">binding samples</a></i>
+    
+  </content>
+</page>

Added: lenya/sandbox/lenya/usecases/cformedit/forms/car-db.xml
URL: http://svn.apache.org/viewcvs/lenya/sandbox/lenya/usecases/cformedit/forms/car-db.xml?view=auto&rev=159183
==============================================================================
--- lenya/sandbox/lenya/usecases/cformedit/forms/car-db.xml (added)
+++ lenya/sandbox/lenya/usecases/cformedit/forms/car-db.xml Sun Mar 27 12:31:20 2005
@@ -0,0 +1,95 @@
+<?xml version="1.0"?>
+<!--
+  Copyright 1999-2004 The Apache Software Foundation
+
+  Licensed 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.
+-->
+<cars>
+  <!-- Enhancements to this list are welcome !
+       Types with no models will automatically be filled with dumb values. -->
+       
+  <make name="Audi">
+    <!-- found on http://www.audi.fr/ -->
+    <type name="A2">
+      <model name="1.4 75"/>
+      <model name="1.4 TDI"/>
+      <model name="1.4 75 Pack"/>
+      <model name="1.4 TDI Pack"/>
+      <model name="1.6 FSI 110 Pack"/>
+      <model name="1.4 75 Pack Plus"/>
+      <model name="1.6 FSI 110 Pack Plus"/>
+    </type>
+    <type name="A3">
+      <model name="1.6 Attration 102"/>
+      <model name="2.0 FSI Attractin 150"/>
+      <model name="1.6 Ambiente 102"/>
+      <model name="2.0 FSI Ambiente 150"/>
+      <model name="2.0 FSI Ambiente 150 tiptronic"/>
+      <model name="1.6 Ambition 102"/>
+      <model name="2.0 FSI Ambition 150"/>
+      <model name="2.0 FSI Ambition 150 tiptronic"/>
+      <model name="2.0 FSI Ambition Luxe 150"/>
+    </type>
+    <type name="A4">
+      <model name="Berline 1.9 TDI 101"/>
+      <model name="Berline 2.5 TDI 163"/>
+      <model name="Berline 2.5 TDI 163 multitronic"/>
+      <model name="Berline 2.5 TDI 180 quattro"/>
+      <model name="Berline 2.5 TDI 180 quattro tiptronic"/>
+      <model name="Avant 1.9 TDI 101"/>
+      <model name="Avant 1.9 TDI 130"/>
+      <model name="Avant 2.5 TDI 163"/>
+      <model name="Avant 2.5 TDI 163 multitronic"/>
+      <model name="Avant 2.5 TDI 180 quattro"/>
+      <model name="Avant 2.5 TDI 180 tiptronic quattro"/>
+    </type>
+    <type name="A6">
+    </type>
+    <type name="A8">
+    </type>
+    <type name="TT">
+    </type>
+    <type name="Allroad Quattro">
+    </type>
+  </make>
+  <make name="Volkswagen">
+    <type name="Golf">
+    </type>
+    <type name="Passat">
+    </type>
+    <type name="Bora">
+    </type>
+  </make>
+  <make name="Mercedes">
+    <type name="CLK">
+    </type>
+    <type name="SLK">
+    </type>
+  </make>
+  <make name="Renault">
+    <type name="Twingo">
+    </type>
+    <type name="Scenic">
+    </type>
+    <type name="Espace">
+    </type>
+  </make>
+  <make name="Maserati">
+    <type name="Quattroporte">
+    </type>
+    <type name="Coupe">
+    </type>
+    <type name="Spyder">
+    </type>
+  </make>
+</cars>

Added: lenya/sandbox/lenya/usecases/cformedit/forms/carselector_form.xml
URL: http://svn.apache.org/viewcvs/lenya/sandbox/lenya/usecases/cformedit/forms/carselector_form.xml?view=auto&rev=159183
==============================================================================
--- lenya/sandbox/lenya/usecases/cformedit/forms/carselector_form.xml (added)
+++ lenya/sandbox/lenya/usecases/cformedit/forms/carselector_form.xml Sun Mar 27 12:31:20 2005
@@ -0,0 +1,128 @@
+<?xml version="1.0"?>
+<!--
+  Copyright 1999-2004 The Apache Software Foundation
+
+  Licensed 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.
+-->
+<!-- form used to illustrate programmatic changing of listbox content. -->
+<fd:form
+  xmlns:fd="http://apache.org/cocoon/forms/1.0#definition"
+  xmlns:i18n="http://apache.org/cocoon/i18n/2.1"
+  id="carselector">
+
+  <fd:widgets>
+    <fd:field id="make" required="true">
+      <fd:label>Make:</fd:label>
+      <fd:datatype base="string"/>
+      <fd:selection-list src="cocoon:/cars" dynamic="true"/>
+      <fd:on-value-changed>
+        <javascript>
+          java.lang.System.err.println("maker changed from " + event.oldValue + " to " + event.newValue);
+          var value = event.source.value;
+          var typewidget = event.source.lookupWidget("../type");
+          if (value != null) {
+            // Get the corresponding type list
+            typewidget.setSelectionList("cocoon:/cars/" + value);
+            typewidget.setState(Packages.org.apache.cocoon.forms.formmodel.WidgetState.ACTIVE);
+          } else {
+            // Set an empty selection list
+            typewidget.setSelectionList(new Packages.org.apache.cocoon.forms.datatype.EmptySelectionList("Select a maker first"));
+            typewidget.setState(Packages.org.apache.cocoon.forms.formmodel.WidgetState.DISABLED);
+          }
+          // Always set the type value to null. Note that it will also fire an event on the "type"
+          // widget if it already had a value.
+          typewidget.setValue(null);
+          
+          // Fun with messages...
+          var msg = event.source.lookupWidget("../message");
+          if (value == null) {
+            msg.value = "Yep. Choosing a maker is not that easy...";
+          } else {
+            if (event.oldValue == null) {
+              msg.value = "Good. " + value + " makes good cars!";
+            } else {
+              msg.value = "Why not? " + value + " also makes good cars!";
+            }
+          }
+        </javascript>
+      </fd:on-value-changed>
+    </fd:field>
+  
+    <fd:field id="type" required="true" state="disabled">
+      <fd:label>Type:</fd:label>
+      <fd:datatype base="string"/>
+      <fd:selection-list>
+        <fd:item value="">
+          <fd:label>Select a maker first</fd:label>
+        </fd:item>
+      </fd:selection-list>
+      <fd:on-value-changed>
+        <javascript>
+          java.lang.System.err.println("type changed to " + event.source.value);
+          var value = event.source.value;
+          var modelwidget = event.source.lookupWidget("../model");
+          var makewidget = event.source.lookupWidget("../make");
+          if (value != null) {
+            modelwidget.setSelectionList("cocoon:/cars/" + makewidget.value + "/" + value);
+            modelwidget.setState(Packages.org.apache.cocoon.forms.formmodel.WidgetState.ACTIVE);
+          } else {
+            // Set an empty selection list
+            modelwidget.setSelectionList(new Packages.org.apache.cocoon.forms.datatype.EmptySelectionList("Select a type first"));
+            modelwidget.setState(Packages.org.apache.cocoon.forms.formmodel.WidgetState.INVISIBLE);
+          }
+          
+          // Always set the model value to null. Note that it will also fire an event on the "model"
+          // widget if it already had a value.
+          modelwidget.setValue(null);
+          
+          // Fun with messages...
+          if (value != null) {
+            var msg = event.source.lookupWidget("../message");
+            if (event.oldValue == null) {
+              msg.value = "A " + makewidget.value + " " + value + " is a very good choice.";
+            } else {
+              msg.value = "So you prefer a " + value + " ?";
+            }
+          }
+        </javascript>
+      </fd:on-value-changed>
+    </fd:field>
+    
+    <fd:field id="model" required="true" state="invisible">
+      <fd:label>Model:</fd:label>
+      <fd:datatype base="string"/>
+      <fd:selection-list>
+        <fd:item value="">
+          <fd:label>Select a type first</fd:label>
+        </fd:item>
+      </fd:selection-list>
+      <fd:on-value-changed>
+        <javascript>
+          var value = event.source.value;
+          if (value != null) {
+            event.source.lookupWidget("../message").setValue("Model " + value + " is a great car!");
+          } else {
+            // Reset value
+            event.source.value = null;
+          }
+        </javascript>
+      </fd:on-value-changed>
+    </fd:field>
+  
+    <fd:output id="message">
+      <fd:datatype base="string"/>
+    </fd:output>
+  
+  </fd:widgets>
+
+</fd:form>

Added: lenya/sandbox/lenya/usecases/cformedit/forms/carselector_success_jx.xml
URL: http://svn.apache.org/viewcvs/lenya/sandbox/lenya/usecases/cformedit/forms/carselector_success_jx.xml?view=auto&rev=159183
==============================================================================
--- lenya/sandbox/lenya/usecases/cformedit/forms/carselector_success_jx.xml (added)
+++ lenya/sandbox/lenya/usecases/cformedit/forms/carselector_success_jx.xml Sun Mar 27 12:31:20 2005
@@ -0,0 +1,29 @@
+<?xml version="1.0"?>
+<!--
+  Copyright 1999-2004 The Apache Software Foundation
+
+  Licensed 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.
+-->
+
+<!--
+  @version $Id: carselector_success_jx.xml 154563 2005-02-20 21:45:05Z sylvain $
+-->
+
+<page>
+  <title>Car selector result</title>
+  <content>
+    You selected: maker ${request.getAttribute("carselectorform").lookupWidget("make").getValue()},
+    type ${request.getAttribute("carselectorform").lookupWidget("type").getValue()},
+    model ${request.getAttribute("carselectorform").lookupWidget("model").getValue()}
+  </content>
+</page>

Added: lenya/sandbox/lenya/usecases/cformedit/forms/carselector_template.xml
URL: http://svn.apache.org/viewcvs/lenya/sandbox/lenya/usecases/cformedit/forms/carselector_template.xml?view=auto&rev=159183
==============================================================================
--- lenya/sandbox/lenya/usecases/cformedit/forms/carselector_template.xml (added)
+++ lenya/sandbox/lenya/usecases/cformedit/forms/carselector_template.xml Sun Mar 27 12:31:20 2005
@@ -0,0 +1,55 @@
+<?xml version="1.0"?>
+<!--
+  Copyright 1999-2004 The Apache Software Foundation
+
+  Licensed 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.
+-->
+<page xmlns:ft="http://apache.org/cocoon/forms/1.0#template" xmlns:fi="http://apache.org/cocoon/forms/1.0#instance">
+  <title>Car selector</title>
+  <para>This example illustrates how you can programmatically update the
+    content of a selection list.</para>
+  <para>
+    This sample illustrates event-handling in Cocoon Forms and how selection lists can be changed
+    programmatically.
+  </para>
+  <para>
+    Event-handlers are defined in the form definition to update the selection lists and set
+    the comment text below the table. This requires only a few lines of server-side JavaScript.
+    Selection widgets also have a "submit-on-change" attribute set in the form template so that
+    changes are considered immediately by the server.
+  </para>
+  <para>
+    See "carselector_form.xml" and "carselector_template.xml" to see how this is done.
+  </para>
+  <content>
+    <ft:form-template action="carselector" method="POST">
+      <ft:continuation-id/>
+      <fi:group>
+        <fi:styling layout="columns"/>
+        <fi:items>
+          <ft:widget id="make">
+            <fi:styling submit-on-change="true"/>
+          </ft:widget>
+          <ft:widget id="type">
+            <fi:styling submit-on-change="true"/>
+          </ft:widget>
+          <ft:widget id="model">
+            <fi:styling submit-on-change="true"/>
+          </ft:widget>
+          <ft:widget id="message"/>
+          <input type="submit" value="Buy it!"/>
+        </fi:items>
+      </fi:group>
+    </ft:form-template>
+  </content>
+</page>

Added: lenya/sandbox/lenya/usecases/cformedit/forms/countryselector_form.xml
URL: http://svn.apache.org/viewcvs/lenya/sandbox/lenya/usecases/cformedit/forms/countryselector_form.xml?view=auto&rev=159183
==============================================================================
--- lenya/sandbox/lenya/usecases/cformedit/forms/countryselector_form.xml (added)
+++ lenya/sandbox/lenya/usecases/cformedit/forms/countryselector_form.xml Sun Mar 27 12:31:20 2005
@@ -0,0 +1,88 @@
+<?xml version="1.0"?>
+<!--
+  Copyright 1999-2004 The Apache Software Foundation
+
+  Licensed 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.
+-->
+<!-- form used to illustrate programmatic changing of listbox content via the flow model -->
+<fd:form
+  xmlns:fd="http://apache.org/cocoon/forms/1.0#definition"
+  xmlns:i18n="http://apache.org/cocoon/i18n/2.1">
+
+	<fd:widgets>
+	
+	  <fd:field id="us-nonus" required="true">
+	    <fd:label>Residence:</fd:label>
+	    <fd:datatype base="string"/>
+	    <fd:selection-list>
+	      <fd:item value="">
+	        <fd:label>Select where you live</fd:label>
+	      </fd:item>
+	      <fd:item value="us">
+	        <fd:label>In the U.S. of America</fd:label>
+	      </fd:item>
+	      <fd:item value="non-us">
+	        <fd:label>Outside the U.S. of America</fd:label>
+	      </fd:item>
+	    </fd:selection-list>
+	    <fd:on-value-changed>
+	      <javascript>
+	        java.lang.System.err.println("Residence changed from " + event.oldValue + " to " + event.newValue);
+	        var value = event.source.value;
+	        var typewidget = event.source.lookupWidget("../country");
+	        if (value == "us") {
+	          typewidget.setSelectionList(states, "key", "value");
+	        }
+	        else if (value == "non-us") {
+              typewidget.setSelectionList(countries, "key", "value");
+            }
+            else {
+		      // Reset the value (will clear validation error)
+		      event.source.setValue(null);
+		      // Set an empty selection list
+		      typewidget.setSelectionList(new Packages.org.apache.cocoon.forms.datatype.EmptySelectionList("Select a maker first"));
+	        }
+	        // Always set the type value to null. Note that it will also fire an event on the "type"
+	        // widget if it already had a value.
+	        typewidget.setValue(null);
+	      </javascript>
+	    </fd:on-value-changed>
+	  </fd:field>
+	
+	  <fd:field id="country" required="true">
+	    <fd:label>State/Country:</fd:label>
+	    <fd:datatype base="string"/>
+	    <fd:selection-list>
+	      <fd:item value="">
+	        <fd:label>Select U.S./non-U.S. first</fd:label>
+	      </fd:item>
+	    </fd:selection-list>
+	    <fd:on-value-changed>
+	      <javascript>
+	        var value = event.source.value;
+	        if (value != null) {
+	          event.source.lookupWidget("../message").setValue("So you live in  " + value + " ?");
+	        } else {
+	          // Reset value
+	          event.source.value = null;
+	        }
+	      </javascript>
+	    </fd:on-value-changed>
+	  </fd:field>
+	
+	  <fd:output id="message">
+	    <fd:datatype base="string"/>
+	  </fd:output>
+
+	</fd:widgets>
+</fd:form>

Added: lenya/sandbox/lenya/usecases/cformedit/forms/countryselector_success_jx.xml
URL: http://svn.apache.org/viewcvs/lenya/sandbox/lenya/usecases/cformedit/forms/countryselector_success_jx.xml?view=auto&rev=159183
==============================================================================
--- lenya/sandbox/lenya/usecases/cformedit/forms/countryselector_success_jx.xml (added)
+++ lenya/sandbox/lenya/usecases/cformedit/forms/countryselector_success_jx.xml Sun Mar 27 12:31:20 2005
@@ -0,0 +1,28 @@
+<?xml version="1.0"?>
+<!--
+  Copyright 1999-2004 The Apache Software Foundation
+
+  Licensed 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.
+-->
+
+<!--
+  @version $Id: countryselector_success_jx.xml 154563 2005-02-20 21:45:05Z sylvain $
+-->
+
+<page>
+  <title>Country selector result</title>
+  <content>
+    You selected: ${request.getAttribute("countryselectorform").lookupWidget("us-nonus").getValue()}
+    country/state ${request.getAttribute("countryselectorform").lookupWidget("country").getValue()}
+  </content>
+</page>

Added: lenya/sandbox/lenya/usecases/cformedit/forms/countryselector_template.xml
URL: http://svn.apache.org/viewcvs/lenya/sandbox/lenya/usecases/cformedit/forms/countryselector_template.xml?view=auto&rev=159183
==============================================================================
--- lenya/sandbox/lenya/usecases/cformedit/forms/countryselector_template.xml (added)
+++ lenya/sandbox/lenya/usecases/cformedit/forms/countryselector_template.xml Sun Mar 27 12:31:20 2005
@@ -0,0 +1,52 @@
+<?xml version="1.0"?>
+<!--
+  Copyright 1999-2004 The Apache Software Foundation
+
+  Licensed 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.
+-->
+<page xmlns:ft="http://apache.org/cocoon/forms/1.0#template" xmlns:fi="http://apache.org/cocoon/forms/1.0#instance">
+  <title>Country selector</title>
+  <para>This example illustrates how you can programmatically update the
+    content of a selection list using a collection built in the flow.</para>
+  <para>
+    This sample illustrates event-handling in Cocoon Forms and how selection lists can be changed
+    programmatically.
+  </para>
+  <para>
+    Event-handlers are defined in the form definition to update the selection lists and set
+    the comment text below the table. This requires only a few lines of server-side JavaScript.
+    Selection widgets also have a "submit-on-change" attribute set in the form template so that
+    changes are considered immediately by the server.
+  </para>
+  <para>
+    See "countryselector_form.xml" and "countryselector_template.xml" to see how this is done.
+  </para>
+  <content>
+    <ft:form-template action="countryselector" method="POST">
+      <ft:continuation-id/>
+      <fi:group>
+        <fi:styling layout="columns"/>
+        <fi:items>
+          <ft:widget id="us-nonus">
+            <fi:styling submit-on-change="true"/>
+          </ft:widget>
+          <ft:widget id="country">
+            <fi:styling submit-on-change="true"/>
+          </ft:widget>
+          <ft:widget id="message"/>
+          <input type="submit"/>
+        </fi:items>
+      </fi:group>
+    </ft:form-template>
+  </content>
+</page>

Added: lenya/sandbox/lenya/usecases/cformedit/forms/datasource_chooser.xml
URL: http://svn.apache.org/viewcvs/lenya/sandbox/lenya/usecases/cformedit/forms/datasource_chooser.xml?view=auto&rev=159183
==============================================================================
--- lenya/sandbox/lenya/usecases/cformedit/forms/datasource_chooser.xml (added)
+++ lenya/sandbox/lenya/usecases/cformedit/forms/datasource_chooser.xml Sun Mar 27 12:31:20 2005
@@ -0,0 +1,84 @@
+<?xml version="1.0"?>
+<!--
+  Copyright 1999-2004 The Apache Software Foundation
+
+  Licensed 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.
+-->
+
+<!--
+  @version $Id$
+-->
+
+<fd:form xmlns:fd="http://apache.org/cocoon/forms/1.0#definition"
+         xmlns:i18n="http://apache.org/cocoon/i18n/2.1">
+
+  <fd:widgets>
+    <fd:field id="name" required="true">
+      <fd:datatype base="string"/>
+    </fd:field>
+    
+    <!-- The datasource type. This is the union's "case" widget -->
+    <fd:field id="sourcetype">
+      <fd:datatype base="string"/>
+      <!-- The union will initially be showing the "SQL" choice -->
+      <fd:initial-value>SQL</fd:initial-value>
+      <fd:selection-list>
+        <fd:item value=""/>
+        <fd:item value="SQL"/>
+        <fd:item value="file"/>
+      </fd:selection-list>
+    </fd:field>
+    
+    <!-- the datasource contents depends on its type -->
+    <fd:union id="datasource" case="sourcetype">
+      <fd:widgets>
+        
+        <!-- data for an SQL datasource -->
+        <fd:group id="SQL">
+          <fd:widgets>
+            <fd:field id="jdbc-url">
+              <fd:label>JDBC URL</fd:label>
+              <fd:datatype base="string"/>
+              <!-- pre-fill with the sample values in cocoon.xconf -->
+              <fd:initial-value>jdbc:hsqldb:hsql://localhost:9002</fd:initial-value>
+            </fd:field>
+            <fd:field id="login">
+              <fd:label>Login</fd:label>
+              <fd:datatype base="string"/>
+              <fd:initial-value>sa</fd:initial-value>
+            </fd:field>
+            <fd:field id="password">
+              <fd:label>Password</fd:label>
+              <fd:datatype base="string"/>
+            </fd:field>
+          </fd:widgets>
+        </fd:group>
+        
+        <!-- data for a file datasource -->
+        <fd:group id="file">
+          <fd:widgets>
+            <fd:field id="filename">
+              <fd:datatype base="string"/>
+            </fd:field>
+          </fd:widgets>
+        </fd:group>
+      </fd:widgets>
+    </fd:union>
+
+    <fd:submit id="ok">
+      <fd:label>OK</fd:label>
+    </fd:submit>
+    
+  </fd:widgets>
+
+</fd:form>

Added: lenya/sandbox/lenya/usecases/cformedit/forms/datasource_chooser_binding.xml
URL: http://svn.apache.org/viewcvs/lenya/sandbox/lenya/usecases/cformedit/forms/datasource_chooser_binding.xml?view=auto&rev=159183
==============================================================================
--- lenya/sandbox/lenya/usecases/cformedit/forms/datasource_chooser_binding.xml (added)
+++ lenya/sandbox/lenya/usecases/cformedit/forms/datasource_chooser_binding.xml Sun Mar 27 12:31:20 2005
@@ -0,0 +1,45 @@
+<?xml version="1.0"?>
+<!--
+  Copyright 1999-2004 The Apache Software Foundation
+
+  Licensed 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.
+-->
+
+<!--
+  @version $Id$
+-->
+
+<fb:context xmlns:fb="http://apache.org/cocoon/forms/1.0#binding"
+    path="config/datasource">
+  
+  <fb:value id="name" path="@name"/>
+
+  <!-- important: bind the discriminant value first, so that fb:union
+       knows what case to choose --> 
+  <fb:value id="sourcetype" path="@type"/>
+  
+  <fb:union id="datasource" path=".">
+    <fb:case id="SQL" path=".">
+      <fb:group id="SQL" path=".">
+      <fb:value id="jdbc-url" path="URL"/>
+      <fb:value id="login" path="login"/>
+      <fb:value id="password" path="password"/>
+      </fb:group>
+    </fb:case>
+    <fb:case id="file" path=".">
+      <fb:group id="file" path=".">
+        <fb:value id="filename" path="file/@path"/>
+      </fb:group>
+    </fb:case>
+  </fb:union>
+</fb:context>

Added: lenya/sandbox/lenya/usecases/cformedit/forms/datasource_chooser_template.xml
URL: http://svn.apache.org/viewcvs/lenya/sandbox/lenya/usecases/cformedit/forms/datasource_chooser_template.xml?view=auto&rev=159183
==============================================================================
--- lenya/sandbox/lenya/usecases/cformedit/forms/datasource_chooser_template.xml (added)
+++ lenya/sandbox/lenya/usecases/cformedit/forms/datasource_chooser_template.xml Sun Mar 27 12:31:20 2005
@@ -0,0 +1,65 @@
+<?xml version="1.0"?>
+<!--
+  Copyright 1999-2004 The Apache Software Foundation
+
+  Licensed 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.
+-->
+<page xmlns:ft="http://apache.org/cocoon/forms/1.0#template"
+      xmlns:fi="http://apache.org/cocoon/forms/1.0#instance"
+      xmlns:jx="http://apache.org/cocoon/templates/jx/1.0">
+      
+  <!-- Import the macros that define CForms template elements -->
+  <jx:import uri="resource://org/apache/cocoon/forms/generation/jx-macros.xml"/>
+  
+  <title>Datasource chooser</title>
+  <content>
+    <ft:form-template action="#{$cocoon/continuation/id}.continue" method="POST">
+      
+      <p>Datasource name: <ft:widget id="name"/></p>
+      <fieldset>
+        <legend>Type:
+          <ft:widget id="sourcetype"><fi:styling submit-on-change="true"/></ft:widget>
+        </legend>
+        <ft:union id="datasource">
+          <ft:case id="">
+            Please choose a datasource type.
+          </ft:case>
+          <ft:case id="SQL">
+            <ft:group id="SQL">
+              <fi:group>
+                <fi:styling layout="columns"/>
+                <fi:items>
+                  <ft:widget id="jdbc-url"/>
+                  <ft:widget id="login"/>
+                  <ft:widget id="password"><fi:styling type="password"/></ft:widget>
+                </fi:items>
+              </fi:group>
+            </ft:group>
+          </ft:case>
+          <ft:case id="file">
+            <ft:group id="file">
+              File name: <ft:widget id="filename"/>
+            </ft:group>
+          </ft:case>
+        </ft:union>
+      </fieldset>
+      
+      <br/>
+      
+      <ft:widget id="ok"/>
+      <br/>
+      <a href="./do-datasourceChooser.flow">Restart this sample</a> -  <a href="./">Back to samples</a>
+
+    </ft:form-template>
+  </content>
+</page>

Added: lenya/sandbox/lenya/usecases/cformedit/forms/dynamicrepeater.xml
URL: http://svn.apache.org/viewcvs/lenya/sandbox/lenya/usecases/cformedit/forms/dynamicrepeater.xml?view=auto&rev=159183
==============================================================================
--- lenya/sandbox/lenya/usecases/cformedit/forms/dynamicrepeater.xml (added)
+++ lenya/sandbox/lenya/usecases/cformedit/forms/dynamicrepeater.xml Sun Mar 27 12:31:20 2005
@@ -0,0 +1,84 @@
+<?xml version="1.0"?>
+<!--
+  Copyright 1999-2004 The Apache Software Foundation
+
+  Licensed 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.
+-->
+
+<!--
+  @version $Id$
+-->
+
+<fd:form xmlns:fd="http://apache.org/cocoon/forms/1.0#definition"
+         xmlns:i18n="http://apache.org/cocoon/i18n/2.1">
+
+  <fd:widgets>
+  
+    <fd:repeater id="contacts">
+      <fd:widgets>
+        
+        <!-- The ID is here to keep track of row creation order, which can
+            have no relation with row index when the users used move up/down -->
+        <fd:output id="ID">
+          <fd:label>ID</fd:label>
+          <fd:datatype base="integer"/>
+        </fd:output>
+        
+        <fd:field id="firstname">
+          <fd:label>Firstname</fd:label>
+          <fd:datatype base="string"/>
+        </fd:field>
+        
+        <fd:field id="lastname">
+          <fd:label>Lastname</fd:label>
+          <fd:datatype base="string"/>
+        </fd:field>
+        
+        <fd:row-action id="up" command="move-up"/>
+        
+        <fd:row-action id="down" command="move-down"/>
+        
+        <fd:booleanfield id="select">
+          <fd:label>Select</fd:label>
+        </fd:booleanfield>
+        
+      </fd:widgets>
+    </fd:repeater>
+  
+    <fd:repeater-action id="addcontact" command="add-row" repeater="contacts">
+      <fd:label>Add contact</fd:label>
+      <fd:on-action>
+        <fd:javascript>
+          // Increment the row creation ID counter (it has been initialized in
+          // the flowscript when the form was created).
+          // This shows how attributes can be used as a communication means between
+          // application logic and widget event handlers.
+          var form = event.source.form;
+          var count = new java.lang.Integer(form.getAttribute("counter").intValue() + 1);
+          form.setAttribute("counter", count);
+          var repeater = form.getChild("contacts");
+          repeater.getRow(repeater.getSize() - 1).getChild("ID").setValue(count);
+        </fd:javascript>
+      </fd:on-action>
+    </fd:repeater-action>
+  
+    <fd:repeater-action id="removecontacts" command="delete-rows" repeater="contacts" select="select">
+      <fd:label>Remove selected contacts</fd:label>
+    </fd:repeater-action>
+
+    <fd:submit id="submit">
+      <fd:label>Submit</fd:label>
+    </fd:submit>
+  </fd:widgets>
+
+</fd:form>

Added: lenya/sandbox/lenya/usecases/cformedit/forms/dynamicrepeater_binding.xml
URL: http://svn.apache.org/viewcvs/lenya/sandbox/lenya/usecases/cformedit/forms/dynamicrepeater_binding.xml?view=auto&rev=159183
==============================================================================
--- lenya/sandbox/lenya/usecases/cformedit/forms/dynamicrepeater_binding.xml (added)
+++ lenya/sandbox/lenya/usecases/cformedit/forms/dynamicrepeater_binding.xml Sun Mar 27 12:31:20 2005
@@ -0,0 +1,31 @@
+<?xml version="1.0"?>
+<!--
+  Copyright 1999-2004 The Apache Software Foundation
+
+  Licensed 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.
+-->
+
+<!--
+  @version $Id$
+-->
+
+<fb:context xmlns:fb="http://apache.org/cocoon/forms/1.0#binding"
+    path=".">
+    
+  <fb:simple-repeater id="contacts" parent-path="contacts" row-path="contact">
+    <fb:value id="ID" path="@id"/>
+    <fb:value id="firstname" path="firstname"/>
+    <fb:value id="lastname" path="lastname"/>
+  </fb:simple-repeater>
+
+</fb:context>

Added: lenya/sandbox/lenya/usecases/cformedit/forms/dynamicrepeater_template.xml
URL: http://svn.apache.org/viewcvs/lenya/sandbox/lenya/usecases/cformedit/forms/dynamicrepeater_template.xml?view=auto&rev=159183
==============================================================================
--- lenya/sandbox/lenya/usecases/cformedit/forms/dynamicrepeater_template.xml (added)
+++ lenya/sandbox/lenya/usecases/cformedit/forms/dynamicrepeater_template.xml Sun Mar 27 12:31:20 2005
@@ -0,0 +1,111 @@
+<?xml version="1.0"?>
+<!--
+  Copyright 1999-2004 The Apache Software Foundation
+
+  Licensed 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.
+-->
+<!-- This file is similar to form1_template_action.xml. They differ in group layout,
+     form's action attribute (to use continuations) and, this one is a dynamic form
+     template that changes the 'contacts' repeater layout depending on its size -->
+<page xmlns:ft="http://apache.org/cocoon/forms/1.0#template"
+      xmlns:fi="http://apache.org/cocoon/forms/1.0#instance"
+      xmlns:jx="http://apache.org/cocoon/templates/jx/1.0">
+      
+  <!-- Import the macros that define CForms template elements -->
+  <jx:import uri="resource://org/apache/cocoon/forms/generation/jx-macros.xml"/>
+  
+  <title>Dynamic template</title>
+  <style type="text/css">
+    /* Additional styles for alternating row colors */
+    .forms-row-0 td {
+       padding: 5px;
+       background-color: #E0E0E0;
+    }
+
+    .forms-row-1 td {
+       padding: 5px;
+    }
+  </style>
+  
+  <content>
+    <ft:form-template action="#{$cocoon/continuation/id}.continue" method="POST">
+    
+    <p>This is an example of how dynamic templates (using the JX macros) allow to change the
+       page structure depending on the form contents. By adding or removing rows in the repeater
+       below you will see:</p>
+    <ul>
+      <li>when there are no contacts, only the "Add contact" button is displayed and the table isn't shown,</li>
+      <li>when there are some contacts, the "move up" and "move down" buttons are not shown on the first and last lines, respectively.</li>
+    </ul>
+        <jx:choose>
+          <jx:when test="${form.getChild('contacts').getSize() == 0}">
+            <p><strong><em>There are no contacts to display</em></strong></p>
+          </jx:when>
+          <jx:otherwise>
+
+            <table border="1">
+              <tr>
+                <th><ft:repeater-widget-label id="contacts" widget-id="firstname"/></th>
+                <th><ft:repeater-widget-label id="contacts" widget-id="lastname"/></th>
+                <th><ft:repeater-widget-label id="contacts" widget-id="ID"/></th>
+                <th><ft:repeater-widget-label id="contacts" widget-id="select"/></th>
+              </tr>
+                  <!-- The contents of the repeater-widget element is a template that will
+                       be applied to each row in the repeater. -->
+                  <ft:repeater-widget id="contacts">
+                    <tr class="forms-row-${repeaterLoop.index % 2}">
+                      <td><ft:widget id="firstname"/></td>
+                      <td><ft:widget id="lastname"/></td>
+                      <td><ft:widget id="ID"/></td>
+                      <td>
+                        <!-- Don't display the "move up" button on the first row -->
+                        <jx:choose>
+                          <jx:when test="${repeaterLoop.first}">
+                            <img src="resources/img/blank_btn.gif"/>
+                          </jx:when>
+                          <jx:otherwise>
+                            <ft:widget id="up">
+                              <fi:styling type="image" src="resources/img/move_up.gif"/>
+                            </ft:widget>
+                          </jx:otherwise>
+                        </jx:choose>
+                        <!-- Don't display the "move down" button on the first row -->
+                        <jx:choose>
+                          <jx:when test="${repeaterLoop.last}">
+                            <img src="resources/img/blank_btn.gif"/>
+                          </jx:when>
+                          <jx:otherwise>
+                            <ft:widget id="down">
+                              <fi:styling type="image" src="resources/img/move_down.gif"/>
+                            </ft:widget>
+                          </jx:otherwise>
+                        </jx:choose>
+                      <ft:widget id="select"/>
+                      </td>
+                    </tr>
+                  </ft:repeater-widget>
+            </table>
+                </jx:otherwise>
+              </jx:choose>
+              <p>
+                  <ft:widget id="addcontact"/>
+                  <jx:if test="${widget.getChild('contacts').getSize() > 0}">
+                    <ft:widget id="removecontacts"/>
+                  </jx:if>
+              </p>
+            <ft:widget id="submit"/><br/>
+            <a href="./do-dynaRepeater.flow">Restart this sample</a> - <a href="./">Back to samples</a>
+
+    </ft:form-template>
+  </content>
+</page>

Added: lenya/sandbox/lenya/usecases/cformedit/forms/form1.xml
URL: http://svn.apache.org/viewcvs/lenya/sandbox/lenya/usecases/cformedit/forms/form1.xml?view=auto&rev=159183
==============================================================================
--- lenya/sandbox/lenya/usecases/cformedit/forms/form1.xml (added)
+++ lenya/sandbox/lenya/usecases/cformedit/forms/form1.xml Sun Mar 27 12:31:20 2005
@@ -0,0 +1,339 @@
+<?xml version="1.0"?>
+<!--
+  Copyright 1999-2004 The Apache Software Foundation
+
+  Licensed 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.
+-->
+
+<!--
+  @version $Id: form1.xml 155210 2005-02-24 17:02:09Z sylvain $
+-->
+
+<fd:form xmlns:fd="http://apache.org/cocoon/forms/1.0#definition"
+         xmlns:i18n="http://apache.org/cocoon/i18n/2.1">
+
+  <fd:validation>
+    <!-- This demonstrates form level validation -->
+    <fd:javascript>
+      var success = true;
+      var price = widget.lookupWidget("dieselprice");
+      if (price.value &lt; 1) {
+          price.setValidationError(new Packages.org.apache.cocoon.forms.validation.ValidationError("It can not be that low!", false));
+          success = false;
+      }
+      
+      // Must return true/false
+      return success;
+    </fd:javascript>
+  </fd:validation>
+
+  <fd:widgets>
+    <fd:field id="tab-state">
+      <fd:datatype base="string"/>
+    </fd:field>
+  
+    <fd:field id="email" required="true">
+      <fd:datatype base="string"/>
+      <!-- new-style validation, outside of the datatype -->
+      <fd:validation>
+        <fd:email/>
+      </fd:validation>
+      <fd:label>Enter an <b>email</b> address:</fd:label>
+      <fd:help>
+        An email address must be in <i>[name]@[domain].[tld]</i> format.
+        <br/>
+        And if you do not know what <b>email</b> address is, then well, chances are
+        that you do not have it. However, if you have access to the Internet,
+        you can easily get yourself one!
+        <br/>
+        Choose one of the following options:
+        <ul>
+          <li><a href='http://mail.yahoo.com/'>Yahoo! Mail</a></li>
+          <li><a href='http://www.hotmail.com/'>Hotmail</a></li>
+        </ul>
+        <small>Anyway, the point of all this was to show a popup help with mixed html content.</small>
+      </fd:help>
+    </fd:field>
+  
+    <fd:booleanfield id="somebool">
+      <fd:label>Put me <em>on</em> or <em>off</em>.</fd:label>
+    </fd:booleanfield>
+  
+    <fd:field id="fourchars">
+      <fd:label>Select something that's 4 characters long:</fd:label>
+      <fd:datatype base="string"/>
+      <fd:validation>
+        <fd:length exact='2*2'/>
+      </fd:validation>
+      <fd:selection-list src="forms/a-choices.xml"/>
+    </fd:field>
+  
+    <fd:field id="account">
+      <fd:label>Indicate the size of your bank account (in m<sup>3</sup>):</fd:label>
+      <fd:datatype base="long"/>
+      <fd:selection-list>
+        <fd:item value="1"/>
+        <fd:item value="2"/>
+        <fd:item value="3">
+          <fd:label>three</fd:label>
+        </fd:item>
+        <fd:item value="4"/>
+        <fd:item value="5"/>
+      </fd:selection-list>
+    </fd:field>
+  
+    <fd:field id="cowheight">
+      <fd:label>Indicate your height (in cows):</fd:label>
+      <fd:datatype base="long"/>
+      <fd:selection-list>
+        <fd:item value="1"/>
+        <fd:item value="2"/>
+        <fd:item value="3">
+          <fd:label>three</fd:label>
+        </fd:item>
+        <fd:item value="4"/>
+        <fd:item value="5"/>
+      </fd:selection-list>
+    </fd:field>
+  
+    <fd:field id="number1" required="true">
+      <fd:label>Please enter a number<br/>
+      <small>(will automatically set a correct value below if needed)</small>:</fd:label>
+      <fd:datatype base="long"/>
+      <fd:on-value-changed>
+        <javascript>
+          java.lang.System.err.println("Was here!");
+          var newValue = event.source.value;
+          if (newValue != null) {
+            var number2 = event.source.parent.lookupWidget("number2");
+            if (number2.value == null) {
+              number2.setValue(new java.lang.Long(newValue.intValue() + 1));
+            }
+          }
+        </javascript>
+      </fd:on-value-changed>
+    </fd:field>
+  
+    <fd:field id="number2" required="true">
+      <fd:label>Enter another number, larger than the other number:</fd:label>
+      <fd:datatype base="long"/>
+      <fd:validation>
+        <fd:range min="number1 + 1">
+          <fd:failmessage>This number should be larger than the first number.</fd:failmessage>
+        </fd:range>
+      </fd:validation>
+    </fd:field>
+  
+    <fd:multivaluefield id="drinks">
+      <fd:label>Indicate which 2 of the following drinks you'd like to receive:</fd:label>
+      <fd:datatype base="string"/>
+      <fd:validation>
+        <fd:value-count exact="2"/>
+      </fd:validation>
+      <fd:selection-list>
+        <fd:item value="Maes"/>
+        <fd:item value="Jupiler"/>
+        <fd:item value="Leffe"/>
+        <fd:item value="Hoegaarden"/>
+        <fd:item value="Coca Cola"/>
+      </fd:selection-list>
+    </fd:multivaluefield>
+  
+    <fd:aggregatefield id="visa" required="true">
+      <fd:label>Enter your (16-digit) visa number (without spaces)
+        <br/>Your credit card will be billed.
+        <br/><small>Valid test number is: 4111111111111111</small>
+      </fd:label>
+      <fd:help>Use a fake number if <a href="http://cocoon.apache.org">Cocoon</a> is not running on your local computer</fd:help>
+      <fd:datatype base="string"/>
+      <fd:split pattern="([0-9]{4})([0-9]{4})([0-9]{4})([0-9]{4})">
+        <fd:map group="1" field="part1"/>
+        <fd:map group="2" field="part2"/>
+        <fd:map group="3" field="part3"/>
+        <fd:map group="4" field="part4"/>
+        <fd:failmessage>Not a valid 16-digit visa number.</fd:failmessage>
+      </fd:split>
+      <fd:combine expression='Concat(part1,part2,part3,part4)'/>
+      <fd:widgets>
+        <fd:field id="part1">
+          <fd:datatype base="string"/>
+        </fd:field>
+        <fd:field id="part2">
+          <fd:datatype base="string"/>
+        </fd:field>
+        <fd:field id="part3">
+          <fd:datatype base="string"/>
+        </fd:field>
+        <fd:field id="part4">
+          <fd:datatype base="string"/>
+        </fd:field>
+      </fd:widgets>
+      <fd:validation>
+        <fd:mod10>
+          <fd:failmessage>Invalid credit card number.</fd:failmessage>
+        </fd:mod10>
+      </fd:validation>
+    </fd:aggregatefield>
+  
+    <fd:field id="ipaddress" required="true">
+      <fd:label>Please enter your IP address</fd:label>
+      <fd:datatype base="string"/>
+      <fd:validation>
+        <fd:regexp pattern="^([01]?\d\d?|2[0-4]\d|25[0-5])\.([01]?\d\d?|2[0-4]\d|25[0-5])\.([01]?\d\d?|2[0-4]\d|25[0-5])\.([01]?\d\d?|2[0-4]\d|25[0-5])$">
+          <fd:failmessage>Invalid IP address.</fd:failmessage>
+        </fd:regexp>
+      </fd:validation>
+    </fd:field>
+  
+    <fd:field id="birthdate" required="true">
+      <fd:label>Your birthdate (dd/MM/yyyy):</fd:label>
+      <fd:datatype base="date">
+        <fd:convertor>
+          <fd:patterns>
+            <fd:pattern>dd/MM/yyyy</fd:pattern>
+            <!-- The above pattern is a non-locale-specific pattern. You can
+            also add locale-specific patterns by adding more fd:pattern elements
+            here, with a locale attribute on them. -->
+          </fd:patterns>
+        </fd:convertor>
+      </fd:datatype>
+      <fd:validation>
+        <fd:range min="Date(1850, 1, 1)" max="Date(2150, 1, 1)">
+          <fd:failmessage>Dead and not born yet should not bother filling this form</fd:failmessage>
+        </fd:range>
+      </fd:validation>
+    </fd:field>
+  
+    <fd:field id="altbirthdate" required="true">
+      <fd:label>Select a date on which you'd rather had been born:</fd:label>
+      <fd:datatype base="date">
+        <fd:convertor variant="date" style="full"/>
+      </fd:datatype>
+      <fd:selection-list>
+        <!-- The convertor element here is used to specify how the values
+             in the value attributes of the fd:item elements should be
+             interpreted. -->
+        <fd:convertor type="formatting">
+          <fd:patterns>
+            <fd:pattern>yyyyMMdd</fd:pattern>
+          </fd:patterns>
+        </fd:convertor>
+        <fd:item value="13020711"/>
+        <fd:item value="19120623"/>
+        <fd:item value="19690721"/>
+        <fd:item value="19700506"/>
+        <fd:item value="19781014"/>
+        <fd:item value="20010911"/>
+      </fd:selection-list>
+    </fd:field>
+  
+    <fd:field id="altbirthdate2" required="true">
+      <fd:label>Select another date on which you'd rather had been born:</fd:label>
+      <fd:datatype base="date">
+        <fd:convertor variant="date" style="full"/>
+      </fd:datatype>
+      <fd:selection-list type="java" class="org.apache.cocoon.forms.samples.DateTestJavaSelectionList" nullable="false"/>
+    </fd:field>
+
+    <fd:field id="dieselprice" required="true">
+      <fd:label>Price for a liter diesel:</fd:label>
+      <fd:datatype base="decimal">
+        <fd:convertor variant="number">
+          <fd:patterns>
+            <fd:pattern>#.00</fd:pattern>
+          </fd:patterns>
+        </fd:convertor>
+      </fd:datatype>
+    </fd:field>
+  
+    <fd:repeater id="contacts">
+      <fd:validation>
+        <!-- This demonstrates validating a repeater: we check here if all contacts are distinct.
+           A repeater cannot itself display a validation error, and therefore sets a validation
+           error on a field in the offenting row. -->
+        <fd:javascript>
+          var list = new java.util.ArrayList();
+          var success = true;
+          // Iterate on all rows
+          for (var i = 0; i &lt; widget.size; i++) {
+            // Get the row
+            var row = widget.getRow(i);
+            // Compute a key combining the first and last name
+            var key = row.lookupWidget("firstname").value + "/" + row.lookupWidget("lastname").value;
+            if (list.contains(key)) {
+              // already in the list
+              row.lookupWidget("firstname").setValidationError(new Packages.org.apache.cocoon.forms.validation.ValidationError("Duplicate contact name", false));
+              success = false;
+              break; // no need to continue
+            }
+            // Add the current row's key to the list
+            list.add(key);
+          }
+          
+          // Must return true/false
+          return success;
+          
+        </fd:javascript>
+      </fd:validation>
+      <fd:widgets>
+        <fd:field id="firstname">
+          <fd:label>Firstname</fd:label>
+          <fd:datatype base="string"/>
+          <!-- very simple example of creation events (should really find something better) -->
+          <fd:on-create>
+            <fd:javascript>
+              java.lang.System.err.println("Creating a new contact row");
+            </fd:javascript>
+          </fd:on-create>
+        </fd:field>
+        <fd:field id="lastname">
+          <fd:label>Lastname</fd:label>
+          <fd:datatype base="string"/>
+        </fd:field>
+        <fd:field id="phone">
+          <fd:label>Phone</fd:label>
+          <fd:datatype base="string"/>
+        </fd:field>
+        <fd:field id="email">
+          <fd:label>Email</fd:label>
+          <fd:datatype base="string"/>
+          <fd:validation>
+            <fd:email/>
+          </fd:validation>
+        </fd:field>
+        <fd:field id="birthdate">
+          <fd:label>Birthdate (dd/MM/yyyy):</fd:label>
+          <fd:datatype base="date">
+            <fd:convertor>
+              <fd:patterns>
+                <fd:pattern>dd/MM/yyyy</fd:pattern>
+              </fd:patterns>
+            </fd:convertor>
+          </fd:datatype>
+        </fd:field>
+        <fd:booleanfield id="select">
+          <fd:label>Select</fd:label>
+        </fd:booleanfield>
+      </fd:widgets>
+    </fd:repeater>
+  
+    <fd:repeater-action id="addcontact" command="add-row" repeater="contacts">
+      <fd:label>Add contact</fd:label>
+    </fd:repeater-action>
+  
+    <fd:repeater-action id="removecontacts" command="delete-rows" repeater="contacts" select="select">
+      <fd:label>Remove selected contacts</fd:label>
+    </fd:repeater-action>
+  </fd:widgets>
+
+</fd:form>

Added: lenya/sandbox/lenya/usecases/cformedit/forms/form1_success_jx.xml
URL: http://svn.apache.org/viewcvs/lenya/sandbox/lenya/usecases/cformedit/forms/form1_success_jx.xml?view=auto&rev=159183
==============================================================================
--- lenya/sandbox/lenya/usecases/cformedit/forms/form1_success_jx.xml (added)
+++ lenya/sandbox/lenya/usecases/cformedit/forms/form1_success_jx.xml Sun Mar 27 12:31:20 2005
@@ -0,0 +1,43 @@
+<?xml version="1.0"?>
+<!--
+  Copyright 1999-2004 The Apache Software Foundation
+
+  Licensed 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.
+-->
+
+<!--
+  @version $Id: form1_success_jx.xml 154563 2005-02-20 21:45:05Z sylvain $
+-->
+
+<page>
+  <title>Sample form result</title>
+  <content>
+  <!--
+    <xsp:logic>
+        // get reference to form and some of the widgets on it
+        Form form = (Form)request.getAttribute("form1");
+        Field field = (Field)form.lookupWidget("email");
+        BooleanField booleanField = (BooleanField)form.lookupWidget("somebool");
+        Field field2 = (Field)((Repeater)form.lookupWidget("contacts")).getWidget(1, "firstname");
+      </xsp:logic>
+    -->
+    email has the following value:
+    ${request.getAttribute("form1").lookupWidget("email").getValue()}
+    <br/>
+    Second person has this firstname:
+    ${request.getAttribute("form1").lookupWidget("contacts").getWidget(1, "firstname").getValue()}
+    <br/>
+    The value of the checkbox is:
+    ${request.getAttribute("form1").lookupWidget("somebool").getValue()}
+  </content>
+</page>

Added: lenya/sandbox/lenya/usecases/cformedit/forms/form1_template.xml
URL: http://svn.apache.org/viewcvs/lenya/sandbox/lenya/usecases/cformedit/forms/form1_template.xml?view=auto&rev=159183
==============================================================================
--- lenya/sandbox/lenya/usecases/cformedit/forms/form1_template.xml (added)
+++ lenya/sandbox/lenya/usecases/cformedit/forms/form1_template.xml Sun Mar 27 12:31:20 2005
@@ -0,0 +1,142 @@
+<?xml version="1.0"?>
+<!--
+  Copyright 1999-2004 The Apache Software Foundation
+
+  Licensed 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.
+-->
+<!-- This file is similar to form1_template_action.xml. They differ in group layout,
+     form's action attribute (to use continuations) and, this one is a dynamic form
+     template that changes the 'contacts' repeater layout depending on its size -->
+<page xmlns:ft="http://apache.org/cocoon/forms/1.0#template"
+      xmlns:fi="http://apache.org/cocoon/forms/1.0#instance"
+      xmlns:jx="http://apache.org/cocoon/templates/jx/1.0">
+      
+  <!-- Import the macros that define CForms template elements -->
+  <jx:import uri="resource://org/apache/cocoon/forms/generation/jx-macros.xml"/>
+  
+  <title>Sample form</title>
+  <content>
+    <ft:form-template action="#{$cocoon/continuation/id}.continue" method="POST">
+      <div style="width: 90%; margin: 10px 50px 50px 50px;">
+        <!-- group with tabs. Each of the children of <items> will constitute a tab -->
+        <fi:group>
+          <fi:styling type="choice"/>
+          <fi:label>Choose a panel: </fi:label>
+          <fi:state>
+            <ft:widget id="tab-state"/>
+          </fi:state>
+
+          <fi:items>
+            <!-- group with automatic two-column layout -->
+            <fi:group>
+              <fi:label>String fields</fi:label>
+              <fi:styling layout="columns"/>
+              <fi:items>
+                <ft:widget id="email"/>
+                <ft:widget id="birthdate"/>
+                <ft:widget id="fourchars">
+                  <!-- particular styling for the enumeration -->
+                  <fi:styling list-type="listbox" listbox-size="4"/>
+                </ft:widget>
+              </fi:items>
+            </fi:group>
+
+            <fi:group>
+              <fi:label>Number fields</fi:label>
+              <fi:styling layout="columns"/>
+              <fi:items>
+                <ft:widget id="number1">
+                  <fi:styling submit-on-change="true"/>
+                </ft:widget>
+                <ft:widget id="number2"/>
+                <ft:widget id="account"/>
+                <ft:widget id="cowheight">
+                  <fi:styling list-type="radio"/>
+                </ft:widget>
+              </fi:items>
+            </fi:group>
+
+            <fi:group>
+              <fi:styling layout="columns"/>
+              <fi:label>Boolean fields</fi:label>
+              <fi:items>
+                <ft:widget id="somebool"/>
+                <ft:widget id="drinks">
+                  <fi:styling list-type="listbox" listbox-size="4"/>
+                </ft:widget>
+              </fi:items>
+            </fi:group>
+          </fi:items>
+        </fi:group>
+
+        <p>Checkout the <a href="form1">form1 action page</a> for another way of formatting panels</p>
+
+        <fi:group>
+          <fi:styling layout="columns"/>
+          <fi:items>
+            <ft:widget id="visa"/>
+            <ft:widget id="ipaddress"/>
+            <ft:widget id="altbirthdate"/>
+            <ft:widget id="altbirthdate2"/>
+            <ft:widget id="dieselprice"/>
+          </fi:items>
+        </fi:group>
+
+        <!-- manual layout of fields, without use of a fi:group -->
+        <ft:widget-label id="contacts"/><br/>
+        <ft:repeater-size id="contacts"/>
+        <table border="1">
+          <tr>
+            <th><ft:repeater-widget-label id="contacts" widget-id="firstname"/></th>
+            <th><ft:repeater-widget-label id="contacts" widget-id="lastname"/></th>
+            <th><ft:repeater-widget-label id="contacts" widget-id="phone"/></th>
+            <th><ft:repeater-widget-label id="contacts" widget-id="email"/></th>
+            <th><ft:repeater-widget-label id="contacts" widget-id="birthdate"/></th>
+            <th><ft:repeater-widget-label id="contacts" widget-id="select"/></th>
+          </tr>
+          <jx:choose>
+            <jx:when test="${widget.getChild('contacts').getSize() == 0}">
+              <tr><td colspan="6" align="center"><em>There are no contacts to display</em></td></tr>
+            </jx:when>
+            <jx:otherwise>
+              <!-- The contents of the repeater-widget element is a template that will
+                   be applied to each row in the repeater. -->
+              <ft:repeater-widget id="contacts">
+                <tr>
+                  <td><ft:widget id="firstname"/></td>
+                  <td><ft:widget id="lastname"/></td>
+                  <td><ft:widget id="phone"/></td>
+                  <td><ft:widget id="email"/></td>
+                  <td><ft:widget id="birthdate"/></td>
+                  <td><ft:widget id="select"/></td>
+                </tr>
+              </ft:repeater-widget>
+            </jx:otherwise>
+          </jx:choose>
+          <tr>
+            <td colspan="6">
+              <ft:widget id="addcontact"/>
+              <jx:if test="${widget.getChild('contacts').getSize() > 0}">
+                <ft:widget id="removecontacts"/>
+                <br/>
+                <small>Hint: remove all contacts to see how dynamic form templates can change
+                  their layout depending on widget values</small>
+              </jx:if>
+            </td>
+          </tr>
+        </table>
+        <input type="submit"/>
+      </div>
+    </ft:form-template>
+  </content>
+</page>

Added: lenya/sandbox/lenya/usecases/cformedit/forms/form1_template_action.xml
URL: http://svn.apache.org/viewcvs/lenya/sandbox/lenya/usecases/cformedit/forms/form1_template_action.xml?view=auto&rev=159183
==============================================================================
--- lenya/sandbox/lenya/usecases/cformedit/forms/form1_template_action.xml (added)
+++ lenya/sandbox/lenya/usecases/cformedit/forms/form1_template_action.xml Sun Mar 27 12:31:20 2005
@@ -0,0 +1,132 @@
+<?xml version="1.0"?>
+<!--
+  Copyright 1999-2004 The Apache Software Foundation
+
+  Licensed 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.
+-->
+<!-- The only difference between this file and the form1_template_flow.xml
+     is the value of the action attribute on the ft:form-template element -->
+<page xmlns:ft="http://apache.org/cocoon/forms/1.0#template" xmlns:fi="http://apache.org/cocoon/forms/1.0#instance">
+  <title>Sample form</title>
+  <content>
+    <ft:form-template action="form1" method="POST">
+      <div style="width: 90%; margin: 10px 50px 50px 50px;">
+
+        <!-- group with tabs. Each of the children of <items> will constitute a tab -->
+        <fi:group>
+          <fi:styling type="tabs"/>
+          <fi:label>Choose a panel: </fi:label>
+          <fi:state>
+            <ft:widget id="tab-state"/>
+          </fi:state>
+
+          <fi:items>
+            <!-- group with automatic two-column layout -->
+            <fi:group>
+              <fi:label>String fields</fi:label>
+              <fi:styling layout="columns"/>
+              <fi:items>
+                <ft:widget id="email"/>
+                <ft:widget id="fourchars">
+                  <!-- particular styling for the enumeration -->
+                  <fi:styling list-type="listbox" listbox-size="4"/>
+                </ft:widget>
+              </fi:items>
+            </fi:group>
+
+            <fi:group>
+              <fi:label>Number fields</fi:label>
+              <fi:styling layout="columns"/>
+              <fi:items>
+                <ft:widget id="number1">
+                  <fi:styling submit-on-change="true"/>
+                </ft:widget>
+                <ft:widget id="number2"/>
+                <ft:widget id="account"/>
+                <ft:widget id="cowheight">
+                  <fi:styling list-type="radio"/>
+                </ft:widget>
+              </fi:items>
+            </fi:group>
+
+            <fi:group>
+              <fi:styling layout="columns"/>
+              <fi:label>Boolean fields</fi:label>
+              <fi:items>
+                <ft:widget id="somebool"/>
+                <ft:widget id="drinks">
+                  <fi:styling list-type="double-listbox">
+                    <fi:available-label>Available drinks</fi:available-label>
+                    <fi:selected-label>Your selection</fi:selected-label>
+                  </fi:styling>
+                </ft:widget>
+              </fi:items>
+            </fi:group>
+          </fi:items>
+        </fi:group>
+
+        <p>Checkout the <a href="form1.flow">form1 flow page</a> for another way of formatting panels</p>
+
+        <!-- Group of type 'fieldset' will have a surrounding frame -->
+        <fi:group>
+          <fi:styling type="fieldset" layout="columns"/>
+          <fi:label>Misc controls</fi:label>
+          <fi:items>
+            <ft:widget id="visa"/>
+            <ft:widget id="ipaddress"/>
+            <ft:widget id="altbirthdate"/>
+            <ft:widget id="altbirthdate2"/>
+            <ft:widget id="birthdate"/>
+            <ft:widget id="dieselprice"/>
+          </fi:items>
+        </fi:group>
+
+        <!-- manual layout of fields, without use of a fi:group -->
+        <ft:widget-label id="contacts"/><br/>
+        <ft:repeater-size id="contacts"/>
+        <table border="1">
+          <tr>
+            <th><ft:repeater-widget-label id="contacts" widget-id="firstname"/></th>
+            <th><ft:repeater-widget-label id="contacts" widget-id="lastname"/></th>
+            <th><ft:repeater-widget-label id="contacts" widget-id="phone"/></th>
+            <th><ft:repeater-widget-label id="contacts" widget-id="email"/></th>
+            <th><ft:repeater-widget-label id="contacts" widget-id="birthdate"/></th>
+            <th><ft:repeater-widget-label id="contacts" widget-id="select"/></th>
+          </tr>
+          <!-- The contents of the repeater-widget element is a template that will
+               be applied to each row in the repeater. -->
+          <ft:repeater-widget id="contacts">
+            <tr>
+              <td><ft:widget id="firstname"/></td>
+              <td><ft:widget id="lastname"/></td>
+              <td><ft:widget id="phone"/></td>
+              <td><ft:widget id="email"/></td>
+              <td>
+                <ft:widget id="birthdate"/>
+              </td>
+              <td><ft:widget id="select"/></td>
+            </tr>
+          </ft:repeater-widget>
+          <tr>
+            <td colspan="4" align="right">
+              <ft:widget id="addcontact"/>
+              <ft:widget id="removecontacts"/>
+            </td>
+          </tr>
+        </table>
+        <input type="submit"/>
+      </div>
+    </ft:form-template>
+  </content>
+</page>
+

Added: lenya/sandbox/lenya/usecases/cformedit/forms/form2_bind_bean.xml
URL: http://svn.apache.org/viewcvs/lenya/sandbox/lenya/usecases/cformedit/forms/form2_bind_bean.xml?view=auto&rev=159183
==============================================================================
--- lenya/sandbox/lenya/usecases/cformedit/forms/form2_bind_bean.xml (added)
+++ lenya/sandbox/lenya/usecases/cformedit/forms/form2_bind_bean.xml Sun Mar 27 12:31:20 2005
@@ -0,0 +1,91 @@
+<?xml version="1.0"?>
+<!--
+  Copyright 1999-2004 The Apache Software Foundation
+
+  Licensed 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"/>
+
+  <!--
+    - 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="lastname" path="lastName"/>
+      <fb:value id="phone" path="phone"/>
+      <fb:value id="email" path="email"/>
+    </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>

Added: lenya/sandbox/lenya/usecases/cformedit/forms/form2_bind_xml.xml
URL: http://svn.apache.org/viewcvs/lenya/sandbox/lenya/usecases/cformedit/forms/form2_bind_xml.xml?view=auto&rev=159183
==============================================================================
--- lenya/sandbox/lenya/usecases/cformedit/forms/form2_bind_xml.xml (added)
+++ lenya/sandbox/lenya/usecases/cformedit/forms/form2_bind_xml.xml Sun Mar 27 12:31:20 2005
@@ -0,0 +1,131 @@
+<?xml version="1.0"?>
+<!--
+  Copyright 1999-2004 The Apache Software Foundation
+
+  Licensed 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.
+-->
+
+<!--
+  - Binding template between
+  -   * form_data file (backend)
+  -   * and form_model file
+  -->
+<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" direction="load">
+        <!-- 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:javascript id="id" path="@id" direction="save">
+        <fb:save-form>
+          var appValue = jxpathPointer.getValue();
+          if (appValue == '') {
+              var precSiblId = jxpathContext.getValue("../preceding-sibling::contact/@id");
+              var newId = Number(precSiblId) + 1
+              jxpathPointer.setValue(newId.toFixed(0));
+          }
+        </fb:save-form>
+      </fb:javascript>
+      <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>
+      <!-- choose one 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>

Added: lenya/sandbox/lenya/usecases/cformedit/forms/form2_data-result.xml
URL: http://svn.apache.org/viewcvs/lenya/sandbox/lenya/usecases/cformedit/forms/form2_data-result.xml?view=auto&rev=159183
==============================================================================
--- lenya/sandbox/lenya/usecases/cformedit/forms/form2_data-result.xml (added)
+++ lenya/sandbox/lenya/usecases/cformedit/forms/form2_data-result.xml Sun Mar 27 12:31:20 2005
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+
+<links>
+  <title>Apache Lenya Links</title>
+  <link href="http://lenya.apache.org/">Apache Lenya Website</link>
+  <link href="http://wiki.apache.org/lenya/">Apache Lenya Wiki</link>
+  <link href="http://www.yahoo.de">Yahoo</link>
+</links>

Added: lenya/sandbox/lenya/usecases/cformedit/forms/form2_data.xml
URL: http://svn.apache.org/viewcvs/lenya/sandbox/lenya/usecases/cformedit/forms/form2_data.xml?view=auto&rev=159183
==============================================================================
--- lenya/sandbox/lenya/usecases/cformedit/forms/form2_data.xml (added)
+++ lenya/sandbox/lenya/usecases/cformedit/forms/form2_data.xml Sun Mar 27 12:31:20 2005
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Copyright 1999-2004 The Apache Software Foundation
+
+  Licensed 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.
+-->
+
+<data>
+  <wrapper>
+    <context>
+
+      <info>
+        <email boolBindingWorks="false">yourname@yourdomain.com</email>
+        <number value="3"/>
+        <choose value="true"/>
+        
+        <phone cntr="32">
+          <zone>2</zone>
+          <number>2222222</number>
+        </phone>
+      </info>
+        
+      <ipaddress changed="false">10.34.44.78</ipaddress>
+      <birthday>1960-04-10</birthday>
+      
+      <drinks>
+        <drink>Jupiler</drink>
+        <drink>Hoegaarden</drink>
+      </drinks>
+
+      <contacts>
+        <contact id="1" row-state="original">
+          <firstname>Lucien</firstname>
+          <lastname>Vandevelde</lastname>
+          <phone nr="+32-2-2222222"/>
+          <email>lv@vdvld.be</email>
+        </contact>
+        <contact id="2" row-state="original">
+          <firstname>Joris</firstname>
+          <lastname>Veldweghel</lastname>
+          <phone nr="+32-59-595959"/>
+          <email>jrsvldwghl@hotmail.com</email>
+        </contact>
+      </contacts>
+        
+    </context>
+  </wrapper>
+</data>

Added: lenya/sandbox/lenya/usecases/cformedit/forms/form2_jx.xml
URL: http://svn.apache.org/viewcvs/lenya/sandbox/lenya/usecases/cformedit/forms/form2_jx.xml?view=auto&rev=159183
==============================================================================
--- lenya/sandbox/lenya/usecases/cformedit/forms/form2_jx.xml (added)
+++ lenya/sandbox/lenya/usecases/cformedit/forms/form2_jx.xml Sun Mar 27 12:31:20 2005
@@ -0,0 +1,66 @@
+<?xml version="1.0"?>
+<!--
+  Copyright 1999-2004 The Apache Software Foundation
+
+  Licensed 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.
+-->
+<html xmlns:jx="http://apache.org/cocoon/templates/jx/1.0">
+  <body>
+    Email: ${form2bean.email}
+    <br/>
+    Phone: +${form2bean.phoneCountry}-${form2bean.phoneZone}-${form2bean.phoneNumber}
+    <br/>
+    IP Address: ${form2bean.ipAddress}
+    <br/>
+    birthday: ${form2bean.birthday}
+    <br/>
+    number: ${form2bean.aNumber}
+    <br/>
+    I choose: ${form2bean.choose}
+    <br/>
+    Sex: <i18n:text xmlns:i18n="http://apache.org/cocoon/i18n/2.1">${form2bean.sex}</i18n:text>
+
+    <table border="1">
+      <tr>
+        <th>id</th>
+        <th>firstName</th>
+        <th>lastName</th>
+        <th>phone</th>
+        <th>email</th>
+      </tr>
+      <jx:forEach var="item" items="${form2bean.contacts}">
+        <tr>
+          <td>${item.id}</td>
+          <td>${item.firstName}</td>
+          <td>${item.lastName}</td>
+          <td>${item.phone}</td>
+          <td>${item.email}</td>
+        </tr>
+      </jx:forEach>
+    </table>
+
+    <table border="1">
+      <tr>
+        <th>drinks</th>
+      </tr>
+      <jx:forEach var="item" items="${form2bean.drinks}">
+        <tr>
+          <td>${item}</td>
+        </tr>
+      </jx:forEach>
+    </table>
+
+    <br/>
+    <a href="form2bean.flow">Do it again</a>
+  </body>
+</html>



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org