6 Replies Latest reply on Jul 24, 2008 8:22 PM by rajarchu

    rich:dataTable not sorting Integer

      Integer's seem to be sorting as strings when using rich:cloulmn sortBy.

      I'm pretty sure it is this bug http://jira.jboss.com/jira/browse/RF-2915?page=all .

      I'm running 3.2.1CR5, because I thought the fix for this was in place. In fact, when I look at the notes Nick and Mikhail posted, and then go into the 3.2.1CR5 src files, I see the config change mentioned in the patch.

      However, after changing to the new libraries, I'm still running into the same issue.

      Am I wrong in expecting 3.2.1CR5 to have picked this fix up? Anyone ?

        • 1. Re: rich:dataTable not sorting Integer

          Could you please attach your source code(or .war) with implemented sorting feature & describe your configuration(server, browser, OS, platform)?
          This bug isn't reproducible under 3.2.1.CR5 for test-application.

          • 2. Re: rich:dataTable not sorting Integer

             

            "mvitenkov" wrote:
            Could you please attach your source code(or .war) with implemented sorting feature & describe your configuration(server, browser, OS, platform)?
            This bug isn't reproducible under 3.2.1.CR5 for test-application.


            Certainly:

            Weblogic 10
            IE6
            WinXP
            3.2.1.CR5 (dl'ed from http://repository.jboss.org/maven2/org/richfaces/ui/richfaces-ui/3.2.1.CR5/)
            Facelets 1.1.14
            Spring

            Like I said, the table is sortable (and sorts) on all the columns, the only issue is the id field (the Integer), sorts like a string. for instance I see:

            0
            1
            10
            100
            101

            when sorting the id column.

            Thanks for your help.

            Bean:
            public class JamesBean implements Serializable{
            
             public class TestObject{
             private String firstName;
             private String lastName;
             private Integer id;
            
             public Integer getId() {
             return id;
             }
            
             public void setId(Integer id) {
             this.id = id;
             }
            
             public String getFirstName() {
             return firstName;
             }
            
             public void setFirstName(String firstName) {
             this.firstName = firstName;
             }
            
             public String getLastName() {
             return lastName;
             }
            
             public void setLastName(String lastName) {
             this.lastName = lastName;
             }
             }
            
            
             private List<TestObject> names;
            
             public List<TestObject> getNames() {
             if(this.names==null){
             this.names = new ArrayList();
             for(int i=0;i<500;i++){
             TestObject to = new TestObject();
             to.setId(i);
             to.setFirstName("First:"+i);
             to.setLastName("Last:"+i);
             this.names.add(to);
             }
            
             }
             return names;
             }
            
            }
            


            JSP Code:
            
            <h:form id="viewReportForm">
            <rich:dataTable
             var="item"
             value="#{James.names}"
             id="reportItemsTable"
             sortMode="single"
             >
            
             <rich:column sortBy="#{item.id}" id="ID">
             <f:facet name="header">
             <h:outputText value="id" />
             </f:facet>
             <h:outputText value="#{item.id}"/>
             </rich:column>
            
             <rich:column sortBy="#{item.firstName}" id="firstName">
             <f:facet name="header">
             <h:outputText value="First Name" />
             </f:facet>
             <h:outputText value="#{item.firstName}"/>
             </rich:column>
            
             <rich:column sortBy="#{item.lastName}" id="lastName">
             <f:facet name="header">
             <h:outputText value="Last Name" />
             </f:facet>
             <h:outputText value="#{item.lastName}"/>
             </rich:column>
            
            
            </rich:dataTable>
            
            </h:form>
            


            Spring Bean Definition:

             <bean id="James" scope="session" class="path.to.my.beans.managedBeans.JamesBean"/>
            
            


            • 3. Re: rich:dataTable not sorting Integer

              0
              1
              10
              100
              101

              is sorted correctly, not?

              But it is not a good example, a string sort would give the same...

              A better example (string sorted):

              0
              1
              10
              2

              I'm curious to know from you if it works, cause I'm waiting for the fix too...

              • 4. Re: rich:dataTable not sorting Integer
                • 5. Re: rich:dataTable not sorting Integer
                  rajarchu

                  Hi am also facing the same problem. I am using 3.2.0.SR version and i dont know how to slove this.. any one has any idea?

                  • 6. Re: rich:dataTable not sorting Integer
                    rajarchu

                    Got the problem solved in 3.2.1.GA version. I am able to sort accroding to data types. Thanks