[
https://issues.apache.org/jira/browse/TOMAHAWK-1682?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15246870#comment-15246870
]
Leonardo Uribe commented on TOMAHAWK-1682:
------------------------------------------
Thanks to Daniel Dziegielewski for provide this patch.
> 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)