10 Replies Latest reply on May 9, 2008 11:39 AM by gabir gabirad

    java.lang.ClassCastException: java.util.ArrayList using rich:listShuttle

    gabir gabirad Newbie

      Hi guys,


      I have a problem using listShuttle from RichFaces (3.1.14 and Jboss 4.2.2).


      I have something like this :


           @DataModel
           List<Agent> agents;
           
           @DataModelSelection(value="agents")
           List<Agent> selectedAgents;
           
              @Begin(join=true) @Factory("agents")
           public List<Agent> getAgents() {
                
                return agentService.getAgentsList();
           }
      


      And the xhtml :



      <rich:panel>
                                    <f:facet name="header">Add / Edit Group Type</f:facet>
                               <div class="dialog"><h:panelGrid columns="2"
                                    rowClasses="prop" columnClasses="name,description">
                          
      
                               <rich:listShuttle id="useracc" sourceValue="#{agents}"
                                    targetValue="#{selectedAgents}" var="agent"
                                    listHeight="300" listWidth="300"
                                    sourceCaptionLabel="Available Agents"
                                    targetCaptionLabel="Currently Selected Agents"
                                    converter="agentConverter">
                                    <rich:column >
      
                                         <h:outputText value="#{agent.loginName}" />
      
                                    </rich:column>
      
                               </rich:listShuttle>
                               </h:panelGrid></div>
                          </rich:panel>



      The 'agents' list is populated correctly on page but when I'm selecting one agent I'm getting this error :

      java.lang.ClassCastException: java.util.ArrayList
              at org.jboss.seam.databinding.DataModelBinder.getSelection(DataModelBinder.java:14)
              at org.jboss.seam.Component.injectDataModelSelection(Component.java:1497)
              at org.jboss.seam.Component.injectDataModelSelections(Component.java:1478)
              at org.jboss.seam.Component.inject(Component.java:1417)
              at org.jboss.seam.core.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:45)
              at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
              at org.jboss.seam.core.ConversationInterceptor.aroundInvoke(ConversationInterceptor.java:56)
              at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
              at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:42)
              at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
              at org.jboss.seam.core.SynchronizationInterceptor.aroundInvoke(SynchronizationInterceptor.java:32)
              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 com.spinvox.webui.logic.GroupAction_$$_javassist_3.getAgents(GroupAction_$$_javassist_3.java)
              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:21)
              at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:125)
              at org.jboss.seam.Component.callComponentMethod(Component.java:2082)
              at org.jboss.seam.Component.getInstanceFromFactory(Component.java:1926)
              at org.jboss.seam.Component.getInstance(Component.java:1863)
              at org.jboss.seam.Component.getInstance(Component.java:1840)
              at org.jboss.seam.Namespace.getComponentInstance(Namespace.java:55)
              at org.jboss.seam.Namespace.getComponentInstance(Namespace.java:50)
              at org.jboss.seam.el.SeamELResolver.resolveBase(SeamELResolver.java:166)
              at org.jboss.seam.el.SeamELResolver.getValue(SeamELResolver.java:53)
              at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:53)
              at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:64)
              at org.jboss.el.parser.AstIdentifier.getValue(AstIdentifier.java:44)
              at org.jboss.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
              at com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:71)
              at javax.faces.component.ValueBindingValueExpressionAdapter.getValue(ValueBindingValueExpressionAdapter.java:102)
              at org.richfaces.component.UIListShuttle.getSourceValue(UIListShuttle.java:293)
              at org.richfaces.component.UIListShuttle.createDataModel(UIListShuttle.java:356)
              at org.ajax4jsf.component.UIDataAdaptor.getExtendedDataModel(UIDataAdaptor.java:592)
              at org.ajax4jsf.component.UIDataAdaptor.walk(UIDataAdaptor.java:994)
              at org.richfaces.renderkit.AbstractRowsRenderer.encodeRows(AbstractRowsRenderer.java:107)
              at org.richfaces.renderkit.ListShuttleRendererBase.encodeRows(ListShuttleRendererBase.java:100)
              at org.richfaces.renderkit.html.ListShuttleRenderer.doEncodeChildren(ListShuttleRenderer.java:244)
              at org.richfaces.renderkit.html.ListShuttleRenderer.doEncodeChildren(ListShuttleRenderer.java:234)
              at org.richfaces.renderkit.ListShuttleRendererBase.encodeChildren(ListShuttleRendererBase.java:227)
              at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:812)
              at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:271)
              at com.sun.faces.renderkit.html_basic.GridRenderer.encodeChildren(GridRenderer.java:242)
              at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:812)
              at org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:282)
              at org.ajax4jsf.renderkit.RendererBase.renderChildren(RendererBase.java:262)
              at org.richfaces.renderkit.html.PanelRenderer.doEncodeChildren(PanelRenderer.java:199)
              at org.richfaces.renderkit.html.PanelRenderer.doEncodeChildren(PanelRenderer.java:194)
              at org.ajax4jsf.renderkit.RendererBase.encodeChildren(RendererBase.java:121)
              at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:812)
              at org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:282)
              at org.ajax4jsf.renderkit.RendererBase.renderChildren(RendererBase.java:262)
              at org.ajax4jsf.renderkit.html.AjaxOutputPanelRenderer.encodeChildren(AjaxOutputPanelRenderer.java:79)
              at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:812)
              at javax.faces.component.UIComponent.encodeAll(UIComponent.java:886)
              at javax.faces.render.Renderer.encodeChildren(Renderer.java:137)
              at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:812)
              at javax.faces.component.UIComponent.encodeAll(UIComponent.java:886)
              at javax.faces.component.UIComponent.encodeAll(UIComponent.java:892)
              at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:592)
              at org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:108)
              at org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:216)
              at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:106)
              at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
              at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144)
              at javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
              at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
              at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:85)
              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:141)
              at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:281)
              at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:60)
              at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
              at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58)
              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:235)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
              at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
              at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
              at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
              at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
              at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
              at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
              at org.apache.catalina.core.StandardHostValve.invoke(Stan
      16:48:50,024 ERROR [STDERR] dardHostValve.java:127)
              at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
              at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
              at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
              at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
              at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
              at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
              at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
              at java.lang.Thread.run(Thread.java:595)
      16:48:54,006 WARN  [lifecycle] executePhase(RENDER_RESPONSE 6,com.sun.faces.context.FacesContextImpl@11ef77f) threw exception
      java.lang.ClassCastException: java.util.ArrayList
              at org.jboss.seam.databinding.DataModelBinder.getSelection(DataModelBinder.java:14)
              at org.jboss.seam.Component.injectDataModelSelection(Component.java:1497)
              at org.jboss.seam.Component.injectDataModelSelections(Component.java:1478)
              at org.jboss.seam.Component.inject(Component.java:1417)
              at org.jboss.seam.core.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:45)
              at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
              at org.jboss.seam.core.ConversationInterceptor.aroundInvoke(ConversationInterceptor.java:65)
              at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
              at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:42)
              at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
              at org.jboss.seam.core.SynchronizationInterceptor.aroundInvoke(SynchronizationInterceptor.java:32)
              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 com.spinvox.webui.logic.GroupAction_$$_javassist_3.toString(GroupAction_$$_javassist_3.java)
              at com.sun.facelets.util.DevTools.writeVariables(DevTools.java:168)
              at com.sun.facelets.util.DevTools.writeVariables(DevTools.java:147)
              at com.sun.facelets.util.DevTools.debugHtml(DevTools.java:109)
              at com.sun.facelets.FaceletViewHandler.handleRenderException(FaceletViewHandler.java:692)
              at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:660)
              at org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:108)
              at org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:216)
              at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:106)
              at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
              at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144)
              at javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
              at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
              at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:85)
              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:141)
              at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:281)
              at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:60)
              at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
              at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58)
              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:235)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
              at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
              at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
              at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
              at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
              at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
              at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
              at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
              at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
              at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
              at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
              at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
              at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
              at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
              at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
              at java.lang.Thread.run(Thread.java:595)
      
      


      Do you have any idea what I'm doing wrong ?


      Thanks,
      Gabi

        • 1. Re: java.lang.ClassCastException: java.util.ArrayList using rich:listShuttle
          gabir gabirad Newbie

          I've removed the converter and I'm the ClassCast is out.


          But now I've got this


          org.ajax4jsf.resource.ResourceNotFoundException:



          on selecting one 'agent'


          Resource not registered : org.richfaces.renderkit.html.gradientimages.OrderingListClickedGradient
                  at org.ajax4jsf.resource.ResourceBuilderImpl.getResource(ResourceBuilderImpl.java:393)
                  at org.ajax4jsf.resource.ResourceBuilderImpl.getResourceForKey(ResourceBuilderImpl.java:337)
                  at org.ajax4jsf.resource.InternetResourceService.serviceResource(InternetResourceService.java:155)
                  at org.ajax4jsf.resource.InternetResourceService.serviceResource(InternetResourceService.java:144)
                  at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:265)
                  at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:60)
                  at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
                  at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58)
                  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:235)
                  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                  at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
                  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
                  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                  at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
                  at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
                  at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
                  at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
                  at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
                  at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
                  at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
                  at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
                  at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
                  at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
                  at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
                  at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
                  at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
                  at java.lang.Thread.run(Thread.java:595)



          and

          17:19:30,606 INFO  [lifecycle] WARNING: FacesMessage(s) 
          have been enqueued, but may not have been displayed.
          
          sourceId=j_id13:useracc[severity=(ERROR 2), summary=(j_id13:useracc: Validation Error:
           Value com.spinvox.security.datamodel.Agent@1c5b422 is not valid), detail=(j_id13:useracc: Validation Error:
           Value com.spinvox.security.datamodel.Agent@1c5b422 is not valid)]


          onsubmit.


          Any ideas ?
          Thanks.


          • 2. Re: java.lang.ClassCastException: java.util.ArrayList using rich:listShuttle
            Keith Naas Novice
            @DataModel
            List<Agent> agents;
                 
            @DataModelSelection(value="agents")
            List<Agent> selectedAgents;



            Please read up on DataModel and DataModelSelection


            The type of the @DataModelSelection should be an Agent, not a List<Agent> since it is a single selected item in the list.


            As for the gradient thing, sounds like a possible ajax4jsf bug.  Try to clear your browser cache and see if it still happens.

            • 3. Re: java.lang.ClassCastException: java.util.ArrayList using rich:listShuttle
              gabir gabirad Newbie

              Hi Keith,


              Thanks for reply!


              You are correct on the gradient, clearing cache solved the problem.


              I'm using listShuttle since I need a List of selected 'Agent'(similar to selectManyListBox).


              Maybe I do not need a DataModelSelection... I do not know since I didn't find a decent example of using rich:listShuttle and Seam (or maybe I didn't search enough and I'm using Seam for 2 weeks).


              Any suggestions?


              Thanks,Gabi



              • 4. Re: java.lang.ClassCastException: java.util.ArrayList using rich:listShuttle
                gabir gabirad Newbie

                Guys,
                I have removed the model and datamodelSelection, and now I have a factory :


                @Name("agents")
                public class Agents {
                
                      private AgentService agentService = new AgentService();
                     
                     public List<Agent> getAgentsList(){
                          
                          return agentService.getAgentsList();
                     }
                     
                
                }     


                and the converter is :


                     public Object getAsObject(FacesContext arg0, UIComponent arg1, String arg2) {
                     
                          Agent agent = null;
                          
                          if(arg2!=null){
                               agent = agentService.getAgent(new Integer(arg2));
                          }
                          
                          return agent;
                     }
                
                     public String getAsString(FacesContext arg0, UIComponent arg1, Object arg2) {
                          
                          return ((Agent)arg2).getId()+"";
                          
                     }



                and the html is :



                <rich:listShuttle  id="useracc" sourceValue="#{agents.agentsList}"
                                              targetValue="#{selectedAgents}" var="agent"
                                              listHeight="300" listWidth="300"
                                              sourceCaptionLabel="Available Agents"
                                              converter="agentConverter"
                                              targetCaptionLabel="Currently Selected Agents"
                                              >
                                              <rich:column >
                
                                                   <h:outputText value="#{agent.loginName}" />
                
                                              </rich:column>
                
                                         </rich:listShuttle>



                The action is :
                     


                @Out(value="selectedAgents",required=false)
                     List selectedAgents;



                The values in the converter are ok, but on submit now I've got :



                INFO  [lifecycle] WARNING: FacesMessage(s) have been enqueued, but may not have been displayed.
                sourceId=j_id13:useracc[severity=(ERROR 2), summary=(j_id13:useracc: Validation Error:
                 Value null is not valid), detail=(j_id13:useracc: Validation Error:
                 Value null is not valid)]



                Agent has equals, so I'm out of ideas.


                Any suggestions ?

                • 5. Re: java.lang.ClassCastException: java.util.ArrayList using rich:listShuttle
                  Keith Naas Novice

                  If Agent is an Entity, you can use the EntityConverter that comes with Seam.



                  As far as the listShuttle generating that facesmessage, i'm not sure...it could be a bug with the richfaces control.


                  try explicitly setting the required attribute to false.

                  • 6. Re: java.lang.ClassCastException: java.util.ArrayList using rich:listShuttle
                    gabir gabirad Newbie

                    Hi Keith and thanks for reply!


                    I cannot use the seam entityConverter because I'm using entity's from another application and I do not have direct access to the DB and of course to the entityManager.(I'm getting data @Remote)


                    the required attribute is already set to false



                         @Out(value="selectedAgents",required=false)
                         List<Agent> selectedAgents



                    The thing is that I saw that equals() or hashCode() from Agent entity are never called although AgentConverter is called correctly for each one of the selected Agents in the listShuttle.


                    Another thing is that in my Agent I have a ManyToMany relation
                    and I saw a similar value is not valid problem here and there were some suggestions about hacking the entityManager :


                    forum link


                    Any suggestions ??


                    Thanks guys!

                    • 7. Re: java.lang.ClassCastException: java.util.ArrayList using rich:listShuttle
                      jeremy girard Newbie

                      Hi,


                      I tried to do something similar (replace selectManyListBox by listShuffle) and i've got exactely the same errors as you.


                      I'm using seam 2.0.0GA, richfaces 3.1.4.GA and jboss 4.2.2.GA.


                      Have you solved your problem ? how ?


                      Thanks.

                      • 8. Re: java.lang.ClassCastException: java.util.ArrayList using rich:listShuttle
                        Pradeep Baisani Newbie

                        Hi,


                        I have a similar problem with rich:listShuttle.  Its complaining  Validation Error:null is not valid on submit.  Is there a way to supress validation on this component. ried required is true and that did not help too


                        I have declared the seam provided entityConverter in the component  declaration.  Did anyone figured out a solution for this?


                        Thanks

                        • 9. Re: java.lang.ClassCastException: java.util.ArrayList using rich:listShuttle
                          Harpreet  Dhanoa Newbie

                          Hi Guys,
                          Any Luck with listShuttle and seam ?
                          I want to convert the SelectManyListBox to listShuttle but facing same validation exceptions.
                          that be great if you post any example


                          Thanks


                          • 10. Re: java.lang.ClassCastException: java.util.ArrayList using rich:listShuttle
                            gabir gabirad Newbie

                            Hi guys,
                            Here's my working listShuttle :


                            <rich:listShuttle  id="available_groups" sourceValue="#{agentAction.availableGroups}"
                                                          targetValue="#{agentAction.selectedGroups}" var="gr"
                                                          listHeight="300" listWidth="300"
                                                          sourceCaptionLabel="#{messages['txt.AvailableGroups']}"
                                                          targetCaptionLabel="#{messages['txt.CurrentlySelectedGroups']}"
                                                          copyAllControlLabel="#{messages['txt.CopyAll']}"
                                                          copyControlLabel="#{messages['txt.Copy']}"
                                                          removeAllControlLabel="#{messages['txt.RemoveAll']}"
                                                          removeControlLabel="#{messages['txt.Remove']}" 
                                                          topControlLabel="#{messages['txt.First']}"
                                                          upControlLabel="#{messages['txt.Up']}"
                                                          downControlLabel="#{messages['txt.Down']}"
                                                          bottomControlLabel="#{messages['txt.Last']}"
                                                          converter="groupConverter">
                                                          
                                                          <rich:column >
                            
                                                               <h:outputText value="#{gr.name}" />
                            
                                                          </rich:column>
                            
                                                     </rich:listShuttle>



                            Here the action :


                            @Name("agentAction")
                            public class AgentAction {
                            
                                 @In(create = true,required=false)
                                 @Out(required=false) 
                                 @DataModelSelection
                                 Agent agent;
                            
                            List<Group> availableGroups = new ArrayList<Group>();
                            List<Group> selectedGroups = new ArrayList<Group>();
                            
                            @Begin(join=true)
                                 public List<Group> getAvailableGroups(){
                                      
                                      List<Group> groups=null;
                                      try {
                                           groups = groupService.getGroups(groupsIndexVar*Constants.DISPLAY_PER_PAGE_NUMBER,(groupsIndexVar+1)*Constants.DISPLAY_PER_PAGE_NUMBER);
                                           if(selectedGroups.size()>0)
                                                groups.removeAll(selectedGroups);
                                      } catch (SecurityException e) {
                                           // TODO Auto-generated catch block
                                           e.printStackTrace();
                                      }
                                      return groups;
                                      
                                 }
                            



                            And this is the Converter:



                            @Name("groupConverter")
                            @BypassInterceptors
                            @Converter(forClass=Group.class)
                            public class GroupConverter implements javax.faces.convert.Converter {
                                 
                                 private GroupRemote groupService = (GroupRemote)DataAccessBridge.retrieve("GroupBean");
                                 
                                 public Object getAsObject(FacesContext arg0, UIComponent arg1, String arg2) {
                                      
                                      Group gr = new Group();
                                      
                                      if(arg2 == null || arg2.equals("null")){
                                           return gr;     
                                      }
                                      else{
                                      
                                      try {
                                           gr = groupService.getGroup(new Integer(arg2));
                                      } catch (NumberFormatException e) {
                                           // TODO Auto-generated catch block
                                           e.printStackTrace();
                                      } catch (SecurityException e) {
                                           // TODO Auto-generated catch block
                                           e.printStackTrace();
                                      }
                                      }
                                      return gr;
                            
                                 }
                            
                                 public String getAsString(FacesContext arg0, UIComponent arg1, Object arg2) {
                                      
                                      return ((Group)arg2).getId()+"";
                                      
                                 }
                            
                            }



                            Be careful with equals and hashCode on listShuttle listing bean(for me is Group).




                            Hope this helps.