5 Replies Latest reply on May 28, 2009 2:02 AM by jFoundation java

    Pagination in Richfaces based Application Doesnt work on JBO

    jFoundation java Newbie

      We have extended the ExtendedDataModel to implement pagination,As in

      http://www.jboss.org/index.html?module=bb&op=viewtopic&t=115636

      Pagination works fine when my application is deployed on tomcat.

      when i deploy the same war on JBOSS 4.3,the datatable behaviour is strange.


      Scenario:

      I have a datatable in one of the pages of my application,the code for the same is as below.

      The datatable is rererendered by clicking a commandbutton.This is for search functionality,i load the data in the pagableDataModel in the backing bean,and rerender the table in the front end.

      xhtml paga code

      <rich:dataTable id="userGroupsList" rows="10"
      binding="#{backingBean.table}"
      value="#{backingBean.pagableDataModel}" var="groupDTO"
      rowKeyVar="rowIndex">

      pagableDataModel -> this is datamodel class which extends the ExtendedDataModel


      <a4j:commandButton reRender="userGroupsList"
      action="#{backingBean.onSearch}" value="Search" />


      Backing Bean code

      void onSearch {

      //this method in my backing bean loads the data in the pagableDataModel object

      groupDetailsList=(PagableList)fetchData(page);

      pagableDataModel.setPageData(groupDetailsList);

      }
      Since i am returning to the same page i am not returning a value,

      Observation1:

      On debug i found the behaviour as follows.


      when the page is loaded first time the walk method of my pagableDatamodel recieves values for all the arguments,so no issues.

      when i click the commandbutton to load data.i found that

      the walk method recives the last argument as null.

      ie public void walk(FacesContext context, DataVisitor visitor, Range range,
      Object argument) throws IOException

      here the argument -> comes as null...

      it expects a org.richfaces.renderkit.TableHolder object as argument at runtime.

      since the argument is null,my table doesnt get rerendered.


      Observation2:

      if i return a value from the onSearch Method and define the navigation rule to return to the same page then the whole page gets loaded,which is not desirable,but data gets loaded.


      Is this an issue with JBOSS ??As the same code works fine on Tomcat ?
      Richfaces jar versions 3.3.0

      JSF [jsf-api.jar/jsf-iml.jar] versions - JBOSS Provided [version :1.2_09-b02-FCS]

      Also tried to bundle the JSF [jsf-api.jar/jsf-iml.jar] versions - [version :1.2_07] inside the war,but the problem still persists.

        • 1. Re: Pagination in Richfaces based Application Doesnt work on
          jFoundation java Newbie

          Need Some Pointers...This is a stopper

          • 2. Re: Pagination in Richfaces based Application Doesnt work on
            Nick Belaevski Master

             

            when the page is loaded first time the walk method of my pagableDatamodel recieves values for all the arguments,so no issues.

            when i click the commandbutton to load data.i found that

            the walk method recives the last argument as null.

            ie public void walk(FacesContext context, DataVisitor visitor, Range range,
            Object argument) throws IOException

            here the argument -> comes as null...

            it expects a org.richfaces.renderkit.TableHolder object as argument at runtime.

            That's the expected behavior. TableHolder is necessary for rendering, but is not used from decoding/validating/etc., so argument passed is null.

            You can try enclosing table in the container component and re-render it.

            • 3. Re: Pagination in Richfaces based Application Doesnt work on
              jFoundation java Newbie

              thanks but thats not the issue..

              Details:
              As we are packaging our pages inside JAR ,we have used a custom resorce resolver,the code for the same is as below

              ------------------------------------------------------------------------------------
              public class JarletResourceResolver extends DefaultResourceResolver {


              public JarletResourceResolver() {
              super();
              }

              private String prefix = "/classlets/";

              public String getPrefix() {

              return prefix;
              }

              @Override
              public URL resolveUrl(String path) {
              URL url = null;
              String prefix = getPrefix();
              if (path != null && path.startsWith(prefix)) {
              url = getClass().getClassLoader().getResource(resolvedURL(path, prefix));

              } else if ((url = super.resolveUrl(path)) == null) {
              url = getClass().getClassLoader().getResource(path.substring(1));
              }

              if (log.ON)
              log.fine("Resolved URL" + url);
              return url;
              }

              private String resolvedURL(String path, String prefix){
              String resourceULR = path.substring(prefix.length());
              return resourceULR;
              }
              }

              ------------------------------------------------------------------------------------
              As we are using the resource resolver,we are packaging our jsf pages inside the JAR,it works fine on tomcat,when deployed on JBOSS ,many places rerender doesnt happen as expected .

              If i move my pages outside the JAR,it works fine...


              Is it something to do with my resolver ..or is it JBOSS ..as the same works fine on tomcat ?

              • 4. Re: Pagination in Richfaces based Application Doesnt work on
                Nick Belaevski Master

                Try using thread's context classloader.

                • 5. Re: Pagination in Richfaces based Application Doesnt work on
                  jFoundation java Newbie

                  I changed the code to use the current thread,as follows..

                  if (path != null && path.startsWith(prefix)) {

                  url = Thread.currentThread().getContextClassLoader().getResource(resolvedURL(path, prefix));

                  } else if ((url = super.resolveUrl(path)) == null) {

                  url = Thread.currentThread().getContextClassLoader().getResource(path.substring(1));

                  }

                  ..but that doesnt seem to be the issue,..i was able to find some error's w.r.t facelets

                  jw-admin-3.1.0.jar!/pages/master/MaintainUserGroups.xhtml] was modified @ 16:19:52, flushing component applied @ 16:19:50
                  16:19:52,054 ERROR [STDERR] 24-May-2009 16:19:52 com.sun.facelets.impl.DefaultFacelet refresh

                  even though i am not changing my xhtml page ..the page gets flushed..and refreshed


                  so i set the facelets.REFRESH_PERIOD to -1 ,which loads the facelet only once....now the data table rerender issue is solved ..but ..there are other issues with rerender creeping up...
                  in the same datatable i have a button for every row..on click i set a boolean flag in the dto.. and i rerender the table...so that the labels are now rendered as text fields..

                  ..i have a save button,once i click that i save the data..to the db..i return back the updated list with the boolean field as false and rerender the table,so that the editable text fields are back as labels,but the rerender doesnt happen as expected.the same stuff works on tomcat..so i am sure the bean has right values.

                  code for the above problem

                  <rich:dataTable id="userGroupsList" binding="#{maintainGroupsBean.table}"
                  value="#{maintainGroupsBean.pagableDataModel}" var="groupDTO"
                  rowKeyVar="rowIndex">

                  <a4j:support immediate="true" event="onRowClick"
                  onsubmit="changeColor(this)"
                  action="#{maintainGroupsBean.onSelectionChange}"
                  >
                  <a4j:actionparam name="value1" value="#{rowIndex}"
                  assignTo="#{maintainGroupsBean.selectedRow}" />
                  </a4j:support>
                  <f:facet name="header">
                  <rich:columnGroup>

                  <h:column>
                  <h:outputText styleClass="headerText"
                  value="#{maintainGroupsBean.resourceBundle['master.groupDescription']}" />
                  </h:column>
                  <h:column>
                  <h:outputText styleClass="headerText" value="Edit" />
                  </h:column>
                  </rich:columnGroup>
                  </f:facet>

                  <h:column>
                  <h:outputText value="#{groupDTO.userGroupDesc}"
                  rendered="#{(not groupDTO.altered)}" />
                  <h:inputText label="Group Description" required="true"
                  maxlength="90" value="#{groupDTO.userGroupDesc}"
                  rendered="#{groupDTO.altered}" />
                  </h:column>
                  <h:column>
                  <a4j:commandButton
                  reRender="userGroupsList"
                  action="#{maintainGroupsBean.onEdit}" value="Edit"
                  disabled="#{(maintainGroupsBean.inNewMode and groupDTO.altered) or
                  (maintainGroupsBean.inEditMode and groupDTO.altered)}"
                  image="/images/icons/edit.gif">
                  <a4j:actionparam noEscape="true" name="codeValue1"
                  value="#{rowIndex}" assignTo="#{maintainGroupsBean.selectedRow}" />
                  </a4j:commandButton>


                  </h:column>
                  </rich:dataTable>


                  code for the save button

                  <a4j:commandButton id="saveButton" eventsQueue="saveButtonQ"
                  ignoreDupResponses="true"
                  reRender="userGroupsList"
                  action="#{maintainGroupsBean.onSave}" value="Save"
                  />