myfaces-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Daniel Dziegielewski (JIRA)" <...@myfaces.apache.org>
Subject [jira] [Created] (TOMAHAWK-1682) Using move method from picklist will invert the order
Date Mon, 18 Apr 2016 11:46:25 GMT
Daniel Dziegielewski created TOMAHAWK-1682:
----------------------------------------------

             Summary: Using move method from picklist will invert the order
                 Key: TOMAHAWK-1682
                 URL: https://issues.apache.org/jira/browse/TOMAHAWK-1682
             Project: MyFaces Tomahawk
          Issue Type: Improvement
         Environment: Eclipse on Windows
            Reporter: Daniel Dziegielewski
            Priority: Minor


Hello,

We are working with picklists and recently discovered that the order of the selected elements
will be placed inverted into the new picklist with the move method. Reason for that is the
decremental for loop, which in fact is the correct start to the problem of transferring the
elements but will therefore put the elements in the wrong order when putting them to the end
of the new picklist. Following patch helps solving this problem:

@@ -72,11 +72,11 @@
             return;
         }
 
+        var tLen = toList.options.length;
         // Decremental loop, so the index is not affected in the moves
         for (var i = fromList.options.length - 1; i >= 0; i--) {
             if (fromList.options[i].selected) {
-                var tLen = toList.options.length;
-                toList.options[tLen] = new Option(fromList.options[i].text);
+                toList.options.add(new Option(fromList.options[i].text),tLen);
                 toList.options[tLen].value = fromList.options[i].value;
                 fromList.options[i] = null;
             }
@@ -85,10 +85,10 @@
 
     org.apache.myfaces.Picklist.moveAll = function (fromList, toList, hiddenId) {
 
+    	var tLen = toList.options.length;
         // Decremental loop, so the index is not affected in the moves
         for (var i = fromList.options.length - 1; i >= 0; i--) {
-            var tLen = toList.options.length;
-            toList.options[tLen] = new Option(fromList.options[i].text);
+            toList.options.add(new Option(fromList.options[i].text),tLen);
             toList.options[tLen].value = fromList.options[i].value;
             fromList.options[i] = null;
         }




--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message