6 Replies Latest reply on Oct 12, 2006 8:05 PM by trouby

    Partial load of data for DataTable

    gvl

      I am using JBoss 4.0.4, ejb38, myfaces 1.1.3 and tomahawk 1.1.3 and ofcourse Seam 1.0.1

      I have a data table that loads from a large table. What I would like to do is only load the rows that are currently visible by the data scroller page. I can see two ways of doing this:

      1) Use a custom made data model (as in http://wiki.apache.org/myfaces/WorkingWithLargeTables) where I would only load the data as per page and bind that to the data table tag instead of the list of entities that are set now in the value attribute. However I'm not sure how this will interact with Seam, especially the DataModel tag, which as I understand it requires a List of entities to work with and the DataModelSelection tag.

      2) The other way is to provide a custom made data scroller. In this case only one page of data will be read from the database per time and set as the list of entities that Seam expects for the DataModel, then I'll use an action listener to receive events when the user selects a page to view or scrolls by using the arrows and so I'll know which part of data I need to read from the database. The role of the custom data scroller will be then to return the total number of rows of the table in the database (instead of the number of rows shown) and the resulting number of pages.

      Has anyone looked at this? I would appreciate any ideas or even some example code :-)

      --
      George

        • 1. Re: Partial load of data for DataTable
          pmuir

          Why not load all the rows at the start of a conversation and then only display the ones needed - avoids too many dataloads (which I would assume you are trying to avoid) and means you can use @DataModel/@DataModelSelection. Or perhaps you could lazy load the data - when the next button is pressed check whether you have the needed rows loaded from the database, and if they aren't, load them.

          • 2. Re: Partial load of data for DataTable
            gvl

            Thank you for your reply,

            My goal here is to avoid loading a large batch of data all at once and do a lazy load as you say.

            So I tried to attach an action listener on the scroller and catch when a user hits the forward button. However I got the following NullPointerException:

            java.lang.NullPointerException
             at org.jboss.ejb3.entity.ExtendedEntityManager.getPersistenceContext(ExtendedEntityManager.java:59)
             at org.jboss.ejb3.entity.ExtendedEntityManager.createNamedQuery(ExtendedEntityManager.java:134)
             at gr.aegek.invent.business.BrowseBean.loadEntities(BrowseBean.java:278)
             at gr.aegek.invent.business.BrowseBean.loadAll(BrowseBean.java:243)
             at gr.aegek.invent.business.material.BrowseMaterialsBean.load(BrowseMaterialsBean.java:129)
             at gr.aegek.invent.business.ScrollerActionListener.processAction(ScrollerActionListener.java:43)
             at javax.faces.event.ActionEvent.processListener(ActionEvent.java:48)
             at javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:484)
             at org.apache.myfaces.custom.datascroller.HtmlDataScroller.broadcast(HtmlDataScroller.java:104)
             at javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:94)
             at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:168)
             at org.apache.myfaces.lifecycle.LifecycleImpl.invokeApplication(LifecycleImpl.java:343)
             at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:86)
             at javax.faces.webapp.FacesServlet.service(FacesServlet.java:137)
             at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
             at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
             at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:144)
             at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
             at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
             at org.jboss.seam.servlet.SeamRedirectFilter.doFilter(SeamRedirectFilter.java:30)
             at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
             at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
             at org.jboss.seam.servlet.SeamExceptionFilter.doFilter(SeamExceptionFilter.java:45)
             at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
             at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
             at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
             at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
             at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
             at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
             at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
             at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
             at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
             at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
             at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
             at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
             at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
             at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
             at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
             at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
             at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
             at java.lang.Thread.run(Thread.java:595)
            


            I am using an extended entity manager:

             @PersistenceContext (type=PersistenceContextType.EXTENDED)
             protected EntityManager manager;
            


            I am not quite sure what is wrong then here!



            • 3. Re: Partial load of data for DataTable
              pmuir

              Looks to me that call isn't going through EJB. You seem to have a chain of methods being called - are you injecting them? Can you post code?

              • 4. Re: Partial load of data for DataTable
                gvl

                Yup,

                that was the problem, the methods were called directly from one object to the other.

                Thanx
                --
                George

                • 5. Re: Partial load of data for DataTable
                  wjmca

                  We are trying to do the same thing and just aren't getting something, any chance you can provide your before and after code snippets... Thanks!

                  • 6. Re: Partial load of data for DataTable
                    trouby

                    Hey,

                    Is there any examples of this? I'd like to do exactly the same with Tomahawk datatable !


                    Thanks