myfaces-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Leonardo Uribe (JIRA)" <...@myfaces.apache.org>
Subject [jira] [Updated] (TOMAHAWK-1682) Using move method from picklist will invert the order
Date Tue, 19 Apr 2016 00:54:25 GMT

     [ https://issues.apache.org/jira/browse/TOMAHAWK-1682?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Leonardo Uribe updated TOMAHAWK-1682:
-------------------------------------
       Resolution: Fixed
         Assignee: Leonardo Uribe
    Fix Version/s: 1.1.15-SNAPSHOT
           Status: Resolved  (was: Patch Available)

> 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
>            Assignee: Leonardo Uribe
>            Priority: Minor
>             Fix For: 1.1.15-SNAPSHOT
>
>         Attachments: picklist.patch
>
>
> 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