cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joerg Heinicke <joerg.heini...@gmx.de>
Subject Re: submit-on-change ---------double-box(woody-advanced-field-styling)------------multivalue field
Date Tue, 11 May 2004 22:43:09 GMT
On 10.05.2004 08:56, Christina wrote:

> intuitively, I think "submit-on-change" is invoked when  some value
> is changed. In the "double box" case, that means an item is
> transfered between left and right column but in fact, in double-box,
>  It is invoked every time you single click one item in the right
> column, and every time there is an error:
> 
> java.lang.IllegalArgumentException: Invalid submit id (no such
> widget): multivaluefieldname.unselected
> 
> because the woody-advanced-field-styling simply add the "unselected"
> to the widget name, and clearly it is not defined.
> 
> I tried to delect the <xsl:apply-templates select="."
> mode="styling"/> for the left column of double-box, or add an
> "onchange" attribute for the right colomn in
> woody-advanced-field-styling, but it doesn't work.
> 
> Would anybody give me some idea how to fix this?

Nice bug, but it's obvious. There are two multiple selection lists and
onchange on a selection lists means a value is selected, not an option
is added or removed. I had a short look on it and have an idea how to
fix it:

Adding the following template to woody/forms-advanced-styling

<xsl:template
match="wi:multivaluefield/wi:styling[@list-type='double-listbox']/@submit-on-change"
mode="styling"/>

switches off the submit-on-change on the selection lists directly. Now
we need to add this on other places: after every occurence of
transfer(All)(Left|Right)().

I have extended woody's/cforms' js adapter to the original option
transfer js, so that it handles exactly this. The patch below works for
me here. It will be included in 2.1.5.

This does *not* test if the values have really changed (e.g. clicking on
< or > without having selected an element).

Joerg


Patch:

Index: woody-advanced-field-styling.xsl
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/blocks/woody/samples/resources/woody-advanced-field-styling.xsl,v
retrieving revision 1.12
diff -u -r1.12 woody-advanced-field-styling.xsl
--- woody-advanced-field-styling.xsl	22 Mar 2004 13:16:37 -0000	1.12
+++ woody-advanced-field-styling.xsl	11 May 2004 22:32:58 -0000
@@ -103,7 +103,7 @@
           <td>
             <!-- select for the unselected values -->
             <select id="{@id}.unselected" name="{@id}.unselected"
multiple="multiple"
-                    ondblclick="opt{generate-id()}.transferRight()">
+                    ondblclick="opt{generate-id()}.woody_transferRight()">
               <xsl:apply-templates select="." mode="styling"/>
               <xsl:for-each select="wi:selection-list/wi:item">
                 <xsl:variable name="value" select="@value"/>
@@ -119,19 +119,19 @@
             <!-- command buttons -->
             <!-- strangely, IE adds an extra blank line if there only a
button on a line. So we surround it with nbsp -->
             <xsl:text>&#160;</xsl:text>
-            <input type="button" value="&gt;"
onclick="opt{generate-id()}.transferRight()"/>
+            <input type="button" value="&gt;"
onclick="opt{generate-id()}.woody_transferRight()"/>
             <xsl:text>&#160;</xsl:text>
             <br/>
             <xsl:text>&#160;</xsl:text>
-            <input type="button" value="&gt;&gt;"
onclick="opt{generate-id()}.transferAllRight()"/>
+            <input type="button" value="&gt;&gt;"
onclick="opt{generate-id()}.woody_transferAllRight()"/>
             <xsl:text>&#160;</xsl:text>
             <br/>
             <xsl:text>&#160;</xsl:text>
-            <input type="button" value="&lt;"
onclick="opt{generate-id()}.transferLeft()"/>
+            <input type="button" value="&lt;"
onclick="opt{generate-id()}.woody_transferLeft()"/>
             <xsl:text>&#160;</xsl:text>
             <br/>
             <xsl:text>&#160;</xsl:text>
-            <input type="button" value="&lt;&lt;"
onclick="opt{generate-id()}.transferAllLeft()"/>
+            <input type="button" value="&lt;&lt;"
onclick="opt{generate-id()}.woody_transferAllLeft()"/>
             <xsl:text>&#160;</xsl:text>
             <br/>
             <xsl:apply-templates select="." mode="common"/>
@@ -139,7 +139,7 @@
           <td>
             <!-- select for the selected values -->
             <select id="{@id}" name="{@id}" multiple="multiple"
-                    ondblclick="opt{generate-id()}.transferLeft()" >
+                    ondblclick="opt{generate-id()}.woody_transferLeft()" >
               <xsl:apply-templates select="." mode="styling"/>
               <xsl:for-each select="wi:selection-list/wi:item">
                 <xsl:variable name="value" select="@value"/>
@@ -154,9 +154,11 @@
         </tr>
       </table>
       <script type="text/javascript">
-        var opt<xsl:value-of select="generate-id()"/> =
woody_createOptionTransfer('<xsl:value-of select="@id"/>');
+        var opt<xsl:value-of select="generate-id()"/> =
woody_createOptionTransfer('<xsl:value-of select="@id"/>', <xsl:value-of
select="wi:styling/@submit-on-change = 'true'"/>);
       </script>
     </span>
   </xsl:template>
+
+  <xsl:template
match="wi:multivaluefield/wi:styling[@list-type='double-listbox']/@submit-on-change"
mode="styling"/>

 </xsl:stylesheet>
Index: woody-lib.js
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/blocks/woody/samples/resources/woody-lib.js,v
retrieving revision 1.6
diff -u -r1.6 woody-lib.js
--- woody-lib.js	11 May 2004 22:22:32 -0000	1.6
+++ woody-lib.js	11 May 2004 22:32:58 -0000
@@ -17,7 +17,7 @@
  * Runtime JavaScript library for Woody.
  *
  * @author <a href="http://www.apache.org/~sylvain/">Sylvain Wallez</a>
- * @version CVS $Id: woody-lib.js,v 1.6 2004/05/11 22:22:32 joerg Exp $
+ * @version CVS $Id: woody-lib.js,v 1.3 2004/03/06 02:25:35 antonio Exp $
  */

 // Handlers that are to be called in the document's "onload" event
@@ -109,7 +109,7 @@
 }


-function woody_createOptionTransfer(id) {
+function woody_createOptionTransfer(id, submitOnChange) {
     var result = new OptionTransfer(id + ".unselected", id);
     result.setAutoSort(true);
     // add to onload handlers
@@ -120,6 +120,31 @@
         sortSelect(this.left);
         sortSelect(this.right);
     }
+    result.submitOnChange = submitOnChange;
+    result.woody_transferLeft = function() {
+        this.transferLeft();
+        if (this.submitOnChange) {
+            woody_submitForm(document.getElementById(this.woody_id));
+        }
+    }
+    result.woody_transferRight = function() {
+        this.transferRight();
+        if (this.submitOnChange) {
+            woody_submitForm(document.getElementById(this.woody_id));
+        }
+    }
+    result.woody_transferAllLeft = function() {
+        this.transferAllLeft();
+        if (this.submitOnChange) {
+            woody_submitForm(document.getElementById(this.woody_id));
+        }
+    };
+    result.woody_transferAllRight = function() {
+        this.transferAllRight();
+        if (this.submitOnChange) {
+            woody_submitForm(document.getElementById(this.woody_id));
+        }
+    };
     woody_onloadHandlers.push(result);

     // add to onsubmit handlers

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message