Menu

case insensitive sorting

Help
shon2006
2006-01-19
2012-10-09
  • shon2006

    shon2006 - 2006-01-19

    Display tag works great for me. The only problem iam having is it doesn't do the sorting independent of upper case and lower case. I want to do the sorting independent of upper case and lower case.
    I have orridden compareTo method in my Business object, but when I do sorting it displays as for example
    A
    B
    C
    a
    b
    It shud be DISPLAYED as:
    A
    a
    B
    b
    C

    I tried to print my results with out using display tag it works fine for me.

     
    • shon2006

      shon2006 - 2006-01-20

      I found the solution , you should add another property to your beans that contains a version of your strings in all lower-case and use that property as the sortProperty attribute. Something as simple as:
      [code]
      public String getCaseInsensitiveData() { return getData().toLowerCase();}
      [/code]
      It just provides a separate property in your bean that you can use for sorting. Only for sorting. Do not use this property for displaying. Display the "data" property but sort on the "caseInsensitiveData" property.

       

      Related

      Code: code

      • David

        David - 2007-03-27

        Just my two cents, since I just ran into the same problem. create a Class to implement Comparator. and use that in the column as comparator="xxx.xxxx.CaseInsensitiveComparator" will work. see DefaultComparator for code.

         
    • Yogesh RK

      Yogesh RK - 2006-01-20

      Hi all,
      Tables can be displayed vertically ...fine.But,I want to display them vertically as shown below.
      NAME a b c
      PHONE 1 2 3
      etc
      I had previously posted the same problem.Please help me.

      Thanks and regards

      Yogesh RK

       

Log in to post a comment.

MongoDB Logo MongoDB