9 Replies Latest reply on Apr 13, 2010 11:07 AM by nbelaevski

    rich:dataTable synchronization problem

    g4j

      Hi,

       

      I open firefox window with the rich:dataTable information on screen and minimize it. This is SCREEN1.

       

      Now, I open ANOTHER whatever screen, called by SCREEN2, and create new row data (new record) that appears on rich:datatable's first position. The rich:displayTable displays new record normally.

       

      Returning at SCREEN1, I click on row data that would appear after  when "managedbean" recover the wrong data (data from other record).

        • 1. Re: rich:dataTable synchronization problem
          nbelaevski

          Hi Gerson,

           

          I guess bean scope is "session".

           

          So here are some possible ways to solve the problem:

           

          - Make list conversation-scoped (requires Seam)

          - Use Seam's entity converter as rowKeyConverter for data table

          - Implement custom data model for the table that will use persistent identifiers as row keys (take a look at RichFaces livedemo demos)

          - Put list into conversation scope or use a4j:keepAlive

          • 2. Re: rich:dataTable synchronization problem
            g4j

            Nick Belaevski wrote:

             

            Hi Gerson,

             

            I guess bean scope is "session".

             

            So here are some possible ways to solve the problem:

             

            - Make list conversation-scoped (requires Seam)

            - Use Seam's entity converter as rowKeyConverter for data table

            - Implement custom data model for the table that will use persistent identifiers as row keys (take a look at RichFaces livedemo demos)

            - Put list into conversation scope or use a4j:keepAlive

             

            Hi Nick!

             

            My scope isn't session.

             

            I use richfaces + spring + hibernate. My beans are managed by Spring via org.springframework.web.jsf.DelegatingVariableResolver.

             

            The bean is defined as:

            <bean id="countryMBean" class="com.tti.hd3web.register.faces.CountryManagedBean"></bean>
            

             

            The .xhml and .java bean were attached.

             

            Thanks in advance!

            • 3. Re: rich:dataTable synchronization problem
              g4j

              Nick Belaevski wrote:

               

              Hi Gerson,

               

              I guess bean scope is "session".

               

              So here are some possible ways to solve the problem:

               

              - Make list conversation-scoped (requires Seam)

              - Use Seam's entity converter as rowKeyConverter for data table

              - Implement custom data model for the table that will use persistent identifiers as row keys (take a look at RichFaces livedemo demos)

              - Put list into conversation scope or use a4j:keepAlive

               

               

              I saw the example. My implementation looks like livedemo, but, live demo doesn't use database and the data are randomized. When open the other window, the data are not the same.

               

              Somebody tested the livedemo example with database and opening more than one window? I would like to know.

              • 4. Re: rich:dataTable synchronization problem
                nbelaevski
                <bean id="countryMBean"></bean>
                

                 

                This means that bean is singleton (or application-scoped). Are you completely sure about the scope chosen?

                 

                You can try this example implemented using Seam entity converter: http://livedemo.exadel.com/richfaces-demo/richfaces/dataTable.jsf?tab=modifiableDataModel&cid=15287491

                • 5. Re: rich:dataTable synchronization problem
                  g4j

                  oh damn! It's true. The default scope of spring bean is singleton. I going to change and test with scope="request".

                  • 6. Re: rich:dataTable synchronization problem
                    g4j

                    Hi Nick,

                     

                    I changed scope to "request" and the related problem is persistent.

                     

                     

                     

                    Nick Belaevski wrote:


                    You can try this example implemented using Seam entity converter: http://livedemo.exadel.com/richfaces-demo/richfaces/dataTable.jsf?tab=modifiableDataModel&cid=15287491

                     

                    I don't see how this sample can help me. Anybody have a trick, or example?

                     

                    My functionality is identical to this sample:

                    http://livedemo.exadel.com/richfaces-demo/richfaces/dataTable.jsf?tab=editDataTable&cid=15389267

                     

                    but synchronization problem is recurrent.

                    • 7. Re: rich:dataTable synchronization problem
                      nbelaevski

                      The example has the following attribute: rowKeyConverter="org.jboss.seam.ui.EntityConverter". This attaches Seam entity converter that involves one of Seam's extended scopes to preserve persistent IDs for used DB entities.

                      • 8. Re: rich:dataTable synchronization problem
                        g4j

                        i tried that. Only adding the attribute don't solves. When adding rowKeyConverter attribute, i've got the exception below. Need i implement something more beyond the attribute?

                         

                        My datatable:

                         

                        <rich:dataTable rowKeyConverter="org.jboss.seam.ui.EntityConverter" value="#{countryMBean.list}" styleClass="dataTable" var="country" rows="13" id="countryDataTableList" reRender="dataScrollerList">
                        

                         

                        value="#{countryMBean.list}" gets the data from getList method:

                         

                         

                        public List<Country> getList() { ... } 
                        

                         

                        StackTrace:

                         

                        java.lang.RuntimeException: exception invoking: getTransaction
                             at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:148)
                             at org.jboss.seam.Component.callComponentMethod(Component.java:2201)
                             at org.jboss.seam.Component.unwrap(Component.java:2227)
                             at org.jboss.seam.Component.getInstance(Component.java:1994)
                             at org.jboss.seam.Component.getInstance(Component.java:1957)
                             at org.jboss.seam.Component.getInstance(Component.java:1951)
                             at org.jboss.seam.Component.getInstance(Component.java:1924)
                             at org.jboss.seam.Component.getInstance(Component.java:1919)
                             at org.jboss.seam.transaction.Transaction.instance(Transaction.java:36)
                             at org.jboss.seam.util.Work.workInTransaction(Work.java:34)
                             at org.jboss.seam.transaction.TransactionInterceptor.aroundInvoke(TransactionInterceptor.java:34)
                             at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                             at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:44)
                             at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
                             at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
                             at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:166)
                             at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:102)
                             at org.jboss.seam.ui.JpaEntityLoader_$$_javassist_1.put(JpaEntityLoader_$$_javassist_1.java)
                             at org.jboss.seam.ui.EntityConverter.getAsString(EntityConverter.java:67)
                             at org.ajax4jsf.component.UIDataAdaptorBase.getClientId(UIDataAdaptorBase.java:715)
                             at javax.faces.component.UIComponent.getContainerClientId(UIComponent.java:363)
                             at javax.faces.component.UIComponentBase.getClientId(UIComponentBase.java:279)
                             at org.richfaces.renderkit.CellRenderer.doEncodeBegin(CellRenderer.java:66)
                             at org.ajax4jsf.renderkit.RendererBase.encodeBegin(RendererBase.java:100)
                             at javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:813)
                             at org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:275)
                             at org.richfaces.renderkit.AbstractRowsRenderer.encodeCellChildren(AbstractRowsRenderer.java:288)
                             at org.richfaces.renderkit.AbstractTableRenderer.encodeOneRow(AbstractTableRenderer.java:391)
                             at org.richfaces.renderkit.AbstractRowsRenderer.process(AbstractRowsRenderer.java:83)
                             at org.ajax4jsf.model.SequenceDataModel.walk(SequenceDataModel.java:101)
                             at org.ajax4jsf.component.UIDataAdaptorBase.walk(UIDataAdaptorBase.java:1156)
                             at org.richfaces.renderkit.AbstractRowsRenderer.encodeRows(AbstractRowsRenderer.java:104)
                             at org.richfaces.renderkit.AbstractRowsRenderer.encodeRows(AbstractRowsRenderer.java:88)
                             at org.richfaces.renderkit.AbstractTableRenderer.encodeTBody(AbstractTableRenderer.java:90)
                             at org.richfaces.renderkit.AbstractTableRenderer.encodeChildren(AbstractTableRenderer.java:97)
                             at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:837)
                             at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:234)
                             at com.sun.faces.renderkit.html_basic.GridRenderer.renderRow(GridRenderer.java:180)
                             at com.sun.faces.renderkit.html_basic.GridRenderer.encodeChildren(GridRenderer.java:127)
                             at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:837)
                             at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:234)
                             at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:239)
                             at com.sun.faces.renderkit.html_basic.GridRenderer.renderRow(GridRenderer.java:180)
                             at com.sun.faces.renderkit.html_basic.GridRenderer.encodeChildren(GridRenderer.java:127)
                             at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:837)
                             at javax.faces.component.UIComponent.encodeAll(UIComponent.java:930)
                             at javax.faces.component.UIComponent.encodeAll(UIComponent.java:933)
                             at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:592)
                             at org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:100)
                             at org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:176)
                             at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:110)
                             at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
                             at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
                             at javax.faces.webapp.FacesServlet.service(FacesServlet.java:266)
                             at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
                             at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
                             at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
                             at org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:51)
                             at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                             at org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:38)
                             at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                             at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:90)
                             at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                             at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
                             at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                             at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
                             at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                             at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:206)
                             at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
                             at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:388)
                             at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:515)
                             at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:56)
                             at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                             at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
                             at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
                             at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
                             at com.tti.richfaces.AuthenticationSessionFilter.doFilter(AuthenticationSessionFilter.java:46)
                             at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
                             at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
                             at com.tti.richfaces.AuthenticationSessionFilter.doFilter(AuthenticationSessionFilter.java:46)
                             at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
                             at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
                             at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
                             at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:172)
                             at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
                             at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
                             at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
                             at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
                             at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:875)
                             at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
                             at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
                             at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
                             at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
                             at java.lang.Thread.run(Thread.java:595)
                        Caused by: javax.naming.NamingException: Cannot create resource instance
                             at org.apache.naming.factory.TransactionFactory.getObjectInstance(TransactionFactory.java:113)
                             at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304)
                             at org.apache.naming.NamingContext.lookup(NamingContext.java:793)
                             at org.apache.naming.NamingContext.lookup(NamingContext.java:140)
                             at org.apache.naming.NamingContext.lookup(NamingContext.java:781)
                             at org.apache.naming.NamingContext.lookup(NamingContext.java:153)
                             at org.apache.naming.SelectorContext.lookup(SelectorContext.java:137)
                             at javax.naming.InitialContext.lookup(InitialContext.java:351)
                             at org.jboss.seam.transaction.Transaction.getUserTransaction(Transaction.java:79)
                             at org.jboss.seam.transaction.Transaction.createUTTransaction(Transaction.java:71)
                             at org.jboss.seam.transaction.Transaction.getTransaction(Transaction.java:44)
                             at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                             at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                             at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                             at java.lang.reflect.Method.invoke(Method.java:585)
                             at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
                             at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:138)
                             ... 93 more
                        • 9. Re: rich:dataTable synchronization problem
                          nbelaevski

                          Check this page: http://docs.jboss.org/seam/2.0.0.GA/reference/en/html/controls.html for documentation on s:entityConverter. It describes necessary configuration steps.