Author: sylvain
Date: Mon Oct 11 03:00:47 2004
New Revision: 54533

Added:
   
cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/forms/datasource_chooser.xml
   (contents, props changed)
   
cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/forms/datasource_chooser_binding.xml
   (contents, props changed)
   
cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/forms/datasource_chooser_template.xml
   (contents, props changed)
   
cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/forms/dynamicrepeater.xml 
  (contents, props changed)
   
cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/forms/dynamicrepeater_binding.xml
   (contents, props changed)
   
cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/forms/dynamicrepeater_template.xml
   (contents, props changed)
   cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/forms/tasktree.xml   
(contents, props changed)
   
cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/forms/tasktree_binding.xml
   (contents, props changed)
   
cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/forms/tasktree_template.xml
   (contents, props changed)
Modified:
   
cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/WidgetDefinitionList.java
   
cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/generation/jx-macros.xml
   
cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/flow/forms_flow_example.js
   cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/sitemap.xmap
   cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/welcome.xml
Log:
New samples from the GT presentation

Modified: 
cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/WidgetDefinitionList.java
==============================================================================
--- 
cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/WidgetDefinitionList.java
      (original)
+++ 
cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/formmodel/WidgetDefinitionList.java
      Mon Oct 11 03:00:47 2004
@@ -27,7 +27,7 @@
  * Helper class for the Definition implementation of widgets containing
  * other widgets.
  * 
- * @version $Id: WidgetDefinitionList.java,v 1.2 2004/05/07 16:43:42 mpo Exp $
+ * @version $Id$
  */
 public class WidgetDefinitionList {
     private List widgetDefinitions = new ArrayList();
@@ -102,11 +102,12 @@
         } else {
             // Non-terminating recursion detection
             if (resolving == true) {
-               // Search up parent list in hopes of finding a "Union" before 
finding previous "New" for this "Class".
+               // Search up parent list in hopes of finding a "Union" or 
"Repeater" before finding previous "New" for this "Class".
                 ListIterator parentsIt = parents.listIterator(parents.size());
                 while(parentsIt.hasPrevious()) {
                     WidgetDefinition widgetDefinition = 
(WidgetDefinition)parentsIt.previous();
                     if (widgetDefinition instanceof UnionDefinition) break;
+                    if (widgetDefinition instanceof RepeaterDefinition) break;
                     if (widgetDefinition == definition) {
                         String location = definition.getLocation();
                         if (parent instanceof FormDefinition) {

Modified: 
cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/generation/jx-macros.xml
==============================================================================
--- 
cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/generation/jx-macros.xml
 (original)
+++ 
cocoon/branches/BRANCH_2_1_X/src/blocks/forms/java/org/apache/cocoon/forms/generation/jx-macros.xml
 Mon Oct 11 03:00:47 2004
@@ -146,7 +146,13 @@
 
 
     <!--
-        ft:aggregate-widget : TODO
+        ft:aggregate-widget
     -->
-    
+       <jx:macro name="aggregate-widget" 
targetNamespace="http://apache.org/cocoon/forms/1.0#template";>
+         <jx:parameter name="id"/>
+      
+      <jx:set var="widget" value="${cformsHelper.getWidget(widget, id)}"/>
+      <jx:evalBody/>
+    </jx:macro>
+        
 </jx:template>

Modified: 
cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/flow/forms_flow_example.js
==============================================================================
--- 
cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/flow/forms_flow_example.js
    (original)
+++ 
cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/flow/forms_flow_example.js
    Mon Oct 11 03:00:47 2004
@@ -78,3 +78,46 @@
     return null;
 }
 
+function do_dynaRepeater() {
+    var form = new Form("forms/dynamicrepeater.xml");
+    form.setAttribute("counter", new java.lang.Integer(0));
+    form.showForm("dynamicrepeater-display-pipeline.jx");
+    
+    var doc = 
Packages.javax.xml.parsers.DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
+    doc.appendChild(doc.createElement("contacts"));
+    form.createBinding("forms/dynamicrepeater_binding.xml");
+    
+    form.save(doc);
+    cocoon.sendPage("xmlresult-display-pipeline.jx",
+        {title: "Contact list", document: doc}
+    );
+}
+
+function do_datasourceChooser() {
+    var form = new Form("forms/datasource_chooser.xml");
+    form.showForm("datasource_chooser-display-pipeline.jx");
+    
+    var doc = 
Packages.javax.xml.parsers.DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
+    doc.appendChild(doc.createElement("config"));
+    form.createBinding("forms/datasource_chooser_binding.xml");
+    form.save(doc);
+    
+    cocoon.sendPage("xmlresult-display-pipeline.jx",
+        {title: "Here's the datasource definition", document: doc}
+    );
+}
+
+function do_taskTree() {
+    var form = new Form("forms/tasktree.xml");
+    form.showForm("tasktree-display-pipeline.jx");
+    
+    var doc = 
Packages.javax.xml.parsers.DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
+    doc.appendChild(doc.createElement("project"));
+    form.createBinding("forms/tasktree_binding.xml");
+    form.save(doc);
+    
+    cocoon.sendPage("xmlresult-display-pipeline.jx",
+        {title: "Here's the resulting project definition", document: doc}
+    );
+}
+

Added: 
cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/forms/datasource_chooser.xml
==============================================================================
--- (empty file)
+++ 
cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/forms/datasource_chooser.xml
  Mon Oct 11 03:00:47 2004
@@ -0,0 +1,79 @@
+<?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.
+-->
+
+<!--+
+    | CVS $Id: form1.xml 37200 2004-08-30 13:34:40Z cziegeler $
+    +-->
+
+<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"/>
+      <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:struct id="SQL">
+          <fd:widgets>
+            <fd:field id="jdbc-url">
+              <fd:label>JDBC URL</fd:label>
+              <fd:datatype base="string"/>
+            </fd:field>
+            <fd:field id="login">
+              <fd:label>Login</fd:label>
+              <fd:datatype base="string"/>
+            </fd:field>
+            <fd:field id="password">
+              <fd:label>Password</fd:label>
+              <fd:datatype base="string"/>
+            </fd:field>
+          </fd:widgets>
+        </fd:struct>
+        
+        <!-- data for a file datasource -->
+        <fd:struct id="file">
+          <fd:widgets>
+            <fd:field id="filename">
+              <fd:datatype base="string"/>
+            </fd:field>
+          </fd:widgets>
+        </fd:struct>
+      </fd:widgets>
+    </fd:union>
+
+    <fd:submit id="ok" action-command="foo">
+      <fd:label>OK</fd:label>
+    </fd:submit>
+    
+  </fd:widgets>
+
+</fd:form>

Added: 
cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/forms/datasource_chooser_binding.xml
==============================================================================
--- (empty file)
+++ 
cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/forms/datasource_chooser_binding.xml
  Mon Oct 11 03:00:47 2004
@@ -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.
+-->
+
+<!--+
+    | CVS $Id: form1.xml 37200 2004-08-30 13:34:40Z cziegeler $
+    +-->
+
+<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:struct id="SQL" path=".">
+      <fb:value id="jdbc-url" path="URL"/>
+      <fb:value id="login" path="login"/>
+      <fb:value id="password" path="password"/>
+      </fb:struct>
+    </fb:case>
+    <fb:case id="file" path=".">
+      <fb:value id="file" path="file/@path"/>
+    </fb:case>
+  </fb:union>
+</fb:context>

Added: 
cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/forms/datasource_chooser_template.xml
==============================================================================
--- (empty file)
+++ 
cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/forms/datasource_chooser_template.xml
 Mon Oct 11 03:00:47 2004
@@ -0,0 +1,63 @@
+<?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="#{$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:struct 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:struct>
+          </ft:case>
+          <ft:case id="file">
+            <ft:struct id="file">
+              File name: <ft:widget id="filename"/>
+            </ft:struct>
+          </ft:case>
+        </ft:union>
+      </fieldset>
+      
+      <br/>
+      
+      <ft:widget id="ok"/>
+
+    </ft:form-template>
+  </content>
+</page>

Added: 
cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/forms/dynamicrepeater.xml
==============================================================================
--- (empty file)
+++ 
cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/forms/dynamicrepeater.xml 
    Mon Oct 11 03:00:47 2004
@@ -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.
+-->
+
+<!--+
+    | CVS $Id: form1.xml 37200 2004-08-30 13:34:40Z cziegeler $
+    +-->
+
+<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" action-command="move-up"/>
+        
+        <fd:row-action id="down" action-command="move-down"/>
+        
+        <fd:booleanfield id="select">
+          <fd:label>Select</fd:label>
+        </fd:booleanfield>
+        
+      </fd:widgets>
+    </fd:repeater>
+  
+    <fd:repeater-action id="addcontact" action-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);
+          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" action-command="delete-rows" 
repeater="contacts" select="select">
+      <fd:label>Remove selected contacts</fd:label>
+    </fd:repeater-action>
+
+    <fd:submit id="submit" action-command="foo" >
+      <fd:label>Submit</fd:label>
+    </fd:submit>
+  </fd:widgets>
+
+</fd:form>

Added: 
cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/forms/dynamicrepeater_binding.xml
==============================================================================
--- (empty file)
+++ 
cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/forms/dynamicrepeater_binding.xml
     Mon Oct 11 03:00:47 2004
@@ -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.
+-->
+
+<!--+
+    | CVS $Id: form1.xml 37200 2004-08-30 13:34:40Z cziegeler $
+    +-->
+
+<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: 
cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/forms/dynamicrepeater_template.xml
==============================================================================
--- (empty file)
+++ 
cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/forms/dynamicrepeater_template.xml
    Mon Oct 11 03:00:47 2004
@@ -0,0 +1,110 @@
+<?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="#{$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/blank_btn.gif"/>
+                          </jx:when>
+                          <jx:otherwise>
+                            <ft:widget id="up">
+                              <fi:styling type="image" 
src="resources/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/blank_btn.gif"/>
+                          </jx:when>
+                          <jx:otherwise>
+                            <ft:widget id="down">
+                              <fi:styling type="image" 
src="resources/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"/>
+
+    </ft:form-template>
+  </content>
+</page>

Added: cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/forms/tasktree.xml
==============================================================================
--- (empty file)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/forms/tasktree.xml    
Mon Oct 11 03:00:47 2004
@@ -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.
+-->
+
+<!--+
+    | A form for a work breakdown in a tree of tasks.
+    |
+    | CVS $Id: form1.xml 37200 2004-08-30 13:34:40Z cziegeler $
+    +-->
+
+<fd:form xmlns:fd="http://apache.org/cocoon/forms/1.0#definition";
+         xmlns:i18n="http://apache.org/cocoon/i18n/2.1";>
+
+  <fd:widgets>
+  
+    <!-- a list of tasks -->
+    <fd:class id="tasklist-class">
+      <fd:widgets>
+        <fd:repeater id="tasks">
+          <fd:widgets>
+            <!-- inline widget definitions from task-class -->
+            <fd:new id="task-class"/>
+          </fd:widgets>
+        </fd:repeater>
+        <fd:repeater-action id="addsub" repeater="tasks" 
action-command="add-row">
+          <fd:label>Add subtasks</fd:label>
+        </fd:repeater-action>
+      </fd:widgets>
+    </fd:class>
+    
+    <!-- a task -->
+    <fd:class id="task-class">
+      <fd:widgets>
+      <!-- FIXME: doesn't work if there's not an enclosing struct -->
+        <fd:struct id="task">
+          <fd:widgets>
+            <fd:field id="title">
+              <fd:datatype base="string"/>
+            </fd:field>
+            <fd:field id="start">
+              <fd:datatype base="date"/>
+            </fd:field>
+            <fd:field id="end">
+              <fd:datatype base="date"/>
+            </fd:field>
+            
+            <!-- these actions will act on the "tasks" repeater in which this 
class is inlined -->
+            <fd:row-action id="add" action-command="add-after">
+              <fd:label>+</fd:label>
+            </fd:row-action>
+            <fd:row-action id="up" action-command="move-up">
+              <fd:label>^</fd:label>
+            </fd:row-action>
+            <fd:row-action id="down" action-command="move-down">
+              <fd:label>v</fd:label>
+            </fd:row-action>
+            <fd:row-action id="delete" action-command="delete">
+              <fd:label>X</fd:label>
+            </fd:row-action>
+            
+            <!-- the substasks -->
+            <fd:new id="tasklist-class"/>
+            
+          </fd:widgets>
+        </fd:struct>
+      </fd:widgets>
+    </fd:class>
+
+    <!-- the project's name -->
+    <fd:field id="name" required="true">
+      <fd:datatype base="string"/>
+    </fd:field>
+    
+    <!-- the top-level tasks -->
+    <fd:new id="tasklist-class"/>
+    
+    <fd:submit id="ok" action-command="foo">
+      <fd:label>OK</fd:label>
+    </fd:submit>
+    
+  </fd:widgets>
+</fd:form>

Added: 
cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/forms/tasktree_binding.xml
==============================================================================
--- (empty file)
+++ 
cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/forms/tasktree_binding.xml
    Mon Oct 11 03:00:47 2004
@@ -0,0 +1,49 @@
+<?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.
+-->
+
+<!--+
+    | CVS $Id: form1.xml 37200 2004-08-30 13:34:40Z cziegeler $
+    +-->
+
+<fb:context xmlns:fb="http://apache.org/cocoon/forms/1.0#binding";
+    xmlns:fd="http://apache.org/cocoon/forms/1.0#definition";
+    path="project">
+
+  <fb:class id="tasklist-class">
+    <fb:simple-repeater id="tasks" parent-path="tasks" row-path="task"
+       delete-parent-if-empty="true">
+      <fb:new id="task-class"/>
+    </fb:simple-repeater>
+  </fb:class>
+  
+  <fb:class id="task-class">
+    <fb:struct id="task" path=".">
+      <fb:value id="title" path="title"/>
+      <fb:value id="start" path="@start">
+        <fd:convertor datatype="date" type="formatting" style="short"/>
+      </fb:value>
+      <fb:value id="end" path="@end">
+        <fd:convertor datatype="date" type="formatting" style="short"/>
+      </fb:value>
+      <fb:new id="tasklist-class"/>
+    </fb:struct>
+  </fb:class>
+  
+  <fb:value id="name" path="name"/>
+
+  <fb:new id="tasklist-class"/>
+</fb:context>
\ No newline at end of file

Added: 
cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/forms/tasktree_template.xml
==============================================================================
--- (empty file)
+++ 
cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/forms/tasktree_template.xml
   Mon Oct 11 03:00:47 2004
@@ -0,0 +1,120 @@
+<?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"/>
+  
+  <!-- Debugging utility that dumps the result of widget.getChildren().
+       Sometimes useful when setting up recursive templates ! -->
+  <jx:macro name="dump">
+    <jx:parameter name="iterator"/>
+    
+    <jx:if test="${iterator.hasNext()}">
+      ${iterator.next()} -
+      <dump iterator="${iterator}"/>
+    </jx:if>
+  </jx:macro>
+  
+  <title>Task list editor</title>
+  
+  <style type="text/css">
+    /* The actions buttons, placed on the right */
+    .actions {
+      float: right;
+      padding-top: 0.2em;
+    }
+    
+    /* A "section" contains a task, related actions and subtasks */
+    div.section {
+      padding-top: 0.4em;
+      padding-bottom: 0.4em;
+      padding-left: 0.4em;
+      border: 1px dotted black;
+      mmargin-top: 0.4em;
+      margin-bottom: -1px;
+    }
+    
+    /* Indent sub-sections (recursively) */
+    div.section div.section {
+      margin-left: 3em;
+      border-right: none;
+    }
+    
+    /* Change bg color depending on nesting depth */
+    div.section div.section { background-color: #F0F0F0; }
+    div.section div.section div.section { background-color: #E0E0E0; }
+    div.section div.section div.section div.section { background-color: 
#D0D0D0; }
+    div.section div.section div.section div.section div.section { 
background-color: #C0C0C0; }
+    
+  </style>
+  <content>
+    <ft:form-template action="#{$continuation/id}.continue" method="POST">
+    
+      <ft:class id="task-class">
+        <div class="section">
+          <ft:struct id="task">
+            <span class="actions">
+              <ft:widget id="down"><fi:styling type="image" 
src="resources/move_down.gif"/></ft:widget>
+              <ft:widget id="up"><fi:styling type="image" 
src="resources/move_up.gif"/></ft:widget>
+              <ft:widget id="delete"><fi:styling type="image" 
src="resources/delete.gif"/></ft:widget>
+              <ft:widget id="add"><fi:styling type="image" 
src="resources/new.gif"/></ft:widget>
+            </span>
+            Title: <ft:widget id="title"/>
+            From <ft:widget id="start"><fi:styling size="10"/></ft:widget>
+            to <ft:widget id="end"><fi:styling size="10"/></ft:widget>
+            
+            <!-- Recurse -->
+            <ft:new id="tasklist-class"/>
+            
+          </ft:struct>
+        </div>
+      </ft:class>
+      
+      <ft:class id="tasklist-class">
+        <!-- Show the "Add subtask" button only if there are currently no 
subtasks.
+             If there are some, more subtasks can be added using the "+" 
button -->
+        <jx:choose>
+          <jx:when test="${widget.getChild('tasks').getSize() > 0}">
+            <ft:repeater-widget id="tasks">
+              <!-- recurse -->
+              <ft:new id="task-class"/>
+              
+            </ft:repeater-widget>
+          </jx:when>
+          <jx:otherwise>
+            <ft:widget id="addsub"/>
+          </jx:otherwise>
+        </jx:choose>
+      </ft:class>
+      
+      Project name: <ft:widget id="name"/>
+      
+      <br/>
+      
+      <ft:new id="tasklist-class"/>
+      
+      <br/>
+      
+      <ft:widget id="ok"/>
+      
+      <a href="do-taskTree.flow">Restart this sample</a>
+    </ft:form-template>
+  </content>
+</page>

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/sitemap.xmap
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/sitemap.xmap  
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/sitemap.xmap  Mon Oct 
11 03:00:47 2004
@@ -149,10 +149,14 @@
        </map:call>
      </map:match>
 
+     <map:match pattern="do-*.flow">
+       <map:call function="do_{1}"/>
+     </map:match>
+
      <map:match pattern="*.continue">
        <map:call continuation="{1}"/>
      </map:match>
-
+     
      <!--
         | Show a form, using the forms transformer
         -->

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/welcome.xml
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/welcome.xml   
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/welcome.xml   Mon Oct 
11 03:00:47 2004
@@ -74,6 +74,27 @@
   <sample name="Flowscript" href="form1.flow?locale=de-DE">Germany</sample>
   <sample name="Flowscript" href="form1.flow?locale=nl-BE">Belgium 
(dutch)</sample>
  </group>
+ 
+ <group name="Dynamic templates and recursive forms">
+   <note>
+     These samples were written for the GT2004 presentation about dynamic 
templates and recursive forms.
+     They illustrate the use of "jx-macros.xml" to interpret form template 
elements within the generator,
+     allowing the page layout to depend on the contents of the form, and the 
use of fd:union and fd:class
+     widgets.
+   </note>
+   <sample name="Dynamic repeater template" href="do-dynaRepeater.flow">
+     Shows a simple repeater, which isn't displayed at all if empty, and whose 
row action depend on
+     the row number.
+   </sample>
+   <sample name="Datasource chooser" href="do-datasourceChooser.flow">
+     A datasource chooser, illustrating the fd:union widget.
+   </sample>
+   <sample name="Task tree" href="do-taskTree.flow">
+     A project work breakdown into a hierarchy of tasks, showing the use of 
the fd:class and fd:new
+     widgets.
+   </sample>
+ </group>
+ 
  <group name="Experimental Flowscript API for Cocoon Forms">
   <note>
     The sample below demonstrates a proposal for a new Flowscript API, 
including a multipage form with a back button.

Reply via email to