Uploaded image for project: 'MyFaces Tomahawk'
  1. MyFaces Tomahawk
  2. TOMAHAWK-1682

Using move method from picklist will invert the order

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • None
    • 1.1.15-SNAPSHOT
    • None
    • None
    • Eclipse on Windows

    Description

      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; }

      Attachments

        1. picklist.patch
          2 kB
          Daniel Dziegielewski

        Activity

          People

            lu4242 Leonardo Uribe
            DanielDz Daniel Dziegielewski
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: