Velocity Tools
  1. Velocity Tools
  2. VELTOOLS-85

DESCENDING order is not preserved in SortTool


    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.2, 1.3
    • Fix Version/s: 1.4, 2.x
    • Component/s: GenericTools
    • Labels:
    • Environment:
      jdk1.5, jboss4.0.4, struts1.3.8, velocity-tools1.3


      I have a property list for each page in my application that I store in the session. If the user sorts the column in DESCENDING order I add 'desc' to the property name and pass that list to the SortTool. The problem is that in the PropertiesComparator constructor, my list gets assigned to the member field and the member field is changed (the ':desc' is removed from the list). The result is the next time the user returns to the page with the column in DESCENDING order, the order is ASCENDING, which is not what I want. I want to preserve the user's selection.

      Here is the code in SortTool I'm referring to:

      public class PropertiesComparator implements Comparator
      List properties;
      public PropertiesComparator(List properties)
      { = properties; //the member list is pointing to my list now
      int colonIndex = prop.indexOf(':');
      if (colonIndex != -1)
      String sortType = prop.substring(colonIndex + 1);
      properties.set(i, prop.substring(0, colonIndex)); //and here the 'desc' is removed

      I rebuild the velocity-tools.jar with the following changes to fix the problem:

      public PropertiesComparator(List propertiesList)
      // I am copying my properties list to the member list instead of pointing to the same list

      properties = new ArrayList(propertiesList.size());


        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        Open Open Resolved Resolved
        20d 20h 35m 1 Nathan Bubna 10/Aug/07 16:53
        Nathan Bubna made changes -
        Fix Version/s 1.4 [ 12312330 ]
        Fix Version/s 2.0 [ 12310350 ]
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Nathan Bubna added a comment -

        Fixed in both 1.x and 2.x. Thanks!

        Nathan Bubna added a comment - Fixed in both 1.x and 2.x. Thanks!
        Nathan Bubna made changes -
        Field Original Value New Value
        Assignee Nathan Bubna [ nbubna ]
        Tatyana created issue -


          • Assignee:
            Nathan Bubna
          • Votes:
            0 Vote for this issue
            0 Start watching this issue


            • Created: