cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anto...@apache.org
Subject svn commit: r482896 - in /cocoon: branches/BRANCH_2_1_X/ trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/resources/org/apache/cocoon/forms/resources/js/ trunk/blocks/cocoon-forms/cocoon-forms-sample/src/main/resources/COB-INF/flow/ trunk/blocks/co...
Date Wed, 06 Dec 2006 05:13:11 GMT
Author: antonio
Date: Tue Dec  5 21:13:10 2006
New Revision: 482896

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

<action dev="AG" type="fix" fixes-bug="COCOON-1962" due-to="Carlos Chávez" due-to-email="cchavez@agssa.net">
  CForms: Numeric based suggestion list should initialzate to the corresponding suggested
text.
</action>

Modified:
    cocoon/branches/BRANCH_2_1_X/status.xml
    cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/resources/org/apache/cocoon/forms/resources/js/CFormsSuggest.js
    cocoon/trunk/blocks/cocoon-forms/cocoon-forms-sample/src/main/resources/COB-INF/flow/forms_flow_example.js
    cocoon/trunk/blocks/cocoon-forms/cocoon-forms-sample/src/main/resources/COB-INF/forms/ajax_suggest_form.xml
    cocoon/trunk/blocks/cocoon-forms/cocoon-forms-sample/src/main/resources/COB-INF/forms/ajax_suggest_template.xml

Modified: cocoon/branches/BRANCH_2_1_X/status.xml
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/status.xml?view=diff&rev=482896&r1=482895&r2=482896
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/status.xml (original)
+++ cocoon/branches/BRANCH_2_1_X/status.xml Tue Dec  5 21:13:10 2006
@@ -184,6 +184,9 @@
   <release version="@version@" date="@date@">
 -->
   <release version="2.1.10" date="TBD">
+   <action dev="AG" type="fix" fixes-bug="COCOON-1962" due-to="Carlos Chávez" due-to-email="cchavez@agssa.net">
+      CForms: Numeric based suggestion list should initialzate to the corresponding suggested
text.
+    </action>
     <action dev="BRD" type="update">
       Updated Rhino (Javascript engine) to version 1.6R5.
       This version is licensed under MPL, while previous versions were licensed under NPL,

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/resources/org/apache/cocoon/forms/resources/js/CFormsSuggest.js
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/resources/org/apache/cocoon/forms/resources/js/CFormsSuggest.js?view=diff&rev=482896&r1=482895&r2=482896
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/resources/org/apache/cocoon/forms/resources/js/CFormsSuggest.js
(original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-impl/src/main/resources/org/apache/cocoon/forms/resources/js/CFormsSuggest.js
Tue Dec  5 21:13:10 2006
@@ -54,9 +54,35 @@
                 "&continuation-id=" + contId + "&filter=%{searchString}";
         }
         dojo.widget.html.ComboBox.prototype.fillInTemplate.apply(this, arguments);
-        // Restore the initial value and the associated suggestion text, if any
-        this.setValue(node.getAttribute("suggestion") ? node.getAttribute("suggestion") :
node.value);
-        this.setSelectedValue(node.value);
+        if (node.value) {
+            // Get the suggestion text from the server
+            this.getData(this, "_cocoon/forms/suggest?widget=" + node.getAttribute("name")
+ 
+                    "&continuation-id=" + contId + "&filter=" + node.value + "&phase=init",
node);
+        } else {
+            // Restore the initial value and the associated suggestion text, if any
+            this.setValue(node.getAttribute("suggestion") ? node.getAttribute("suggestion")
: node.value);
+            this.setSelectedValue(node.value);
+        }
+    },
+
+    getData: function(widget, url, node) {
+        dojo.io.bind({
+            url: url,
+            load: dojo.lang.hitch(this, function(type, data, evt){ 
+                if(!dojo.lang.isArray(data)){
+                    var arrData = [];
+                    for(var key in data){
+                        arrData.push([data[key], key]);
+                    }
+                    data = arrData;
+                }
+                // suggestion text
+                widget.setValue(data[0][0]);
+                // numeric value
+                widget.setSelectedValue(node.value);
+            }),
+            mimetype: "text/json"
+        });
     }
 })
 

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-sample/src/main/resources/COB-INF/flow/forms_flow_example.js
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-sample/src/main/resources/COB-INF/flow/forms_flow_example.js?view=diff&rev=482896&r1=482895&r2=482896
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-sample/src/main/resources/COB-INF/flow/forms_flow_example.js
(original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-sample/src/main/resources/COB-INF/flow/forms_flow_example.js
Tue Dec  5 21:13:10 2006
@@ -215,14 +215,18 @@
 
 function do_suggest() {
     var form = new Form("forms/ajax_suggest_form.xml");
-    var path = form.getChild("path");
 
     form.showForm("ajax_suggest-display-pipeline.jx");
-    
+
+    var path = form.getChild("path");
+    var person = form.getChild("personId");
+
     cocoon.sendPage("textresult-display-pipeline.jx",
         {title: "Suggest results", text: "path value = " + path.value +
-              "\npath suggested label = " +  
-              (path.suggested ? path.suggestionLabel : "(none)") });
+             "\npath suggested label = " +  
+             (path.suggested ? path.suggestionLabel : "(none)") +
+             "\n\n\npersonId = " + person.value + 
+             "\npersonName = " + (person.suggested ? person.suggestionLabel : "(none)")});
 }
 
 function do_inplace() {

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-sample/src/main/resources/COB-INF/forms/ajax_suggest_form.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-sample/src/main/resources/COB-INF/forms/ajax_suggest_form.xml?view=diff&rev=482896&r1=482895&r2=482896
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-sample/src/main/resources/COB-INF/forms/ajax_suggest_form.xml
(original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-sample/src/main/resources/COB-INF/forms/ajax_suggest_form.xml
Tue Dec  5 21:13:10 2006
@@ -66,6 +66,83 @@
 	  ]]>
 	  </fd:suggestion-list>
 	</fd:field>
+  <fd:field id="personId">
+      <fd:datatype base="integer"/>
+      <fd:initial-value>16</fd:initial-value>
+      <fd:suggestion-list type="javascript">
+      <![CDATA[
+        function addSuggestion(bean) {
+            suggestions.push({value: bean.value, label: bean.label});
+        }
+
+        function personList() {
+          return [
+                  {value: 1, label: "Donald Ball"},
+                  {value: 2, label: "Sylvain Wallez"},
+                  {value: 3, label: "Carsten Ziegeler"},
+                  {value: 4, label: "Torsten Curdt"},
+                  {value: 5, label: "Marcus Crafter"},
+                  {value: 6, label: "Ovidiu Predescu"},
+                  {value: 7, label: "Christian Haul"},
+                  {value: 8, label: "Jeremy Quinn"},
+                  {value: 9, label: "Stefano Mazzocchi"},
+                  {value: 10, label: "Pierpaolo Fumagalli"},
+                  {value: 11, label: "Davanum Srinivas"},
+                  {value: 12, label: "Antonio Gallardo"},
+                  {value: 13, label: "Ugo Cei"},
+                  {value: 14, label: "David Crossley"},
+                  {value: 15, label: "Bertrand Delacr&#233;taz"},
+                  {value: 16, label: "Bruno Dumon"},
+                  {value: 17, label: "Daniel Fagerstrom"},
+                  {value: 18, label: "Leszek Gawron"},
+                  {value: 19, label: "Ralph Goers"},
+                  {value: 20, label: "Vadim Gritsenko"},
+                  {value: 21, label: "Jorg Heymans"},
+                  {value: 22, label: "J&#246;rg Heinicke"},
+                  {value: 23, label: "Jean-Baptiste Quenot"}
+                ];
+        }
+
+        function startsWith(string1, string2) {
+          return (new java.lang.String(string1)).startsWith(string2);
+        }
+        
+        function searchByString() {
+          for (var i = 0; i < list.length; i++) {
+            if (startsWith(list[i].label, filter)) {
+              addSuggestion(list[i]);
+            }
+          }
+        }
+        
+        function searchById() {
+          for (var i = 0; i < list.length; i++) {
+            if (list[i].value == parseInt(filter)) {
+              addSuggestion(list[i]);
+            }
+          }
+        }
+        
+        var suggestions = [];
+        var list = personList();
+        if (filter) {
+          var phase = cocoon.request.getParameter("phase");
+          if (phase && phase.equals("init")) {
+            if (!isNaN(parseInt(filter))) {
+              searchById();
+            } else {
+              cocoon.log.error("The filter: '" + filter + "' must be a number.");
+            }
+          } else {              
+            searchByString();
+          }          
+        } else {
+          suggestions = list;
+        }
+        return suggestions;
+      ]]>
+      </fd:suggestion-list>
+    </fd:field>
     <fd:submit id="ok"><fd:label>OK</fd:label></fd:submit>
   </fd:widgets>
 </fd:form>

Modified: cocoon/trunk/blocks/cocoon-forms/cocoon-forms-sample/src/main/resources/COB-INF/forms/ajax_suggest_template.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-sample/src/main/resources/COB-INF/forms/ajax_suggest_template.xml?view=diff&rev=482896&r1=482895&r2=482896
==============================================================================
--- cocoon/trunk/blocks/cocoon-forms/cocoon-forms-sample/src/main/resources/COB-INF/forms/ajax_suggest_template.xml
(original)
+++ cocoon/trunk/blocks/cocoon-forms/cocoon-forms-sample/src/main/resources/COB-INF/forms/ajax_suggest_template.xml
Tue Dec  5 21:13:10 2006
@@ -43,6 +43,12 @@
       use the up/down arrow and press space. Hitting escape hides the suggestion list.</small>
       <br/>
       <br/>
+      Choose a person.
+      <br/>
+      <ft:widget id="personId" type="suggest"/>
+      <small>Initial value of the widget is 16, the widget must show "Bruno Dumon".</small>
+      <br/>
+      <br/>
       <ft:widget id="ok"/>
     </ft:form-template>
 



Mime
View raw message