1 Reply Latest reply on Nov 21, 2012 7:46 AM by Misha Stankovic

    rich:dataTable builtin sort does not work

    mabu2 Newbie

      Hi,

       

      I would like to have a table with 2 columns, the first colum should be sortable. So I wrote this 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:h="http://java.sun.com/jsf/html"

            xmlns:a4j="http://richfaces.org/a4j"

            xmlns:rich="http://richfaces.org/rich"

            xmlns:f="http://java.sun.com/jsf/core"

            xmlns:ui="http://java.sun.com/jsf/facelets">

      <h:head>

          <link href="styles/styles.css" rel="stylesheet" type="text/css" />

      </h:head>

      <h:body>

          <f:loadBundle basename="afs.message" var="msg" />

       

          <rich:dataTable value="#{userBean.allUserItems}" var="userentry" id="usertable" style="height:300px; width:300px;">

              <rich:column sortable="true" sortBy="#{userentry.fullName}">

                  <f:facet name="header">

                      <h:outputText value="#{msg.lbl_name}" />

                  </f:facet>

                  <h:outputText value="#{userentry.fullName}" />

              </rich:column>

              <rich:column>

                  <f:facet name="header">

                      <h:outputText value="#{msg.lbl_id}" />

                  </f:facet>

                  <h:outputText value="#{userentry.id}" />

              </rich:column>

          </rich:dataTable>

      </h:body>

      </html>

       

      This works well except the sort feature. Nothing happens when I click on the column header. The generated html is this:

       

      <body>

        <table id="usertable" class="rf-dt" style="height:300px; width:300px;">

           <colgroup span="2"></colgroup>

              <thead id="usertable:th" class="rf-dt-thd">

                <tr id="usertable:ch" class="rf-dt-shdr">

                           <th class="rf-dt-shdr-c" scope="col" id="usertable:j_idt22">Name</th>

                  <th class="rf-dt-shdr-c" scope="col" id="usertable:j_idt9">ID</th>

                </tr>

              </thead>.....

       

      So it is clear, that nothing happens, because there is no onclick attribute or any other element which could react to a mouse click. But why?

       

      My environment:

      • Tomcat 7.0.28 Java with JRE 1.6.0_30
      • Eclipse Indigo

       

      Thanks in advance

      mabu2

        • 1. Re: rich:dataTable builtin sort does not work
          Misha Stankovic Newbie

          I have the same problem with RichFaces 4.2.3-Final running on Tomcat 7 and Mojarra 2.1.14.

          The data is displayed OK, but no sorting links in the header nor in the generated HTML.

          My xhtml is as below: 

           

           

          <rich:dataTable value="#{propertySearch.properties}" var="property">

               <rich:column sortBy="#{property.id}" Sorted="true">

                    <f:facet name="header">ID</f:facet>

                    <h:outputText value="#{property.id}" />

              </rich:column>          

              <rich:column sortBy="#{property.propertyType}">

                    <f:facet name="header">Property Type</f:facet>

                    <h:outputText value="#{property.propertyType}" /></rich:dataTable>

              </rich:column>

          </rich:dataTable>

           

          Does anyone have sorting working in this version of RichFaces?