6 Replies Latest reply on May 29, 2008 7:35 AM by Nicolas Feybesse

    sortBy in scrollable data table

    Bouchra Hanine Newbie

      Hello,
      I am wondering why this code don't work (sortBy fonctionality), thank you for your help and response.

      //--------------------------------------------------------------------------------
      code xhtml
      //--------------------------------------------------------------------------------
      <h:form>
       <rich:scrollableDataTable
       width="330px" id="carList" rows="40"
       value="#{tableBean.cars}" var="car"
       sortMode="single">
      
       <rich:column sortBy="#{car.id}">
       <f:facet name="header">
       <h:outputText value="Id" />
       </f:facet>
       <h:outputText value="#{car.id}" />
       </rich:column>
      
       <rich:column sortBy="#{car.code}">
       <f:facet name="header">
       <h:outputText value="Code" />
       </f:facet>
       <h:outputText value="#{car.code}" />
       </rich:column>
      
       <rich:column sortBy="#{car.immatriculation}">
       <f:facet name="header">
       <h:outputText value="Immatriculation" />
       </f:facet>
       <h:outputText value="#{car.immatriculation}" />
       </rich:column>
      
       </rich:scrollableDataTable>
      </h:form>
      
      //--------------------------------------------------------------------------------
      code java of TableBean
      //--------------------------------------------------------------------------------
      
      import java.util.ArrayList;
      import java.util.List;
      
      import org.jboss.seam.ScopeType;
      import org.jboss.seam.annotations.Name;
      import org.jboss.seam.annotations.Scope;
      
      @Name("tableBean")
      @Scope(ScopeType.SESSION)
      public class TableBean {
      
       private List<CarBean> cars;
      
       public List<CarBean> getCars() {
       if (cars==null){
       cars = new ArrayList<CarBean>();
       for(int id=0;id<1000 ;id++)
       cars.add(new CarBean(id,999-id,id+"BB"+(999-id)));
       }
       return this.cars;
       }
      
      }
      
      //--------------------------------------------------------------------------------
      code java of CarBean
      //--------------------------------------------------------------------------------
      
      public class CarBean {
      
       private long id;
       private long code;
       private String immatriculation;
      
       public CarBean(long id, long code, String immatriculation){
       this.id=id;
       this.code=code;
       this.immatriculation=immatriculation;
       }
      
       public long getCode() {
       return code;
       }
      
       public void setCode(long code) {
       this.code = code;
       }
      
       public long getId() {
       return id;
       }
      
       public void setId(long id) {
       this.id = id;
       }
      
       public String getImmatriculation() {
       return immatriculation;
       }
      
       public void setImmatriculation(String immatriculation) {
       this.immatriculation = immatriculation;
       }
      
      }