You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by an...@apache.org on 2008/07/11 00:36:42 UTC

svn commit: r675789 - in /cocoon/branches/BRANCH_2_1_X: ./ src/blocks/forms/resources/org/apache/cocoon/forms/resources/ src/blocks/forms/resources/org/apache/cocoon/forms/resources/js/ src/blocks/forms/resources/org/apache/cocoon/forms/resources/js/te...

Author: antonio
Date: Thu Jul 10 15:36:41 2008
New Revision: 675789

URL: http://svn.apache.org/viewvc?rev=675789&view=rev
Log:

<action dev="AG" type="fix" fixes-bug="COCOON-1822" due-to="Karen Torres &amp; Rafael Márquez" due-to-email="ktorres@agssa.net &amp; rmarquez@agssa.net">
  Forms: MultiValueField list-type="double-listbox" does not work correctly in ajax enabled forms.
</action>

Added:
    cocoon/branches/BRANCH_2_1_X/src/blocks/forms/resources/org/apache/cocoon/forms/resources/js/MultiValueDoubleList.js   (with props)
    cocoon/branches/BRANCH_2_1_X/src/blocks/forms/resources/org/apache/cocoon/forms/resources/js/templates/MultiValueDoubleList.html   (with props)
    cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/forms/multiValueDoubleList.xml   (with props)
    cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/forms/multiValueDoubleList_template.xml   (with props)
Modified:
    cocoon/branches/BRANCH_2_1_X/src/blocks/forms/resources/org/apache/cocoon/forms/resources/forms-advanced-field-styling.xsl
    cocoon/branches/BRANCH_2_1_X/src/blocks/forms/resources/org/apache/cocoon/forms/resources/js/__package__.js
    cocoon/branches/BRANCH_2_1_X/src/blocks/forms/resources/org/apache/cocoon/forms/resources/manifest.js
    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/forms/widgetstates.xml
    cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/forms/widgetstates_template.xml
    cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/welcome.xml
    cocoon/branches/BRANCH_2_1_X/status.xml

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/forms/resources/org/apache/cocoon/forms/resources/forms-advanced-field-styling.xsl
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/src/blocks/forms/resources/org/apache/cocoon/forms/resources/forms-advanced-field-styling.xsl?rev=675789&r1=675788&r2=675789&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/forms/resources/org/apache/cocoon/forms/resources/forms-advanced-field-styling.xsl (original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/forms/resources/org/apache/cocoon/forms/resources/forms-advanced-field-styling.xsl Thu Jul 10 15:36:41 2008
@@ -171,6 +171,69 @@
   <xsl:template match="fi:multivaluefield/fi:styling[@list-type='double-listbox']/@submit-on-change" mode="styling"/>
 
   <!--+
+      | fi:multivaluefield with list-type='dojo-double-listbox' styling
+      +-->
+  <xsl:template
+      match="fi:multivaluefield[fi:styling/@list-type='dojo-double-listbox']">
+      <xsl:variable name="id" select="@id"/>
+      <xsl:variable name="values" select="fi:values/fi:value/text()"/>
+      <div id="{@id}" class="forms-doubleList forms doubleList"
+          title="{fi:hint}">
+          <table>
+              <tr>
+                  <td>
+                      <div dojoType="forms:MultiValueDoubleList" styleClass="multivalue-widget" id="{$id}:widget" cformsIdPrefix="{$id}"
+                          availableListLabel="{fi:styling/fi:available-label}" selectedListLabel="{fi:styling/fi:selected-label}"
+                          size="{fi:styling/@size}">
+                          <!-- Data is supplied to the widget using this table-->
+                          <table>
+                              <tbody>
+                                  <!-- select for the available values-->
+                                  <xsl:for-each select="fi:selection-list/fi:item">
+                                      <xsl:variable name="value" select="@value"/>
+                                      <xsl:if test="not($values[. = $value])">
+                                          <tr>
+                                              <td>
+                                                  <xsl:value-of select="$value"/>
+                                              </td>
+                                              <td>
+                                                  <xsl:copy-of select="fi:label/node()"/>
+                                              </td>
+                                          </tr>
+                                      </xsl:if>
+                                  </xsl:for-each>
+                              </tbody>
+                          </table>
+                          <table>
+                              <tbody>
+                                  <!-- select for the selected values -->
+                                  <xsl:for-each select="fi:selection-list/fi:item">
+                                      <xsl:variable name="value" select="@value"/>
+                                      <xsl:if test="$values[. = $value]">
+                                          <tr>
+                                              <td>
+                                                  <xsl:value-of select="$value"/>
+                                              </td>
+                                              <td>
+                                                  <xsl:copy-of select="fi:label/node()"/>
+                                              </td>
+                                          </tr>
+                                      </xsl:if>
+                                  </xsl:for-each>
+                              </tbody>
+                          </table>
+                      </div>
+                  </td>
+                  <td>
+                      <xsl:apply-templates select="." mode="common"/>
+                  </td>
+              </tr>
+          </table>
+      </div>
+      <xsl:apply-templates select="." mode="label-ajax-request"/>
+  </xsl:template>
+
+  <!--+
       | fi:multivaluefield without a selection list
       +-->
   <xsl:template match="fi:multivaluefield[not(fi:selection-list)]">
@@ -210,7 +273,7 @@
     <!-- <xsl:variable name="values" select="fi:values/fi:value/text()"/>
     <xsl:variable name="popupUri" select="fi:styling/@popup-uri"/>
     <xsl:variable name="popupLinkText" select="fi:styling/@popup-link-text"/>
-    <xsl:variable name="dataUrl" select="fi:styling/@dataUrl"/> 
+    <xsl:variable name="dataUrl" select="fi:styling/@dataUrl"/>
     <xsl:variable name="popupSize" select="fi:styling/@popup-size"/>-->
 
     <div id="{@id}" dojoType="forms:MultiValueEditorWithSuggestion" styleClass="multivalue-widget" dataUrl="{fi:styling/@dataUrl}"

Added: cocoon/branches/BRANCH_2_1_X/src/blocks/forms/resources/org/apache/cocoon/forms/resources/js/MultiValueDoubleList.js
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/src/blocks/forms/resources/org/apache/cocoon/forms/resources/js/MultiValueDoubleList.js?rev=675789&view=auto
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/forms/resources/org/apache/cocoon/forms/resources/js/MultiValueDoubleList.js (added)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/forms/resources/org/apache/cocoon/forms/resources/js/MultiValueDoubleList.js Thu Jul 10 15:36:41 2008
@@ -0,0 +1,349 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+dojo.require("dojo.widget.HtmlWidget");
+dojo.provide("cocoon.forms.MultiValueDoubleList");
+
+/**
+ * A free-entry multivalue field editor style double list.
+ *
+ * Some functionality that's not visible at first sight:
+ *  - items can be moved around using ctrl+up and ctrl+down.
+ *  - an item can be replaced/updated by pressing ctrl+enter in the input box
+ */
+dojo.widget.defineWidget(
+    // widget name and class
+    "cocoon.forms.MultiValueDoubleList",
+
+    // superclass
+    dojo.widget.HtmlWidget,
+
+    function() {
+    },
+    // properties and methods
+   {
+        isContainer: false,
+
+        cformsIdPrefix: "id-prefix-not-set",
+        resourcesUri: cocoon.resourcesUri,
+        templatePath: cocoon.resourcesUri + "/forms/js/templates/MultiValueDoubleList.html",
+
+        availableListLabel : "Available",
+        selectedListLabel : "Selected",
+        size: "5",
+        styleClass : "",
+
+        fillInTemplate: function(args, frag) {
+            cocoon.forms.MultiValueDoubleList.superclass.fillInTemplate(this, args, frag);
+            // Available list options.
+            this.selectLeft.addOption = function(value, text) {
+                var alreadyInList = false;
+                for (var i = 0; this.options.length > i && !alreadyInList; i++) {
+                    if (this.options[i].value == value) {
+                        alreadyInList = true;
+                    }
+                }
+
+                if (!alreadyInList) {
+                    this.options[this.options.length] = new Option(text, value);
+                }
+            }
+            // Selected list options.
+            this.selectRight.addOption = function(value, text) {
+                var alreadyInList = false;
+                for (var i = 0; this.options.length > i && !alreadyInList; i++) {
+                    if (this.options[i].value == value) {
+                        alreadyInList = true;
+                    }
+                }
+
+                if (!alreadyInList) {
+                    this.options[this.options.length] = new Option(text, value);
+                }
+            }
+
+            dojo.event.connect(this.selectRight, "ondblclick", this, "_transferLeft");
+            dojo.event.connect(this.transferRight, "onclick", this, "_transferRight");
+            dojo.event.connect(this.selectLeft, "ondblclick", this, "_transferRight");
+            dojo.event.connect(this.transferAllRight, "onclick", this, "_transferAllRight");
+            dojo.event.connect(this.transferLeft, "onclick", this, "_transferLeft");
+            dojo.event.connect(this.transferAllLeft, "onclick", this, "_transferAllLeft");
+
+            dojo.event.connect(this, "addedTo", this, "_addOnSubmitHandler");
+            this._readData(this.getFragNodeRef(frag));
+
+        },
+
+        _addOnSubmitHandler: function(parent) {
+            var form = this._getForm(this);
+            if (form != null) {
+                dojo.event.connect("before", form,"onsubmit", this, "_selectAll");
+            } else {
+                dojo.debug("MultiValueDoubleList is not being added to a form -- no onSubmitHandler then.");
+            }
+        },
+
+        /**
+         * Finds the HTML form to which a widget belongs.
+         * The widget is passed as an argument since this might become a generic
+         * utility function outside of this wiget.
+         */
+        _getForm: function(widget) {
+            do {
+                if (widget.domNode != null && widget.domNode.tagName != null && widget.domNode.tagName.toLowerCase() == "form") {
+                    return widget.domNode;
+                }
+                widget = widget.parent;
+            } while (widget != null)
+            return null;
+        },
+
+        _readData: function(origFrag) {
+            // Read data from available list options.
+            var table = dojo.dom.getFirstChildElement(origFrag, "table");
+            if (table != null) {
+                var tbody = dojo.dom.firstElement(table, "tbody");
+                if (tbody != null) {
+                    var tr = dojo.dom.firstElement(tbody, "tr");
+                    while (tr != null) {
+                        var td = dojo.dom.firstElement(tr, "td");
+                        var value = td != null ? dojo.dom.textContent(td) : null;
+                        var text = td.nextSibling != null ? dojo.dom.textContent(td.nextSibling) : value;
+
+                        if (value && text) {
+                            this.selectLeft.addOption(value, text);
+                        }
+                        tr = dojo.dom.nextElement(tr, "tr");
+                    }
+                }
+                // Read data from selected list options.
+                var table1 = dojo.dom.getNextSiblingElement(table, "table");
+                if (table1 != null) {
+                    var tbody1 = dojo.dom.firstElement(table1, "tbody");
+                    if (tbody1 != null) {
+                        var tr1 = dojo.dom.firstElement(tbody1, "tr");
+                        while (tr1 != null) {
+                            var td1 = dojo.dom.firstElement(tr1, "td");
+                            var value1 = td1 != null ? dojo.dom.textContent(td1) : null;
+                            var text1 = td1.nextSibling != null ? dojo.dom.textContent(td1.nextSibling) : value1;
+
+                            if (value1 && text1) {
+                                this.selectRight.addOption(value1, text1);
+                            }
+                            tr1 = dojo.dom.nextElement(tr1, "tr");
+                        }
+                    }
+                }
+            } else {
+                dojo.debug("MultiValueDoubleList: no data table found");
+            }
+        },
+
+        _selectAll: function() {
+            this._selectAllOptions(this.selectRight);
+        },
+
+        _transferLeft: function (event) {
+            dojo.event.browser.stopEvent(event);
+            this._moveSelectedOptions(this.selectRight, this.selectLeft);
+            this._update();
+        },
+
+        _transferRight: function (event) {
+            dojo.event.browser.stopEvent(event);
+            this._moveSelectedOptions(this.selectLeft, this.selectRight);
+            this._update();
+        },
+
+        _transferAllLeft: function (event) {
+            dojo.event.browser.stopEvent(event);
+            this._moveAllOptions(this.selectRight, this.selectLeft);
+            this._update();
+        },
+
+        _transferAllRight: function (event) {
+            dojo.event.browser.stopEvent(event);
+            this._moveAllOptions(this.selectLeft, this.selectRight);
+            this._update();
+        },
+
+        _update: function() {
+            var removedLeft = new Object();
+            var removedRight = new Object();
+            var addedLeft = new Object();
+            var addedRight = new Object();
+            var newLeft = new Object();
+            var newRight = new Object();
+            var originalLeftValues = new Object();
+            var originalRightValues = new Object();
+            var delimiter = ",";
+            var right = this.selectRight;
+            var left = this.selectLeft;
+            var removedLeftField = null;
+            var removedRightField = null;
+            var addedLeftField = null;
+            var addedRightField = null;
+            var newLeftField = null;
+            var newRightField = null;
+            for (var i = 0; i < left.options.length; i++) {
+                var o = left.options[i];
+                newLeft[o.value] = 1;
+                if (typeof(originalLeftValues[o.value]) == "undefined") {
+                    addedLeft[o.value] = 1;
+                    removedRight[o.value] = 1;
+                    }
+                }
+            for (var i = 0; i < right.options.length; i++) {
+                var o = right.options[i];
+                newRight[o.value] = 1;
+                if (typeof(originalRightValues[o.value]) == "undefined") {
+                    addedRight[o.value] = 1;
+                    removedLeft[o.value] = 1;
+                    }
+                }
+            if (removedLeftField != null) {
+                removedLeftField.value = this._join(removedLeft, delimiter);
+            }
+            if (removedRightField != null) {
+                removedRightField.value = this._join(removedRight, delimiter);
+            }
+            if (addedLeftField != null) {
+                addedLeftField.value = this._join(addedLeft, delimiter);
+            }
+            if (addedRightField != null) {
+                addedRightField.value = this._join(addedRight, delimiter);
+            }
+            if (newLeftField != null) {
+                newLeftField.value = this._join(newLeft, delimiter);
+            }
+            if (newRightField != null) {
+                newRightField.value = this._join(newRight, delimiter);
+            }
+        },
+
+        _moveSelectedOptions: function (from, to) {
+            if (arguments.length > 3) {
+                var regex = arguments[3];
+                if(regex != "") {
+                    this._unSelectMatchingOptions(from,regex);
+                }
+            }
+            for(var i = 0; i < from.options.length; i++) {
+                var o = from.options[i];
+                if(o.selected) {
+                    to.options[to.options.length] = new Option( o.text, o.value, true, o.selected);
+                }
+            }
+            for (var i = (from.options.length-1); i >= 0; i--) {
+                var o = from.options[i];
+                if(o.selected) {
+                    from.options[i] = null;
+                }
+            }
+            if ((arguments.length < 3) || (arguments[2] == true)) {
+                this._sortSelect(from);
+                this._sortSelect(to);
+            }
+            from.selectedIndex = -1;
+            to.selectedIndex = -1;
+        },
+
+        _moveAllOptions: function (from, to) {
+            this._selectAllOptions(from);
+            if(arguments.length == 2) {
+                this._moveSelectedOptions(from, to);
+            } else if(arguments.length == 3) {
+                this._moveSelectedOptions(from, to, arguments[2]);
+            } else if(arguments.length == 4) {
+                this._moveSelectedOptions(from, to, arguments[2], arguments[3]);
+            }
+        },
+
+        _selectAllOptions: function (obj) {
+            for(var i = 0; i < obj.options.length; i++) {
+                obj.options[i].selected = true;
+            }
+        },
+
+        _unSelectMatchingOptions: function (obj, regex) {
+            this._selectUnselectMatchingOptions(obj, regex, "unselect", false);
+        },
+
+        _selectUnselectMatchingOptions: function(obj, regex, which, only) {
+            if (window.RegExp) {
+                var selected1;
+                var selected2;
+                if(which == "select"){
+                    selected1 = true;
+                    selected2 = false;
+                } else if (which == "unselect") {
+                    selected1 = false;
+                    selected2 = true;
+                } else {
+                      return;
+                }
+                var re = new RegExp(regex);
+                for (var i = 0;i < obj.options.length; i++) {
+                    if(re.test(obj.options[i].text)) {
+                        obj.options[i].selected = selected1;
+                } else {
+                    if(only == true) {
+                        obj.options[i].selected = selected2;
+                    }
+                }
+              }
+           }
+        },
+
+        _join: function(o, delimiter) {
+            var val;
+            var str="";
+            for(val in o) {
+                if (str.length > 0) {
+                    str = str + delimiter;
+                }
+                str = str + val;
+            }
+            return str;
+        },
+
+        _sortSelect: function(obj) {
+            var o = new Array();
+            if(obj.options == null) {
+                return;
+            }
+            for(var i = 0; i < obj.options.length; i++) {
+                o[o.length] = new Option( obj.options[i].text, obj.options[i].value, obj.options[i].defaultSelected, obj.options[i].selected) ;
+             }
+             if (o.length == 0) {
+                 return;
+             }
+             o = o.sort( function(a,b) {
+                            if ((a.text + "") < (b.text + "")) {
+                                return -1;
+                            }
+                            if ((a.text + "") > (b.text + "")) {
+                                return 1;
+                            }
+                            return 0;
+                         } );
+            for(var i = 0; i < o.length; i++) {
+                obj.options[i] = new Option(o[i].text, o[i].value, o[i].defaultSelected, o[i].selected);
+            }
+        }
+
+    }
+);

Propchange: cocoon/branches/BRANCH_2_1_X/src/blocks/forms/resources/org/apache/cocoon/forms/resources/js/MultiValueDoubleList.js
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/forms/resources/org/apache/cocoon/forms/resources/js/__package__.js
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/src/blocks/forms/resources/org/apache/cocoon/forms/resources/js/__package__.js?rev=675789&r1=675788&r2=675789&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/forms/resources/org/apache/cocoon/forms/resources/js/__package__.js (original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/forms/resources/org/apache/cocoon/forms/resources/js/__package__.js Thu Jul 10 15:36:41 2008
@@ -14,9 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
- 
- 
- 
+
 // DEPRECATED: This functionality is provided more elegantly via the manifest.js file
 
 dojo.kwCompoundRequire({
@@ -30,6 +28,7 @@
                 "cocoon.forms.InfoPopup",
                 "cocoon.forms.MultiValueEditor",
                 "cocoon.forms.MultiValueEditorWithSuggestion",
+                "cocoon.forms.MultiValueDoubleList",
                 "dojo.widget.InlineEditBox" // also needed by advanced-field-styling
         ]
 });

Added: cocoon/branches/BRANCH_2_1_X/src/blocks/forms/resources/org/apache/cocoon/forms/resources/js/templates/MultiValueDoubleList.html
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/src/blocks/forms/resources/org/apache/cocoon/forms/resources/js/templates/MultiValueDoubleList.html?rev=675789&view=auto
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/forms/resources/org/apache/cocoon/forms/resources/js/templates/MultiValueDoubleList.html (added)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/forms/resources/org/apache/cocoon/forms/resources/js/templates/MultiValueDoubleList.html Thu Jul 10 15:36:41 2008
@@ -0,0 +1,31 @@
+<div id="${this.widgetId}" class="${this.styleClass}">
+  <table>
+    <tr>
+    <th>${this.availableListLabel}</th>
+    <th/>
+    <th>${this.selectedListLabel}</th>
+    </tr>
+    <tr>
+      <td>
+        <select name="${this.cformsIdPrefix}.unselected" id="${this.cformsIdPrefix}.unselected" size="${this.size}"
+            multiple="multiple" dojoAttachPoint="selectLeft">
+        </select>
+      </td>
+      <td width="10px">
+        <img dojoAttachPoint="transferRight" src="${this.resourcesUri}/forms/img/move_right.gif">
+        <br/>
+        <img dojoAttachPoint="transferAllRight" src="${this.resourcesUri}/forms/img/move_all_right.gif">
+        <br/>
+        <img dojoAttachPoint="transferLeft" src="${this.resourcesUri}/forms/img/move_left.gif">
+        <br/>
+        <img dojoAttachPoint="transferAllLeft" src="${this.resourcesUri}/forms/img/move_all_left.gif">
+        <br/>
+      </td>
+      <td>
+        <select name="${this.cformsIdPrefix}" id="${this.cformsIdPrefix}:input" size="${this.size}"
+            multiple="multiple" dojoAttachPoint="selectRight">
+        </select>
+      </td>
+    </tr>
+  </table>
+</div>

Propchange: cocoon/branches/BRANCH_2_1_X/src/blocks/forms/resources/org/apache/cocoon/forms/resources/js/templates/MultiValueDoubleList.html
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/forms/resources/org/apache/cocoon/forms/resources/manifest.js
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/src/blocks/forms/resources/org/apache/cocoon/forms/resources/manifest.js?rev=675789&r1=675788&r2=675789&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/forms/resources/org/apache/cocoon/forms/resources/manifest.js (original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/forms/resources/org/apache/cocoon/forms/resources/manifest.js Thu Jul 10 15:36:41 2008
@@ -44,7 +44,8 @@
             "dropdowndatetimepicker"    : "cocoon.forms.DropdownDateTimePicker",
             "infopopup"                 : "cocoon.forms.InfoPopup",
             "multivalueeditor"          : "cocoon.forms.MultiValueEditor",
-            "multivalueeditorwithsuggestion" : "cocoon.forms.MultiValueEditorWithSuggestion"
+            "multivalueeditorwithsuggestion" : "cocoon.forms.MultiValueEditorWithSuggestion",
+            "multivaluedoublelist" : "cocoon.forms.MultiValueDoubleList"
             // register new Widgets in the cocoon.forms namespace here
         },
         svg: {

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/flow/forms_flow_example.js
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/flow/forms_flow_example.js?rev=675789&r1=675788&r2=675789&view=diff
==============================================================================
--- 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 Thu Jul 10 15:36:41 2008
@@ -290,3 +290,19 @@
     var form = new Form("forms/widgetstates.xml");
     form.showForm("widgetstates-display-pipeline.jx");
 }
+
+function do_multiValueDoubleList() {
+    var list = new Packages.java.util.ArrayList();
+    list.add("3");
+    list.add("5");
+    var form = new Form("forms/multiValueDoubleList.xml");
+    form.getChild("field_1").setValue(list.toArray());
+    form.showForm("multiValueDoubleList-display-pipeline.jx");
+    var _field_1 = form.getChild("field_1").getValue();
+    var _string1 = "";
+    for (var i = 0; i < _field_1.length; i++) {
+        _string1 += " " + _field_1[i] + ",";
+    }
+    cocoon.sendPage("textresult-display-pipeline.jx",
+        { title: "Values selected", text: "_field_1: "+_string1 });
+}
\ No newline at end of file

Added: cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/forms/multiValueDoubleList.xml
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/forms/multiValueDoubleList.xml?rev=675789&view=auto
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/forms/multiValueDoubleList.xml (added)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/forms/multiValueDoubleList.xml Thu Jul 10 15:36:41 2008
@@ -0,0 +1,61 @@
+<?xml version="1.0"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You 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 activate/invisible state widget on ajax forms. -->
+<fd:form xmlns:fd="http://apache.org/cocoon/forms/1.0#definition" xmlns:i18n="http://apache.org/cocoon/i18n/2.1">
+
+  <fd:widgets>
+
+    <fd:multivaluefield id="field_1">
+        <fd:label><br>Multivalue dojo widget:</br></fd:label>
+        <fd:hint>double-list multivalue dojo widget</fd:hint>
+        <fd:help>double-list multivalue dojo widget</fd:help>
+        <fd:datatype base="string"/>
+        <fd:selection-list>
+            <fd:item value="1"/>
+            <fd:item value="2"/>
+            <fd:item value="3"/>
+            <fd:item value="4"/>
+            <fd:item value="5"/>
+            <fd:item value="6"/>
+        </fd:selection-list>
+    </fd:multivaluefield>
+
+    <fd:action id="show">
+      <fd:label>show/Active ...</fd:label>
+      <fd:on-action>
+        <fd:javascript>
+            widget.getForm().getChild("field_1").setState(org.apache.cocoon.forms.formmodel.WidgetState.ACTIVE);
+        </fd:javascript>
+      </fd:on-action>
+    </fd:action>
+    <fd:action id="hide">
+      <fd:label>hide ...</fd:label>
+      <fd:on-action>
+        <fd:javascript>
+            widget.getForm().getChild("field_1").setState(org.apache.cocoon.forms.formmodel.WidgetState.INVISIBLE);
+        </fd:javascript>
+      </fd:on-action>
+    </fd:action>
+
+    <fd:submit id="save">
+        <fd:label>Save</fd:label>
+        <fd:hint>Save</fd:hint>
+    </fd:submit>
+
+  </fd:widgets>
+</fd:form>
\ No newline at end of file

Propchange: cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/forms/multiValueDoubleList.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/forms/multiValueDoubleList_template.xml
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/forms/multiValueDoubleList_template.xml?rev=675789&view=auto
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/forms/multiValueDoubleList_template.xml (added)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/forms/multiValueDoubleList_template.xml Thu Jul 10 15:36:41 2008
@@ -0,0 +1,40 @@
+<?xml version="1.0"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You 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"/>
+  <h4 class="samplesGroup">Sample to double-list multivalue widget with dojo.</h4>
+  <title>Sample form</title>
+  <content>
+    <ft:form-template action="continue" method="POST" ajax="true">
+      <ft:continuation-id/>
+
+        <ft:widget id="field_1">
+              <fi:styling list-type="dojo-double-listbox" size="10">
+                <fi:available-label>Available items</fi:available-label>
+                <fi:selected-label>Selected items</fi:selected-label>
+              </fi:styling>
+        </ft:widget>
+
+        <ft:widget id="show"/>
+        <ft:widget id="hide"/>
+        <ft:widget id="save"/>
+
+    </ft:form-template>
+  </content>
+</page>

Propchange: cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/forms/multiValueDoubleList_template.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/forms/widgetstates.xml
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/forms/widgetstates.xml?rev=675789&r1=675788&r2=675789&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/forms/widgetstates.xml (original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/forms/widgetstates.xml Thu Jul 10 15:36:41 2008
@@ -215,7 +215,7 @@
         function startsWith(string1, string2) {
           return (new java.lang.String(string1.toLowerCase())).startsWith(string2.toLowerCase());
         }
-        
+
         function searchByString() {
           for (var i = 0; i < list.length; i++) {
             if (startsWith(list[i].label, filter)) {
@@ -223,7 +223,7 @@
             }
           }
         }
-        
+
         function searchById() {
           for (var i = 0; i < list.length; i++) {
             if (list[i].value == parseInt(filter)) {
@@ -231,7 +231,7 @@
             }
           }
         }
-        
+
         var suggestions = [];
         var list = personList();
         if (filter) {
@@ -242,9 +242,9 @@
             } else {
               cocoon.log.error("The filter: '" + filter + "' must be a number.");
             }
-          } else {              
+          } else {
             searchByString();
-          }          
+          }
         } else {
           suggestions = list;
         }
@@ -258,7 +258,22 @@
       <fd:help>field_14</fd:help>
       <fd:datatype base="long" />
     </fd:multivaluefield>
-        
+
+    <fd:multivaluefield id="field_15">
+        <fd:label><b>Multivalue dojo widget:</b></fd:label>
+        <fd:hint>double-list multivalue dojo widget</fd:hint>
+        <fd:help>double-list multivalue dojo widget</fd:help>
+        <fd:datatype base="string"/>
+        <fd:selection-list>
+            <fd:item value="1"/>
+            <fd:item value="2"/>
+            <fd:item value="3"/>
+            <fd:item value="4"/>
+            <fd:item value="5"/>
+            <fd:item value="6"/>
+        </fd:selection-list>
+    </fd:multivaluefield>
+
     <fd:repeater id="contacts">
       <fd:widgets>
         <fd:field id="firstname">
@@ -282,7 +297,7 @@
     <fd:repeater-action id="removecontacts" command="delete-rows" repeater="contacts" select="select">
       <fd:label>Remove selected contacts</fd:label>
     </fd:repeater-action>
-    
+
     <fd:repeater id="contacts2">
       <fd:widgets>
         <fd:field id="firstname">
@@ -306,7 +321,7 @@
     <fd:repeater-action id="removecontacts2" command="delete-rows" repeater="contacts2" select="select">
       <fd:label>Remove selected contacts</fd:label>
     </fd:repeater-action>
-    
+
     <fd:repeater id="contacts3">
       <fd:widgets>
         <fd:field id="firstname">
@@ -336,7 +351,7 @@
       <fd:on-action>
         <fd:javascript>
         	var i;
-			for (i=1; i &lt;= 14; i++) {
+			for (i=1; i &lt;= 15; i++) {
           		widget.getForm().getChild("field_" + i).setState(org.apache.cocoon.forms.formmodel.WidgetState.ACTIVE);
           	}
         </fd:javascript>
@@ -347,7 +362,7 @@
       <fd:on-action>
         <fd:javascript>
         	var i;
-			for (i=1; i &lt;= 14; i++) {
+			for (i=1; i &lt;= 15; i++) {
           		widget.getForm().getChild("field_" + i).setState(org.apache.cocoon.forms.formmodel.WidgetState.INVISIBLE);
           	}
         </fd:javascript>
@@ -358,7 +373,7 @@
 	    <fd:on-action>
 		    <fd:javascript>
 			    var i;
-			    for (i=1; i &lt;= 14; i++) {
+			    for (i=1; i &lt;= 15; i++) {
 			         widget.getForm().getChild("field_" + i).setState(org.apache.cocoon.forms.formmodel.WidgetState.DISABLED);
 			    }
 		    </fd:javascript>

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/forms/widgetstates_template.xml
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/forms/widgetstates_template.xml?rev=675789&r1=675788&r2=675789&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/forms/widgetstates_template.xml (original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/forms/widgetstates_template.xml Thu Jul 10 15:36:41 2008
@@ -32,8 +32,8 @@
       <br />
       <fi:group>
         <fi:styling layout="columns"/>
-        <fi:items>          
-          <ft:widget id="field_2"/>          
+        <fi:items>
+          <ft:widget id="field_2"/>
           <ft:widget id="field_4">
             <fi:styling list-type="listbox"/>
           </ft:widget>
@@ -58,6 +58,12 @@
             <fi:styling type="MultiValueEditorWithSuggestion"
                         dataUrl="_cocoon/forms/suggest/contacts"/>
           </ft:widget>
+          <ft:widget id="field_15">
+              <fi:styling list-type="dojo-double-listbox">
+                <fi:available-label>Available items</fi:available-label>
+                <fi:selected-label>Selected items</fi:selected-label>
+              </fi:styling>
+        </ft:widget>
         </fi:items>
       </fi:group>
       <br />
@@ -125,7 +131,7 @@
             <table border="1">
               <tr>
                 <th><ft:repeater-widget-label widget-id="firstname"/></th>
-                <th><ft:repeater-widget-label widget-id="lastname"/></th>                
+                <th><ft:repeater-widget-label widget-id="lastname"/></th>
                 <th><ft:repeater-widget-label widget-id="select"/></th>
               </tr>
               <tbody>

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/welcome.xml
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/src/blocks/forms/samples/welcome.xml?rev=675789&r1=675788&r2=675789&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 Thu Jul 10 15:36:41 2008
@@ -93,7 +93,7 @@
   <sample name="Flowscript" href="form1.flow?locale=el">Greek</sample>
   <sample name="Flowscript" href="form1.flow?locale=zh_CN">Chinese</sample>
  </group>
- 
+
  <group name="Dynamic templates and recursive forms">
    <note>
      These samples were written for the GT2004 presentation about dynamic templates and recursive forms.
@@ -113,7 +113,7 @@
      widgets.
    </sample>
  </group>
- 
+
  <group name="Tree widget samples">
    <sample name="File explorer" href="do-fileExplorer.flow">
      (Ajax) A file explorer built with two tree widgets.
@@ -122,7 +122,7 @@
      (Ajax) Scratchpad for random samples of the Tree widgets.
    </sample>
  </group>
- 
+
  <group name="Advanced Ajax samples using Dojo widgets">
    <sample name="Drag and drop reordering, in-place editing" href="do-dojoRepeater.flow">
      (Ajax) The dynamic repeater sample revisited, featuring drag and drop reordering of rows,
@@ -138,7 +138,9 @@
    <sample name="Cocoon multivalue editor with suggestions" href="do-multivalueWithSuggestion.flow">
      (Ajax) Very simple demo of the &lt;fd:multivaluefield&gt; with suggestion support feature.
    </sample>
-   
+   <sample name="Cocoon double-list multivalue widget" href="do-multiValueDoubleList.flow">
+     (Ajax) Demo of the double list &lt;fd:multivaluefield&gt;.
+   </sample>
    <sample name="In place editing" href="do-inplace.flow">
      (Ajax) Various ways to use in place editing.
    </sample>
@@ -150,7 +152,7 @@
      (Ajax) Demostrate how it works the change of the widget state on a ajax request
    </sample>
  </group>
- 
+
  <group name="Dynamic repeater template and event handling">
     <sample name="Dynamic repeater template" href="dreamteam">
       Create your Euro 2004 soccer dream team
@@ -163,9 +165,9 @@
       In order to keep the samples as lean as possible, an action is used as controller.
     </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> 
- 
+    <sample name="form1 - FormsTransformer" href="form1-cforms-transformer">Render form using the FormsTransformer</sample>
+  </group>
+
 <!--
  <group name="Pre-alpha Cocoon Forms-based xml editor">
   <note>

Modified: cocoon/branches/BRANCH_2_1_X/status.xml
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/status.xml?rev=675789&r1=675788&r2=675789&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/status.xml (original)
+++ cocoon/branches/BRANCH_2_1_X/status.xml Thu Jul 10 15:36:41 2008
@@ -186,6 +186,9 @@
     <action dev="all" type="update">
       Starting with 2.1.12 the minimum required Java version will be 1.4.2.
     </action>
+    <action dev="AG" type="fix" fixes-bug="COCOON-1822" due-to="Karen Torres &amp; Rafael Márquez" due-to-email="ktorres@agssa.net &amp; rmarquez@agssa.net">
+      Forms: MultiValueField list-type="double-listbox" does not work correctly in ajax enabled forms.
+    </action>
     <action dev="AN" type="fix" fixes-bug="COCOON-2169" due-to="Mark Lundquist" due-to-email="lundquist.mark@gmail.com">
       ImageOp block: If parameter width or height in resize operation is zero, use the original image size.
       If both are zero, then handle as no-op.  Set default values to zero to allow using that feature by