6 Replies Latest reply on Jan 26, 2011 8:36 AM by ssilvert

    Error while using SerializableDataModel in rich:dataTable

    testvogel

      Hi,

       

      I'm using a custom SerializableDataModel to realize a pagination in a rich:dataTable

       

      The xhtml code:

       

      <rich:dataTable id="udm" value="#{userDataModel}"

       

      code of the bean:

       

      public class UserPaginationDataModel extends PaginatingDataModel<IUser, Integer> implements Serializable {
      ...
      }

       

      PaginationDataModel is an extension of SerializableDataModel

       

      public abstract class PaginatingDataModel<T, U> extends SerializableDataModel implements Modifiable{
      ...
      }

       

      Well, the problem is that in my tests this dataTable always throw an exception because of the value parameter.

      For the exception look here: http://community.jboss.org/message/579515#579515 (Unfortunately the implementation has no errors :/ )

       

      I think HTMLUnit / JSFUnit is looking for a value with @DataModel annotation in the bean, but because we're using the SerializableDataModel there is no annotation.

       

      Any workaround how we can write tests for a dataTable which is filled by a SerializableDataModel?

       

      greets,

      ole

        • 1. Error while using SerializableDataModel in rich:dataTable
          ssilvert

          From the stack trace, this looks like a client side thing.  Nothing is looking for an annotation.  It's processing javascript and not java.

           

          Sorry I can't tell you more than I did before.  It's either a problem with HTMLUnit or your application.

           

          Stan

          • 2. Error while using SerializableDataModel in rich:dataTable
            testvogel

            Then it is a problem with HtmlUnit because in the application the dataTable is working fine without any javascript errors.

            • 3. Re: Error while using SerializableDataModel in rich:dataTable
              testvogel

              Hi,

               

              now I have identified the problem.

              HtmlUnit is calling a method in our custom PaginationDataModel that we dont use and this method throws an exception. In the real application this method is never called (I dont't get the exception).

               

              Stack Trace:

               

              Caused by: java.lang.UnsupportedOperationException

                  at com.baseclasses.PaginatingDataModel.setRowIndex(PaginatingDataModel.java:137)

                  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:597)

                  at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)

                  at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:32)

                  at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)

                  at org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:28)

                  at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)

                  at org.jboss.seam.core.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:77)

                  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:185)

                  at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:103)

                  at com.gui.admin.impl.UserPaginationDataModel_$$_javassist_seam_37.setRowIndex(UserPaginationDataModel_$$_javassist_seam_37.java)

                  at org.ajax4jsf.component.UIDataAdaptor.setRowIndex(UIDataAdaptor.java:289)

                  at org.jboss.jsfunit.jsfsession.ClientIDs.addUIData(ClientIDs.java:133)

                  at org.jboss.jsfunit.jsfsession.ClientIDs.addAllIDs(ClientIDs.java:80)

                  at org.jboss.jsfunit.jsfsession.ClientIDs.addAllIDs(ClientIDs.java:88)

                  at org.jboss.jsfunit.jsfsession.ClientIDs.addAllIDs(ClientIDs.java:88)

                  at org.jboss.jsfunit.jsfsession.ClientIDs.addAllIDs(ClientIDs.java:88)

                  at org.jboss.jsfunit.jsfsession.ClientIDs.<init>(ClientIDs.java:67)

                  at org.jboss.jsfunit.jsfsession.JSFServerSession.pageCreated(JSFServerSession.java:223)

                  at org.jboss.jsfunit.jsfsession.JSFServerSession.afterRequest(JSFServerSession.java:235)

                  at org.jboss.jsfunit.framework.JSFUnitWebConnection.notifyListenersAfter(JSFUnitWebConnection.java:101)

                  at org.jboss.jsfunit.framework.JSFUnitWebConnection.getResponse(JSFUnitWebConnection.java:83)

                  at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseFromWebConnection(WebClient.java:1405)

                  at com.gargoylesoftware.htmlunit.WebClient.loadWebResponse(WebClient.java:1324)

                  at com.gargoylesoftware.htmlunit.WebClient.download(WebClient.java:2082)

                  at com.gargoylesoftware.htmlunit.javascript.host.Location.jsxSet_href(Location.java:206)

                  at com.gargoylesoftware.htmlunit.javascript.host.Window.jsxSet_location(Window.java:534)

                  at sun.reflect.GeneratedMethodAccessor1321.invoke(Unknown Source)

                  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

                  at java.lang.reflect.Method.invoke(Method.java:597)

                  at net.sourceforge.htmlunit.corejs.javascript.MemberBox.invoke(MemberBox.java:172)

                  ... 110 more

               

               

              This exception is expected because the code in PaginationDataModel is

                  @Override
                  public void setRowIndex(final int rowIndex) {
                      throw new UnsupportedOperationException();
              
                  }
              

               

              Any ideas why this is working in the real application and not in HtmlUnit?

              • 4. Error while using SerializableDataModel in rich:dataTable
                ssilvert

                That stack trace is coming from JSFUnit after all.  On the server side, JSFUnit will build a list of all the Client IDs.  To do that it must iterate through your UIData component.  Thus, it needs to call setRowIndex.

                 

                Can you implement setRowIndex()?

                 

                Stan

                • 5. Error while using SerializableDataModel in rich:dataTable
                  testvogel

                  Hi Stan,

                   

                  yes it's no problem to replace "throw UnsupportedException" with "return;" but it doesnt make sense to me that I have to change some code in my application to run the tests. In the running application all works fine and the view will be loaded. In the tests the view won't be loaded also if I set setThrowExceptionOnScriptError(false);.

                   

                  Is there any possibilty to catch the exception and continue loading the view? Maybe something like continueOnException()? Otherwise I have to fill the methods with not needed dummy data :/

                   

                  greets,

                  ole

                  • 6. Error while using SerializableDataModel in rich:dataTable
                    ssilvert

                    You could look at it another way.  JSFUnit has exposed a bug in your code.  The setRowIndex() is not an optional method.  It needs some sort of implementation because there is no guarantee in the future that JSF itself will never need to call it.

                     

                    I do see your point too.  But JSFUnit has to rely on the JSF API to do its job.

                     

                    Stan