7 Replies Latest reply on Feb 23, 2011 7:28 AM by flaviohenrique

    Richfaces 4 M6: second click in sortable header don´t work

    flaviohenrique

      I followed the showcase and now I am able to sort, BUT if I click twice, only the first click is processed. I also find a strange behavior. There are many calls to action="#{meuMB.sortByNome}" when the column header is clicked. I didn´t understand why this method must be void, since JSF action method allways return a String. By the way, I also tried to change this but the problem still occurs. This problem affected all browsers.

       

      ManagedBean code related to sorting:

       

      (...)

      private SortOrder nomeOrder = SortOrder.unsorted;

       

          public void sortByNome(){

               if (this.nomeOrder.equals(SortOrder.ascending)) {

                this.nomeOrder = SortOrder.descending;

               } else {

                   this.nomeOrder = SortOrder.ascending;

               }

          }

       

       

      Page code:

       

      ?xml version="1.0" encoding="UTF-8" ?>

      <!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: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">

      <h:head>

      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

      </h:head>

      <h:body>

      <h:form>

        <rich:dataTable id="tabela" value="#{meuMB.pessoas}" var="pessoa" rows="5"

         noDataLabel="Não há dados" sortMode="single">

         <rich:column id="a1" sortBy="#{pessoa.nome}"

         sortOrder="#{meuMB.nomeOrder}">

          <f:facet name="header">

           <a4j:commandLink value="Nome" render="tabela"

            action="#{meuMB.sortByNome}" />

          </f:facet>

          <h:outputText value="#{pessoa.nome}" />

         </rich:column>

         <rich:column>

          <f:facet name="header">

           <h:outputLabel value="Idade" />

          </f:facet>

          <h:outputText value="#{pessoa.idade}" />

         </rich:column>

         <f:facet name="footer">

          <rich:dataScroller />

         </f:facet>

        </rich:dataTable>

      </h:form>

      </h:body>

      </html>