1 Reply Latest reply on Nov 25, 2010 3:32 AM by gerryjun

    Modify Seam-gen default column sorting to AJAX

    gerryjun

      Hi,


      Notes:
      Seam-gen generated
      Seam 2.2


            I need some help pls,  im trying to modify the sorting columns generated by seam-gen sortable via AJAX as per client requirement.


      My problem is, it would seem that the query is being generated before the sort and dir param could be set on the entityList component.


      Looking at the system.out on the getResultList() to print the orderColumn it still shows null, then after the query is generated, is the time that it gets the params for the filter.


      The list is being reRender with out a problme, i have verified that the params are bieng passed, it would seem its just late.


      How can i correct this?



      --------------- sort.xhtml --------------


      <ui:composition xmlns="http://www.w3.org/1999/xhtml">
          <a4j:commandLink  styleClass="columnHeader" value="#{propertyLabel} #{entityList.orderColumn == propertyPath ? (entityList.orderDirection == 'desc' ? messages.down : messages.up) : ''}" reRender="mainbody" ajaxSingle="true" >
              <a4j:actionparam name="sort" value="#{propertyPath}" assignTo="#{entityList.orderColumn}" />
              <a4j:actionparam name="dir" value="#{entityList.orderColumn == propertyPath and entityList.orderDirection == 'asc' ? 'desc' : 'asc'}" assignTo="#{entityList.orderDirection}"/>
              <s:conversationPropagation type="join" />  
          </a4j:commandLink>
      </ui:composition>
      



      ------------------ System out from entityList.getResultList() ------------------------------


      15:26:11,898 INFO  [STDOUT] (orderColumn from entityList getResultList()) null
      15:26:11,899 INFO  [STDOUT] Hibernate:
          select
              masteruser0_.UserType as UserType132_,
              masteruser0_.AccountingAccess as Accounti2_132_,
              masteruser0_.CaseAdminAccess as CaseAdmi3_132_,
              masteruser0_.CaseProcessAccess as CaseProc4_132_,
              masteruser0_.ClientAdminAccess as ClientAd5_132_,
              masteruser0_.EDDTechAccess as EDDTechA6_132_,
              masteruser0_.RecordActiveFlag as RecordAc7_132_,
              masteruser0_.SysAdminAccess as SysAdmin8_132_,
              masteruser0_.SystemRequiredFlag as SystemRe9_132_,
              masteruser0_.UserTypeDescription as UserTyp10_132_,
              masteruser0_.UserTypeShortName as UserTyp11_132_
          from
              edd_master.MasterUserType masteruser0_ limit ?
      15:26:11,925 INFO  [STDOUT] (orderColumn from entityList getResultList()) masterUserType.userType
      15:26:11,926 INFO  [STDOUT] (orderColumn from entityList getResultList()) masterUserType.userType
      15:26:11,926 INFO  [STDOUT] (orderColumn from entityList getResultList()) masterUserType.userType
      15:26:11,927 INFO  [STDOUT] (orderColumn from entityList getResultList()) masterUserType.userType
      15:26:11,928 INFO  [STDOUT] (orderColumn from entityList getResultList()) masterUserType.userType
      15:26:11,928 INFO  [STDOUT] (orderColumn from entityList getResultList()) masterUserType.userType
      15:26:11,928 INFO  [STDOUT] (orderColumn from entityList getResultList()) masterUserType.userType
      15:26:11,946 INFO  [STDOUT] (orderColumn from entityList getResultList()) masterUserType.userType
      15:26:11,946 INFO  [STDOUT] (orderColumn from entityList getResultList()) masterUserType.userType



        • 1. Re: Modify Seam-gen default column sorting to AJAX
          gerryjun

          Solved it my self, by overriding the getResultList method and setting it my self from the FacesContext were the params are available but not yet set on the EntityList.



          Seems to be a bug on the life cycled where param are being applied late in its cycle.


               @Override
               public List<MasterUserType> getResultList() {
                     this.setOrderColumn(FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("sort"));
                     this.setOrderDirection(FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("dir"));
                    return super.getResultList();
               }



          additional note: im using a4j:include to dynamically include the list view.


          Thanks