cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sylv...@apache.org
Subject svn commit: r171291 [2/2] - in /cocoon/branches/BRANCH_2_1_X: ./ src/blocks/forms/java/org/apache/cocoon/forms/binding/ src/blocks/forms/java/org/apache/cocoon/forms/datatype/ src/blocks/forms/java/org/apache/cocoon/forms/datatype/convertor/ src/blocks/forms/java/org/apache/cocoon/forms/datatype/typeimpl/ src/blocks/forms/java/org/apache/cocoon/forms/flow/javascript/ src/blocks/forms/java/org/apache/cocoon/forms/formmodel/ src/blocks/forms/java/org/apache/cocoon/forms/generation/ src/blocks/forms/java/org/apache/cocoon/forms/resources/js/ src/blocks/forms/java/org/apache/cocoon/forms/samples/captcha/ src/blocks/forms/java/org/apache/cocoon/forms/samples/captcha/flow/ src/blocks/forms/java/org/apache/cocoon/forms/samples/captcha/forms/ src/blocks/forms/samples/ src/blocks/forms/samples/flow/ src/blocks/forms/samples/forms/ src/blocks/forms/samples/resources/ src/blocks/forms/test/org/apache/cocoon/forms/datatype/convertor/ src/java/org/apache/cocoon/transformation/
Date Sun, 22 May 2005 08:38:05 GMT
Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/forms/dynamicrepeater_template.xml
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/forms/dynamicrepeater_template.xml?rev=171291&r1=171290&r2=171291&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/forms/dynamicrepeater_template.xml
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/forms/dynamicrepeater_template.xml
Sun May 22 01:38:04 2005
@@ -38,7 +38,7 @@
   </style>
   
   <content>
-    <ft:form-template action="#{$cocoon/continuation/id}.continue" method="POST">
+    <ft:form-template action="#{$cocoon/continuation/id}.continue" method="POST" ajax="true">
     
     <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
@@ -47,8 +47,9 @@
       <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>
+      <ft:repeater id="contacts">
         <jx:choose>
-          <jx:when test="${form.getChild('contacts').getSize() == 0}">
+          <jx:when test="${repeater.getSize() == 0}">
             <p><strong><em>There are no contacts to display</em></strong></p>
           </jx:when>
           <jx:otherwise>
@@ -62,7 +63,7 @@
               </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">
+                  <ft:repeater-rows>
                     <tr class="forms-row-${repeaterLoop.index % 2}">
                       <td><ft:widget id="firstname"/></td>
                       <td><ft:widget id="lastname"/></td>
@@ -93,16 +94,17 @@
                       <ft:widget id="select"/>
                       </td>
                     </tr>
-                  </ft:repeater-widget>
+                  </ft:repeater-rows>
             </table>
                 </jx:otherwise>
               </jx:choose>
-              <p>
+             <p>
                   <ft:widget id="addcontact"/>
                   <jx:if test="${widget.getChild('contacts').getSize() > 0}">
                     <ft:widget id="removecontacts"/>
                   </jx:if>
               </p>
+            </ft:repeater>
             <ft:widget id="submit"/><br/>
             <a href="./do-dynaRepeater.flow">Restart this sample</a> - <a
href="./">Back to samples</a>
 

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/forms/tasktree_template.xml
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/forms/tasktree_template.xml?rev=171291&r1=171290&r2=171291&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/forms/tasktree_template.xml (original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/forms/tasktree_template.xml Sun
May 22 01:38:04 2005
@@ -65,7 +65,7 @@
     
   </style>
   <content>
-    <ft:form-template action="#{$cocoon/continuation/id}.continue" method="POST">
+    <ft:form-template action="#{$cocoon/continuation/id}.continue" method="POST" ajax="true">
     
       <ft:class id="task-class">
         <div class="section">
@@ -90,20 +90,22 @@
       <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 id="tasks">
+          <jx:choose>
+            <jx:when test="${repeater.getSize() > 0}">
+              <ft:repeater-rows>
+                <!-- recurse -->
+                <ft:new id="task-class"/>
               
-            </ft:repeater-widget>
-          </jx:when>
-          <jx:otherwise>
+              </ft:repeater-rows>
+            </jx:when>
+            <jx:otherwise>
             <ft:widget id="addsub">
-	      <fi:styling type="link"/>
-	    </ft:widget>
+              <fi:styling type="link"/>
+            </ft:widget>
           </jx:otherwise>
         </jx:choose>
+        </ft:repeater>
       </ft:class>
       
       Project name: <ft:widget id="name"/>

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/resources/forms-advanced-field-styling.xsl
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/resources/forms-advanced-field-styling.xsl?rev=171291&r1=171290&r2=171291&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/resources/forms-advanced-field-styling.xsl
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/resources/forms-advanced-field-styling.xsl
Sun May 22 01:38:04 2005
@@ -90,7 +90,7 @@
     <xsl:variable name="id" select="@id"/>
     <xsl:variable name="values" select="fi:values/fi:value/text()"/>
 
-    <div class="forms-doubleList" title="{fi:hint}">
+    <div id="{@id}" class="forms-doubleList" title="{fi:hint}">
       <table>
         <xsl:if test="fi:styling/fi:available-label|fi:styling/fi:selected-label">
           <tr>

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/resources/forms-calendar-styling.xsl
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/resources/forms-calendar-styling.xsl?rev=171291&r1=171290&r2=171291&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/resources/forms-calendar-styling.xsl
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/resources/forms-calendar-styling.xsl
Sun May 22 01:38:04 2005
@@ -65,28 +65,30 @@
       </xsl:choose>
     </xsl:variable>
     
-    <!-- regular input -->
-    <input id="{@id}" name="{@id}" value="{fi:value}" title="{normalize-space(fi:hint)}"
type="text">
-      <xsl:apply-templates select="." mode="styling"/>
-    </input>
+    <span id="{@id}">
+      <!-- regular input -->
+      <input id="{@id}" name="{@id}" value="{fi:value}" title="{normalize-space(fi:hint)}"
type="text">
+        <xsl:apply-templates select="." mode="styling"/>
+      </input>
     
-    <!-- calendar popup -->
-    <xsl:choose>
-      <xsl:when test="@state = 'disabled'">
-        <!-- TODO: i18n key for @alt -->
-        <img src="{$resources-uri}/img/cal.gif" alt="Calendar"/>
-      </xsl:when>
-      <xsl:otherwise>
-        <a href="#" name="{$id}" id="{$id}"
-           onclick="forms_calendar.select(forms_getForm(this)['{@id}'],'{$id}','{$format}');
return false;">
+      <!-- calendar popup -->
+      <xsl:choose>
+        <xsl:when test="@state = 'disabled'">
           <!-- TODO: i18n key for @alt -->
           <img src="{$resources-uri}/img/cal.gif" alt="Calendar"/>
-        </a>
-      </xsl:otherwise>
-    </xsl:choose>
+        </xsl:when>
+        <xsl:otherwise>
+          <a href="#" name="{$id}" id="{$id}"
+             onclick="forms_calendar.select(forms_getForm(this)['{@id}'],'{$id}','{$format}');
return false;">
+            <!-- TODO: i18n key for @alt -->
+            <img src="{$resources-uri}/img/cal.gif" alt="Calendar"/>
+          </a>
+        </xsl:otherwise>
+      </xsl:choose>
 
-    <!-- common stuff -->
-    <xsl:apply-templates select="." mode="common"/>
+      <!-- common stuff -->
+      <xsl:apply-templates select="." mode="common"/>
+    </span>
   </xsl:template>
 
 </xsl:stylesheet>

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/resources/forms-field-styling.xsl
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/resources/forms-field-styling.xsl?rev=171291&r1=171290&r2=171291&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/resources/forms-field-styling.xsl
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/resources/forms-field-styling.xsl
Sun May 22 01:38:04 2005
@@ -30,6 +30,7 @@
 
   <xsl:template match="head" mode="forms-field">
     <script src="{$resources-uri}/js/forms-lib.js" type="text/javascript"/>
+    <script src="{$resources-uri}/js/cforms.js" type="text/javascript"/>
     <link rel="stylesheet" type="text/css" href="{$resources-uri}/css/forms.css"/>
   </xsl:template>
 
@@ -48,21 +49,24 @@
       | Generic fi:field : produce an <input>
       +-->
   <xsl:template match="fi:field">
-    <xsl:if test="fi:captcha-image">
-      <img src="captcha-{fi:captcha-image/@id}.jpg" style="vertical-align:middle"/>
-      <xsl:text> </xsl:text>
-    </xsl:if>
-    <input name="{@id}" id="{@id}" value="{fi:value}" title="{fi:hint}" type="text">
-      <xsl:apply-templates select="." mode="styling"/>
-    </input>
-    <xsl:apply-templates select="." mode="common"/>
+    <span id="{@id}">
+      <xsl:if test="fi:captcha-image">
+        <img src="captcha-{fi:captcha-image/@id}.jpg" style="vertical-align:middle"/>
+        <xsl:text> </xsl:text>
+      </xsl:if>
+      <!--  @id-input is what labels point to -->
+      <input name="{@id}" id="{@id}-input" value="{fi:value}" title="{fi:hint}" type="text">
+        <xsl:apply-templates select="." mode="styling"/>
+      </input>
+      <xsl:apply-templates select="." mode="common"/>
+    </span>
   </xsl:template>
 
   <!--+
       | Field in "output" state: display its value
       +-->
   <xsl:template match="fi:field[@state='output']" priority="3">
-    <xsl:value-of select="fi:value/node()"/>
+    <span id="{@id}"><xsl:value-of select="fi:value/node()"/></span>
   </xsl:template>
 
   <!--+
@@ -164,7 +168,7 @@
     <xsl:variable name="vertical" select="string(fi:styling/@list-orientation) != 'horizontal'"/>
     <xsl:choose>
       <xsl:when test="$vertical">
-        <table cellpadding="0" cellspacing="0" border="0" title="{fi:hint}">
+        <table id="{$id}" cellpadding="0" cellspacing="0" border="0" title="{fi:hint}">
           <xsl:for-each select="fi:selection-list/fi:item">
             <tr>
               <td>
@@ -190,7 +194,7 @@
         </table>
       </xsl:when>
       <xsl:otherwise>
-        <span title="{fi:hint}">
+        <span id="{$id}" title="{fi:hint}">
           <xsl:for-each select="fi:selection-list/fi:item">
             <input type="radio" id="{generate-id()}" name="{$id}" value="{@value}">
               <xsl:if test="@value = $value">
@@ -202,8 +206,8 @@
               <xsl:with-param name="id" select="generate-id()"/>
             </xsl:apply-templates>
           </xsl:for-each>
+          <xsl:apply-templates select="." mode="common"/>
         </span>
-        <xsl:apply-templates select="." mode="common"/>
       </xsl:otherwise>
     </xsl:choose>
   </xsl:template>
@@ -219,18 +223,20 @@
     <xsl:variable name="value" select="fi:value"/>
 
     <!-- dropdown or listbox -->
-    <select title="{fi:hint}" id="{@id}" name="{@id}">
-      <xsl:apply-templates select="." mode="styling"/>
-      <xsl:for-each select="fi:selection-list/fi:item">
-        <option value="{@value}">
-          <xsl:if test="@value = $value">
-            <xsl:attribute name="selected">selected</xsl:attribute>
-          </xsl:if>
-          <xsl:copy-of select="fi:label/node()"/>
-        </option>
-      </xsl:for-each>
-    </select>
-    <xsl:apply-templates select="." mode="common"/>
+    <span id="{@id}">
+      <select title="{fi:hint}" id="{@id}-input" name="{@id}">
+        <xsl:apply-templates select="." mode="styling"/>
+        <xsl:for-each select="fi:selection-list/fi:item">
+          <option value="{@value}">
+            <xsl:if test="@value = $value">
+              <xsl:attribute name="selected">selected</xsl:attribute>
+            </xsl:if>
+            <xsl:copy-of select="fi:label/node()"/>
+          </option>
+        </xsl:for-each>
+      </select>
+      <xsl:apply-templates select="." mode="common"/>
+    </span>
   </xsl:template>
 
   <!--+
@@ -239,33 +245,37 @@
   <xsl:template match="fi:field[fi:selection-list][fi:styling/@type='output']" priority="3">
     <xsl:variable name="value" select="fi:value"/>
     <xsl:variable name="selected" select="fi:selection-list/fi:item[@value = $value]"/>
-    <xsl:choose>
-      <xsl:when test="$selected/fi:label">
-        <xsl:copy-of select="$selected/fi:label/node()"/>
-      </xsl:when>
-      <xsl:otherwise>
-        <xsl:value-of select="$value"/>
-      </xsl:otherwise>
-    </xsl:choose>
+    <span id="{@id}">
+      <xsl:choose>
+        <xsl:when test="$selected/fi:label">
+          <xsl:copy-of select="$selected/fi:label/node()"/>
+        </xsl:when>
+        <xsl:otherwise>
+          <xsl:value-of select="$value"/>
+        </xsl:otherwise>
+      </xsl:choose>
+    </span>
   </xsl:template>
 
   <!--+
       | fi:field with @type 'textarea'
       +-->
   <xsl:template match="fi:field[fi:styling/@type='textarea']">
-    <textarea id="{@id}" name="{@id}" title="{fi:hint}">
-      <xsl:apply-templates select="." mode="styling"/>
-      <!-- remove carriage-returns (occurs on certain versions of IE and doubles linebreaks
at each submit) -->
-      <xsl:copy-of select="translate(fi:value/node(), '&#13;', '')"/>
-    </textarea>
-    <xsl:apply-templates select="." mode="common"/>
+    <span id="{@id}">
+      <textarea id="{@id}-input" name="{@id}" title="{fi:hint}">
+        <xsl:apply-templates select="." mode="styling"/>
+        <!-- remove carriage-returns (occurs on certain versions of IE and doubles linebreaks
at each submit) -->
+        <xsl:copy-of select="translate(fi:value/node(), '&#13;', '')"/>
+      </textarea>
+      <xsl:apply-templates select="." mode="common"/>
+    </span>
   </xsl:template>
 
   <!--+
       | fi:field with @type 'output' and fi:output are both rendered as text
       +-->
   <xsl:template match="fi:output | fi:field[fi:styling/@type='output']" priority="2">
-    <xsl:copy-of select="fi:value/node()"/>
+    <span id="{@id}"><xsl:copy-of select="fi:value/node()"/></span>
   </xsl:template>
 
   <!--+
@@ -273,7 +283,7 @@
       +-->
   <xsl:template match="fi:*" mode="label">
     <xsl:param name="id" select="@id"/>
-    <label for="{$id}" title="{fi:hint}">
+    <label for="{$id}-input" title="{fi:hint}">
       <xsl:copy-of select="fi:label/node()"/>
     </label>
   </xsl:template>
@@ -291,22 +301,24 @@
       | the value and not the checked attribute
       +-->
   <xsl:template match="fi:booleanfield">
-    <input id="{@id}" type="checkbox" value="true" name="{@id}" title="{fi:hint}">
-      <xsl:apply-templates select="." mode="styling"/>
-      <xsl:choose>
-        <xsl:when test="./fi:styling[@type='hidden']">
-          <xsl:if test="fi:value = 'false'">
-            <xsl:attribute name="value">false</xsl:attribute>
-          </xsl:if>
-        </xsl:when>
-        <xsl:otherwise>
-          <xsl:if test="fi:value = 'true'">
-            <xsl:attribute name="checked">checked</xsl:attribute>
-          </xsl:if>
-        </xsl:otherwise>
-      </xsl:choose>
-    </input>
-    <xsl:apply-templates select="." mode="common"/>
+    <span id="{@id}">
+      <input id="{@id}-input" type="checkbox" value="true" name="{@id}" title="{fi:hint}">
+        <xsl:apply-templates select="." mode="styling"/>
+        <xsl:choose>
+          <xsl:when test="./fi:styling[@type='hidden']">
+            <xsl:if test="fi:value = 'false'">
+              <xsl:attribute name="value">false</xsl:attribute>
+            </xsl:if>
+          </xsl:when>
+          <xsl:otherwise>
+            <xsl:if test="fi:value = 'true'">
+              <xsl:attribute name="checked">checked</xsl:attribute>
+            </xsl:if>
+          </xsl:otherwise>
+        </xsl:choose>
+      </input>
+      <xsl:apply-templates select="." mode="common"/>
+    </span>
   </xsl:template>
 
   <!--+
@@ -314,7 +326,7 @@
       | use text but avoids i18n problems related to hardcoding 'yes'/'no' or 'true'/'false'
       +-->
   <xsl:template match="fi:booleanfield[@state='output' or fi:styling/@type='output']"
priority="3">
-    <input type="checkbox" title="{fi:hint}" disabled="disabled">
+    <input id="{@id}" type="checkbox" title="{fi:hint}" disabled="disabled">
     	  <xsl:if test="fi:value = 'true'">
     	    <xsl:attribute name="checked">checked</xsl:attribute>
     	  </xsl:if>
@@ -325,7 +337,7 @@
       | fi:action
       +-->
   <xsl:template match="fi:action">
-    <input id="{@id}" type="submit" name="{@id}" title="{fi:hint}">
+    <input id="{@id}" type="submit" name="{@id}" title="{fi:hint}" onclick="forms_submitForm(this,
'{@id}'); return false">
       <xsl:attribute name="value"><xsl:value-of select="fi:label/node()"/></xsl:attribute>
       <xsl:apply-templates select="." mode="styling"/>
     </input>
@@ -335,7 +347,7 @@
       | fi:action, link-style 	 
       +--> 	 
   <xsl:template match="fi:action[fi:styling/@type = 'link']" priority="1"> 	 
-    <a title="{fi:hint}" href="#" onclick="forms_submitForm(this, '{@id}'); return false">
	 
+    <a id="{@id}" title="{fi:hint}" href="#" onclick="forms_submitForm(this, '{@id}');
return false"> 	 
       <xsl:apply-templates select="." mode="styling"/> 	 
       <xsl:copy-of select="fi:label/node()"/> 	 
     </a>
@@ -361,7 +373,7 @@
     <xsl:variable name="id" select="@id"/>
     <xsl:variable name="values" select="fi:values/fi:value/text()"/>
 
-    <span title="{fi:hint}">
+    <span id="{@id}" title="{fi:hint}">
       <xsl:for-each select="fi:selection-list/fi:item">
         <xsl:variable name="value" select="@value"/>
         <input id="{generate-id()}" type="checkbox" value="{@value}" name="{$id}">
@@ -374,8 +386,8 @@
         </xsl:apply-templates>
         <br/>
       </xsl:for-each>
+      <xsl:apply-templates select="." mode="common"/>
     </span>
-    <xsl:apply-templates select="." mode="common"/>
   </xsl:template>
 
   <!--+
@@ -385,8 +397,8 @@
     <xsl:variable name="id" select="@id"/>
     <xsl:variable name="values" select="fi:values/fi:value/text()"/>
 
-    <span title="{fi:hint}">
-      <select id="{@id}" name="{$id}" multiple="multiple">
+    <span id="{@id}" title="{fi:hint}">
+      <select id="{@id}-input" name="{$id}" multiple="multiple">
         <xsl:apply-templates select="." mode="styling"/>
         <xsl:for-each select="fi:selection-list/fi:item">
           <xsl:variable name="value" select="@value"/>
@@ -398,8 +410,8 @@
           </option>
         </xsl:for-each>
       </select>
+      <xsl:apply-templates select="." mode="common"/>
     </span>
-    <xsl:apply-templates select="." mode="common"/>
   </xsl:template>
 
   <!--+
@@ -407,50 +419,52 @@
       +-->
   <xsl:template match="fi:multivaluefield[@state='output']" priority="3">
     <xsl:variable name="values" select="fi:values/fi:value/text()"/>
-    <xsl:for-each select="fi:selection-list/fi:item">
-      <xsl:variable name="value" select="@value"/>
-      <xsl:if test="$values[. = $value]">
-    	    <xsl:value-of select="fi:label/node()"/>
-    	  </xsl:if>
-    </xsl:for-each>
+    <span id="{@id}">
+      <xsl:for-each select="fi:selection-list/fi:item">
+        <xsl:variable name="value" select="@value"/>
+        <xsl:if test="$values[. = $value]">
+          <xsl:value-of select="fi:label/node()"/>
+    	    </xsl:if>
+      </xsl:for-each>
+    </span>
   </xsl:template>
 
   <!--+
       | fi:upload
       +-->
   <xsl:template match="fi:upload">
-    <xsl:choose>
-      <xsl:when test="fi:value">
-        <!-- Has a value (filename): display it with a change button -->
-        <span title="{fi:hint}">
-          <xsl:text>[</xsl:text>
-          <xsl:value-of select="fi:value"/>
-          <xsl:text>] </xsl:text>
-          <input type="button" id="{@id}" name="{@id}" value="..." onclick="forms_submitForm(this)"/>
-        </span>
-      </xsl:when>
-      <xsl:otherwise>
-        <input type="file" id="{@id}" name="{@id}" title="{fi:hint}" accept="{@mime-types}">
-          <xsl:apply-templates select="." mode="styling"/>
-        </input>
-      </xsl:otherwise>
-    </xsl:choose>
-    <xsl:apply-templates select="." mode="common"/>
+    <span id="{@id}" title="{fi:hint}">
+      <xsl:choose>
+        <xsl:when test="fi:value">
+          <!-- Has a value (filename): display it with a change button -->
+            <xsl:text>[</xsl:text>
+            <xsl:value-of select="fi:value"/>
+            <xsl:text>] </xsl:text>
+            <input type="button" id="{@id}-input" name="{@id}-input" value="..." onclick="forms_submitForm(this)"/>
+        </xsl:when>
+        <xsl:otherwise>
+          <input type="file" id="{@id}-input" name="{@id}" title="{fi:hint}" accept="{@mime-types}">
+            <xsl:apply-templates select="." mode="styling"/>
+          </input>
+        </xsl:otherwise>
+      </xsl:choose>
+      <xsl:apply-templates select="." mode="common"/>`
+    </span>
   </xsl:template>
 
   <!--+
       | fi:upload, output state
       +-->
   <xsl:template match="fi:upload[@state='output']" priority="3">
-      <xsl:copy-of select="fi:value/node()"/>
+      <span id="{@id}"><xsl:copy-of select="fi:value/node()"/></span>
   </xsl:template>
 
   <!--+
       | fi:repeater
       +-->
   <xsl:template match="fi:repeater">
-    <input type="hidden" name="{@id}.size" value="{@size}"/>
-    <table border="1">
+    <table id="{@id}" border="1">
+      <input type="hidden" name="{@id}.size" value="{@size}"/>
       <tr>
         <xsl:for-each select="fi:headings/fi:heading">
           <th><xsl:value-of select="."/></th>
@@ -489,6 +503,9 @@
       <xsl:attribute name="onsubmit">forms_onsubmit(); <xsl:value-of select="@onsubmit"/></xsl:attribute>
       <!-- hidden field to store the submit id -->
       <div><input type="hidden" name="forms_submit_id"/></div>
+      <xsl:if test="@ajax = 'true'">
+        <script script="text/javascript">CForms.ajax = true;</script>
+      </xsl:if>
       <xsl:apply-templates/>
       
       <!-- TODO: consider putting this in the xml stream from the generator? -->
@@ -534,62 +551,88 @@
   </xsl:template>
 
   <xsl:template match="fi:aggregatefield">
-    <input id="{@id}" name="{@id}" value="{fi:value}" title="{fi:hint}">
-      <xsl:apply-templates select="." mode="styling"/>
-    </input>
-    <xsl:apply-templates select="." mode="common"/>
+    <span id="{@id}">
+      <input id="{@id}-input" name="{@id}" value="{fi:value}" title="{fi:hint}">
+        <xsl:apply-templates select="." mode="styling"/>
+      </input>
+      <xsl:apply-templates select="." mode="common"/>
+    </span>
   </xsl:template>
 
   <xsl:template match="fi:messages">
-    <xsl:if test="fi:message">
-      <xsl:apply-templates select="." mode="label"/>:
-      <ul>
-        <xsl:for-each select="fi:message">
-          <li><xsl:apply-templates/></li>
-        </xsl:for-each>
-      </ul>
-    </xsl:if>
+    <div id="{@id}">
+      <xsl:if test="fi:message">
+        <xsl:apply-templates select="." mode="label"/>:
+        <ul>
+          <xsl:for-each select="fi:message">
+            <li><xsl:apply-templates/></li>
+          </xsl:for-each>
+        </ul>
+      </xsl:if>
+    </div>
   </xsl:template>
 
   <xsl:template match="fi:validation-errors">
-    <xsl:variable name="header">
-      <xsl:choose>
-        <xsl:when test="header">
-          <xsl:copy-of select="header"/>
-        </xsl:when>
-        <xsl:otherwise>
-          <p class="forms-validation-errors">The following errors have been detected
(marked with !):</p>
-        </xsl:otherwise>
-      </xsl:choose>
-    </xsl:variable>
-    <xsl:variable name="footer">
-      <xsl:choose>
-        <xsl:when test="footer">
-          <xsl:copy-of select="footer"/>
-        </xsl:when>
-        <xsl:otherwise>
-          <p class="forms-validation-errors">Please, correct them and re-submit the
form.</p>
-        </xsl:otherwise>
-      </xsl:choose>
-    </xsl:variable>
-    <xsl:variable name="messages" select="ancestor::fi:form-template//fi:validation-message"/>
-    <xsl:if test="$messages">
-      <xsl:copy-of select="$header"/>
-      <ul>
-        <xsl:for-each select="$messages">
-          <li class="forms-validation-error">
-            <xsl:variable name="label">
-              <xsl:apply-templates select=".." mode="label"/>
-            </xsl:variable>
-            <xsl:if test="$label">
-              <xsl:copy-of select="$label"/><xsl:text>: </xsl:text>
-            </xsl:if>
-            <xsl:value-of select="."/>
-          </li>
-        </xsl:for-each>
-      </ul>
-      <xsl:copy-of select="$footer"/>
-    </xsl:if>
+    <div id="{@id}">
+      <xsl:variable name="header">
+        <xsl:choose>
+          <xsl:when test="header">
+            <xsl:copy-of select="header"/>
+          </xsl:when>
+          <xsl:otherwise>
+            <p class="forms-validation-errors">The following errors have been detected
(marked with !):</p>
+          </xsl:otherwise>
+        </xsl:choose>
+      </xsl:variable>
+      <xsl:variable name="footer">
+        <xsl:choose>
+          <xsl:when test="footer">
+            <xsl:copy-of select="footer"/>
+          </xsl:when>
+          <xsl:otherwise>
+            <p class="forms-validation-errors">Please, correct them and re-submit the
form.</p>
+          </xsl:otherwise>
+        </xsl:choose>
+      </xsl:variable>
+      <xsl:variable name="messages" select="ancestor::fi:form-template//fi:validation-message"/>
+      <xsl:if test="$messages">
+        <xsl:copy-of select="$header"/>
+        <ul>
+          <xsl:for-each select="$messages">
+            <li class="forms-validation-error">
+              <xsl:variable name="label">
+                <xsl:apply-templates select=".." mode="label"/>
+              </xsl:variable>
+              <xsl:if test="$label">
+                <xsl:copy-of select="$label"/><xsl:text>: </xsl:text>
+              </xsl:if>
+              <xsl:value-of select="."/>
+            </li>
+          </xsl:for-each>
+        </ul>
+        <xsl:copy-of select="$footer"/>
+      </xsl:if>
+    </div>
+  </xsl:template>
+  
+  <xsl:template match="fi:union">
+    <div id="{@id}">
+      <xsl:apply-templates/>
+    </div>
+  </xsl:template>
+  
+  <xsl:template match="fi:repeater-template">
+    <div id="{@id}">
+      <xsl:apply-templates/>
+    </div>
+  </xsl:template>
+  
+  <!--+
+      | fi:placeholder - used to represent invisible widgets so that AJAX updates
+      | know where to insert the widget if it becomes visible
+      +-->
+  <xsl:template match="fi:placeholder">
+    <span id="{@id}"/>
   </xsl:template>
 
   <xsl:template match="@*|node()" priority="-1">

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/resources/forms-page-styling.xsl
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/resources/forms-page-styling.xsl?rev=171291&r1=171290&r2=171291&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/resources/forms-page-styling.xsl
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/resources/forms-page-styling.xsl
Sun May 22 01:38:04 2005
@@ -141,7 +141,7 @@
     <fieldset id="{$id}">
       <legend title="{fi:hint}">
         <xsl:apply-templates select="fi:label/node()"/>
-        <select name="{$state-widget}" onchange="forms_showTab('{$id}', this.selectedIndex,
{count(fi:items/*)}, '{$state-widget}')">
+        <select name="{$state-widget}" id="{$state-widget}" onchange="forms_showTab('{$id}',
this.selectedIndex, {count(fi:items/*)}, '{$state-widget}')">
           <xsl:for-each select="fi:items/fi:*">
             <xsl:variable name="pos" select="position() - 1"/>
             <option>

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/sitemap.xmap
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/sitemap.xmap?rev=171291&r1=171290&r2=171291&view=diff
==============================================================================
--- 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 Sun May 22 01:38:04
2005
@@ -20,6 +20,7 @@
  <map:components>
 
   <map:transformers default="xslt">    
+    <map:transformer name="browser-update" src="org.apache.cocoon.transformation.BrowserUpdateTransformer"/>
     <map:transformer name="i18n" src="org.apache.cocoon.transformation.I18nTransformer">
       <catalogues default="other">
         <catalogue id="other" name="OtherMessages" location="messages"/>
@@ -127,20 +128,23 @@
        </map:select>
 
        <!-- pipeline to show the form -->
-       <map:generate src="forms/form1_template_action.xml"/>
+       <map:generate src="forms/form1_template_action.xml">
+	     <map:parameter name="attribute-name" value="form1"/>       	
+       </map:generate>
+
        <map:transform type="forms" label="content1">
          <map:parameter name="attribute-name" value="form1"/>
        </map:transform>
+       
        <map:transform type="i18n">
-         <!--map:parameter name="locale" value="en-US"/-->
        </map:transform>
        <map:call resource="simple-page2html">
          <map:parameter name="file" value="forms/form1_success.xsp"/>
        </map:call>
        <map:transform type="i18n">
-         <!--map:parameter name="locale" value="en-US"/-->
        </map:transform>
        <map:transform src="resources/forms-samples-styling.xsl"/>
+
        <map:serialize/>
      </map:match>
         
@@ -191,6 +195,7 @@
         -->
      <map:match pattern="*-display-pipeline.jx">
        <map:generate type="jx" src="forms/{1}_template.xml" label="content1"/>
+       <map:transform type="browser-update"/>
        <map:transform type="i18n">
          <!--map:parameter name="locale" value="en-US"/-->
        </map:transform>
@@ -198,7 +203,15 @@
          <map:parameter name="file" value="forms/{1}_template.xml"/>
        </map:call>
        <map:transform src="resources/forms-samples-styling.xsl"/>
-       <map:serialize/>
+       <map:select type="request-parameter">
+         <map:parameter name="parameter-name" value="cocoon-ajax"/>
+         <map:when test="true">
+	   <map:serialize type="xml"/>
+	 </map:when>
+	 <map:otherwise>
+           <map:serialize type="html"/>
+	 </map:otherwise>
+       </map:select>
      </map:match>
 
      <!--

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/welcome.xml
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/welcome.xml?rev=171291&r1=171290&r2=171291&view=diff
==============================================================================
--- 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 Sun May 22 01:38:04
2005
@@ -30,14 +30,18 @@
   <sample name="Cocoon Forms Documentation" href="http://cocoon.apache.org/2.1/userdocs/forms/">
     Documentation is available on the Cocoon site.
   </sample>
+  <note>
+     Samples with the (Ajax) mark use the new transparent Ajax (Asynchronous Javascript And
XML) framework
+     to reduce client/server roundtrips and perform partial page updates.
+  </note>
  </group>
 
  <group name="Basic Samples">
   <sample name="Various (Actions)" href="form1">This sample shows validation, event
handling and various Cocoon Forms features.</sample>
   <sample name="Various (Flowscript)" href="form1.flow">The same sample as above using
Flowscript.</sample>
   <sample name="Registration" href="registration">A simple registration form.</sample>
-  <sample name="Car selector" href="carselector">Illustrates programmatically changing
selectionlists.</sample>
-  <sample name="XHR Car selector" href="xhr_carselector">Same sample, using XmlHttpRequest
to reduce client/server roundtrips.</sample>
+  <sample name="Car selector" href="carselector">(Ajax) Illustrates programmatically
changing selectionlists.</sample>
+  <sample name="XHR Car selector" href="xhr_carselector">Same sample, with the historical
first use of XmlHttpRequest to reduce client/server roundtrips.</sample>
   <sample name="Country selector" href="countryselector">Illustrates programmatically
changing flow-jxpath selectionlists.</sample>
   <sample name="Upload" href="upload">Shows an upload widget used with Flowscript</sample>
   <sample name="Form Model GUI" href="form_model_gui.flow">Illustrates the use of Class,
New, Struct, and Union.</sample>
@@ -89,14 +93,14 @@
      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
+     (Ajax) 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.
+     (Ajax) 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
+     (Ajax) A project work breakdown into a hierarchy of tasks, showing the use of the fd:class
and fd:new
      widgets.
    </sample>
  </group>
@@ -106,7 +110,7 @@
       Create your Euro 2004 soccer dream team
     </sample>
  </group>
- 
+
   <group name="Profiling information">
     <note>
       These samples concentrate on Cocoon Forms and JXTemplate in order to collect profiling
information.
@@ -114,7 +118,7 @@
     </note>
     <sample name="form1 - JXTemplate" href="form1-jx-macro">Render form using JXTemplate
macros</sample>
     <sample name="form1 - FormsTransformer" href="form1-cforms-transformer">Render
form using the FormsTransformer</sample>    
-  </group>  
+  </group> 
  
  <group name="Experimental Flowscript API for Cocoon Forms">
   <note>

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/forms/test/org/apache/cocoon/forms/datatype/convertor/EnumConvertorBuilderTestCase.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/forms/test/org/apache/cocoon/forms/datatype/convertor/EnumConvertorBuilderTestCase.java?rev=171291&r1=171290&r2=171291&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/forms/test/org/apache/cocoon/forms/datatype/convertor/EnumConvertorBuilderTestCase.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/forms/test/org/apache/cocoon/forms/datatype/convertor/EnumConvertorBuilderTestCase.java
Sun May 22 01:38:04 2005
@@ -45,7 +45,6 @@
         parser = factory.newDocumentBuilder();
     }
 
-
     public EnumConvertorBuilderTestCase(String name) {
         super(name);
     }

Added: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/transformation/BrowserUpdateTransformer.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/transformation/BrowserUpdateTransformer.java?rev=171291&view=auto
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/transformation/BrowserUpdateTransformer.java
(added)
+++ cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/transformation/BrowserUpdateTransformer.java
Sun May 22 01:38:04 2005
@@ -0,0 +1,108 @@
+package org.apache.cocoon.transformation;
+
+import java.io.IOException;
+import java.util.Map;
+
+import org.apache.avalon.framework.parameters.Parameters;
+import org.apache.cocoon.ProcessingException;
+import org.apache.cocoon.environment.ObjectModelHelper;
+import org.apache.cocoon.environment.Request;
+import org.apache.cocoon.environment.SourceResolver;
+import org.apache.cocoon.xml.AttributesImpl;
+import org.apache.cocoon.xml.RedundantNamespacesFilter;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+
+public class BrowserUpdateTransformer extends AbstractTransformer {
+    
+    public static final String AJAXMODE_PARAM = "cocoon-ajax";
+    
+    public static final String BU_NSURI = "http://apache.org/cocoon/browser-update/1.0";
+    
+    private boolean ajaxMode = false;
+    
+    private int replaceDepth = 0;
+
+    public void setup(SourceResolver resolver, Map objectModel, String src, Parameters par)
throws ProcessingException, SAXException, IOException {
+
+        Request request = ObjectModelHelper.getRequest(objectModel);
+        this.ajaxMode = request.getParameter(AJAXMODE_PARAM) != null;
+    }
+
+    public void startDocument() throws SAXException {
+        
+        if (ajaxMode) {
+            // Add the namespace filter to our own output.
+            // This is needed as flattening bu:* elements can lead to some weird reordering
of
+            // namespace declarations...
+            RedundantNamespacesFilter nsPipe = new RedundantNamespacesFilter();
+            if (this.xmlConsumer != null) {
+                nsPipe.setConsumer(this.xmlConsumer);
+            } else {
+                nsPipe.setContentHandler(this.contentHandler);
+            }
+            setConsumer(nsPipe);
+        }
+        
+        super.startDocument();
+        if (ajaxMode) {
+            // Add a root element. The original one is very likely to be stripped
+            super.startPrefixMapping("bu", BU_NSURI);
+            super.startElement(BU_NSURI, "document", "bu:document", new AttributesImpl());
+        }
+    }
+    
+    public void startPrefixMapping(String prefix, String uri) throws SAXException {
+        // always let them trough
+        super.startPrefixMapping(prefix, uri);
+    }
+
+    public void startElement(String uri, String loc, String raw, Attributes a) throws SAXException
{
+        if (BU_NSURI.equals(uri) && "replace".equals(loc)) {
+            if (this.ajaxMode && this.replaceDepth == 0) {
+                // Pass this element through
+                super.startElement(uri, loc, raw, a);
+            }
+            replaceDepth++;
+        } else {
+            // Passthrough if not in ajax mode or if in a bu:replace
+            if (!this.ajaxMode || this.replaceDepth > 0) {
+                super.startElement(uri, loc, raw, a);
+            }
+        }
+    }
+
+    public void characters(char[] buffer, int offset, int len) throws SAXException {
+        if (!this.ajaxMode || this.replaceDepth > 0) {
+            super.characters(buffer, offset, len);
+        }
+    }
+    
+    public void endElement(String uri, String loc, String raw) throws SAXException {
+        if (BU_NSURI.equals(uri) && "replace".equals(loc)) {
+            replaceDepth--;
+            if (this.ajaxMode && this.replaceDepth == 0) {
+                // Pass this element through
+                super.endElement(uri, loc, raw);
+            }
+        } else {
+            // Passthrough if not in ajax mode or if in a bu:replace
+            if (!this.ajaxMode || this.replaceDepth > 0) {
+                super.endElement(uri, loc, raw);
+            }
+        }
+    }
+
+    public void endPrefixMapping(String prefix) throws SAXException {
+        // always let them trough
+        super.endPrefixMapping(prefix);
+    }
+
+    public void endDocument() throws SAXException {
+        if (ajaxMode) {
+            super.endElement(BU_NSURI, "document", "bu:document");
+            super.endPrefixMapping("bu");
+        }
+        super.endDocument();
+    }
+}

Propchange: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/transformation/BrowserUpdateTransformer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/transformation/BrowserUpdateTransformer.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: cocoon/branches/BRANCH_2_1_X/status.xml
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/status.xml?rev=171291&r1=171290&r2=171291&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/status.xml (original)
+++ cocoon/branches/BRANCH_2_1_X/status.xml Sun May 22 01:38:04 2005
@@ -196,6 +196,11 @@
 
   <changes>
   <release version="@version@" date="@date@">
+    <action dev="SW" type="add">
+      CForms block: add automatic AJAX features. When <code>&lt;ft:form-template&gt;</code>
+      has an <code>ajax="true"</code> attribute, partial page updates are performed
rather
+      than full page reloads.
+    </action>
     <action dev="AG" type="fix" fixes-bug="32728" due-to="Thomas Scheithauer" due-to-email="cocoon-t3@gmx.de">
       SearchGenerator return has-previous false when meet the no. 2 page.
     </action>
@@ -209,7 +214,7 @@
       with spurious compilation errors or undefined runtime behaviour.
     </action>
     <action dev="UC" type="add">
-      Added CAPTCHA validator to Forms.
+      CForms block: added CAPTCHA validator.
     </action>
     <action dev="VG" type="add">
       IncludeTransformer moved from the scratchpad into the core. It has following



Mime
View raw message