4 Replies Latest reply on Mar 30, 2009 3:46 PM by scott duke

    Using sort.xhtml in dataTable

    scott duke Novice

      I am trying to switch over to use the sort.xhtml, but I am having a problem. It does not seem to change the initial sort I have defined in my java class. It just executes the original query.


      Here is a portion of the dataTable.


                  <rich:dataTable id="phoneList" 
                                 var="_phone"
                             value="#{phoneList.resultList}" 
                           rendered="#{not empty phoneList.resultList}">
                           
                     <h:column>
                          <f:facet name="header">
                               <s:decorate template="/layout/sort.xhtml">
                                    <ui:param name="entityList" value="#{phoneList}"/>
                                    <ui:param name="propertyLabel" value="Company"/>
                                    <!-- doesn't support two sort fields -->
                                    <ui:param name="propertyPath" value="uzer.company"/>
                               </s:decorate>
                          </f:facet>
                       #{_phone.uzer.company}
                     </h:column>               
                                          
                   <h:column>
                        <f:facet name="header">
                           <a4j:htmlCommandLink styleClass="columnHeader" reRender="phoneList"
                                             value="Name #{phoneList.order=='uzer.name asc' ? messages.down : ( phoneList.order=='uzer.name desc' ? messages.up : '' )}">
                               <f:param name="phoneListOrder" value="#{phoneList.order=='uzer.name asc' ? 'uzer.name desc' : 'uzer.name asc'}"/>
                           </a4j:htmlCommandLink>
                       </f:facet>
                       #{_phone.uzer.name}
                     </h:column>                     
                     
                   <h:column>
                       <f:facet name="header">
                           <a4j:htmlCommandLink styleClass="columnHeader" reRender="phoneList"
                                             value="Type #{phoneList.order=='type asc' ? messages.down : ( phoneList.order=='type desc' ? messages.up : '' )}">
                               <f:param name="phoneListOrder" value="#{phoneList.order=='type asc' ? 'type desc' : 'type asc'}"/>
                           </a4j:htmlCommandLink>
                       </f:facet>
                       #{_phone.type}
                   </h:column>   
      
                     <h:column>
                          <f:facet name="header">
                               <s:decorate template="/layout/sort.xhtml">
                                    <ui:param name="entityList" value="#{phoneList}"/>
                                    <ui:param name="propertyLabel" value="Number"/>
                                    <!-- doesn't support two sort fields -->
                                    <ui:param name="propertyPath" value="phone.phoneNumber"/>
                               </s:decorate>
                          </f:facet>
                       #{_phone.phoneNumber}
                     </h:column>          
      
                     <h:column>
                          <f:facet name="header">               
                             <ui:include src="/layout/sort.xhtml">
                                    <ui:param name="entityList" value="#{personList}"/>
                                    <ui:param name="propertyLabel" value="Number"/>
                                    <ui:param name="propertyPath" value="phone.phoneNumber"/>
                               </ui:include>
                          </f:facet>
                       #{_phone.phoneNumber}
                     </h:column>
                                     
                   <h:column>
                       <f:facet name="header">Action</f:facet>
                       <s:link view="/role/admin/#{empty from ? 'Phone' : from}.xhtml" 
                              value="Select" 
                                 id="phone"
                             propagation="none">                           
                            <f:param name="phoneFrom" 
                                   value="#{phoneFrom}"/>
                           <f:param name="phoneId" 
                                   value="#{_phone.id}"/>
                       </s:link>
                   </h:column>
                            
                  </rich:dataTable>
      




      The PhoneList.java:


      @Name("phoneList")
      public class PhoneList extends EntityQuery<Phone>
      {
           private static final long serialVersionUID = -8080460493565303154L;
      
           private static final String[] RESTRICTIONS = {
                // tab list selection
                "phone.uzer.id = #{uzerHome.uzerId}",
                // non-tab list selection
                "lower(phone.uzer.company) like concat(lower(#{phoneList.phone.uzer.company}),'%')",
                "lower(phone.uzer.name) like concat(lower(#{phoneList.phone.uzer.name}),'%')",
                "lower(phone.type) like concat(lower(#{phoneList.phone.type}),'%')",
                "lower(phone.phoneNumber) like concat(lower(#{phoneList.phone.phoneNumber}),'%')",
                "lower(phone.ext) like concat(lower(#{phoneList.phone.ext}),'%')",
                };
           
           private Phone phone = new Phone();
           
           public PhoneList()
          {
                this.setMaxResults(25);
              this.setEjbql("select phone from Phone phone");
                this.setOrder("phone.type asc");
                this.setRestrictionExpressionStrings(Arrays.asList(RESTRICTIONS));
          }
      
           public Phone getPhone() {
                return phone;
           }
           
      }
      



      Could someone please tell me what I am doing wrong?


      Thanks,
      Scott