0 Replies Latest reply on Oct 7, 2011 9:31 AM by lfcamargo

    rich:column sorting problem

    lfcamargo

      Fellows,

       

      I have a problem with the sorting feature. I'm trying create a simple dataTable with sorting but it just works once.

      The first time that I click on the header the sorts works fine, but when I click again it doesn't work anymore.

      I'm following the example of the live demo. But I can't make it work.

       

      I'm using:

      Spring 3.0.5

      Richfaces 3.3.3.Final.

      JSF1.2

       

       

      Follow my codes:

      .xhtml

      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      
      
      <html xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:a4j="http://richfaces.org/a4j"
                xmlns:rich="http://richfaces.org/rich">
      
      
      <a4j:form>
                <rich:panel id="pnl">
                <rich:dataTable var="_item" value="#{testeBean.lista}"  reRender="pnl" id="table" >
                          <rich:column sortBy="#{_item.nome}" id="col1" sortable="true" >
                                    <f:facet name="header">nome</f:facet>
                                    <h:outputText value="#{_item.nome}" />
                          </rich:column>
                          <rich:column sortBy="#{_item.numero}" id="col2" sortable="true"   >
                                    <f:facet name="header">numero</f:facet>
                                    <h:outputText value="#{_item.numero}" />
                          </rich:column>
                </rich:dataTable>
                </rich:panel>
      </a4j:form>
      </html>
      
      
      

       

      ManagedBean

       

      @Component
      @Scope("session")
      public class TesteBean {
          
          private List<Teste> lista;
          
          public TesteBean() {
              lista = new ArrayList<Teste>();
              
              for (int i = 0; i < 50; i++) {
                  lista.add(new Teste("Nome" + i, i));
              }
              
          }
          
          /**
           * Get the lista.
           *
           * @return the lista.
           */
          public List<Teste> getLista() {
              return lista;
          }
          
          /**
           * Set the lista.
           *
           * @param lista The lista to set.
           */
          public void List(ArrayList<Teste> lista) {
              this.lista = lista;
          }
          
      }
      
      

       

      ValueObject

       

      
      public class Teste implements Serializable {
          
          /** The serialVersionUID */
          private static final long serialVersionUID = 2338342875466046563L;
          
          private String            nome;
          
          private Integer           numero;
          
          public Teste(String nome, Integer numero) {
              this.nome = nome;
              this.numero = numero;
          }
          
          /**
           * Get the nome.
           *
           * @return the nome.
           */
          public String getNome() {
              return nome;
          }
          
          /**
           * Set the nome.
           *
           * @param nome The nome to set.
           */
          public void setNome(String nome) {
              this.nome = nome;
          }
          
          /**
           * Get the numero.
           *
           * @return the numero.
           */
          public Integer getNumero() {
              return numero;
          }
          
          /**
           * Set the numero.
           *
           * @param numero The numero to set.
           */
          public void setNumero(Integer numero) {
              this.numero = numero;
          }
          
          /**
           * @see java.lang.Object#hashCode()
           */
          @Override
          public int hashCode() {
              final int prime = 31;
              int result = 1;
              result = prime * result + ((nome == null) ? 0 : nome.hashCode());
              result = prime * result + ((numero == null) ? 0 : numero.hashCode());
              return result;
          }
          
          /**
           * @see java.lang.Object#equals(java.lang.Object)
           */
          @Override
          public boolean equals(Object obj) {
              if (this == obj) return true;
              if (obj == null) return false;
              if (getClass() != obj.getClass()) return false;
              Teste other = (Teste) obj;
              if (nome == null) {
                  if (other.nome != null) return false;
              } else if (!nome.equals(other.nome)) return false;
              if (numero == null) {
                  if (other.numero != null) return false;
              } else if (!numero.equals(other.numero)) return false;
              return true;
          }
          
      }
      
      

       

       

      What I doing wrong, someone have the same problem?

       

      Thanks a lot.