0 Replies Latest reply on Dec 10, 2007 9:30 AM by Miroslav Genov

    Tree Component

    Miroslav Genov Newbie

      Hello,
      I'm getting strange error when I use the tree component. When I use Map for child elements everything is working like e charm. But when collection type is changed to Set I'm getting this exception.

      java.lang.ClassCastException: org.mgenov.agreements.beans.ip.Lan
       at org.richfaces.model.TreeDataModel.doWalk(TreeDataModel.java:80)
       at org.richfaces.model.TreeDataModel.walk(TreeDataModel.java:139)
       at org.richfaces.component.UITree.walk(UITree.java:323)
       at org.richfaces.renderkit.TreeRendererBase.writeContent(TreeRendererBase.java:682)
       at org.richfaces.renderkit.TreeRendererBase.encodeChildren(TreeRendererBase.java:625)
       at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:825)
       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:825)
       at org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:282)
       at org.ajax4jsf.renderkit.RendererBase.renderChildren(RendererBase.java:262)
       at org.ajax4jsf.renderkit.AjaxContainerRenderer.encodeChildren(AjaxContainerRenderer.java:97)
       at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:825)
       at org.ajax4jsf.component.UIAjaxRegion.encodeChildren(UIAjaxRegion.java:113)
       at org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:282)
       at org.ajax4jsf.renderkit.RendererBase.renderChildren(RendererBase.java:262)
       at org.richfaces.renderkit.TabRendererBase.encodeChildren(TabRendererBase.java:113)
       at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:825)
       at org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:282)
       at org.ajax4jsf.renderkit.RendererBase.renderChildren(RendererBase.java:262)
       at org.richfaces.renderkit.html.TabPanelRenderer.doEncodeChildren(TabPanelRenderer.java:266)
       at org.richfaces.renderkit.html.TabPanelRenderer.doEncodeChildren(TabPanelRenderer.java:261)
       at org.ajax4jsf.renderkit.RendererBase.encodeChildren(RendererBase.java:121)
       at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:825)
       at javax.faces.component.UIComponent.encodeAll(UIComponent.java:936)
       at javax.faces.render.Renderer.encodeChildren(Renderer.java:148)
       at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:825)
       at javax.faces.component.UIComponent.encodeAll(UIComponent.java:936)
       at javax.faces.component.UIComponent.encodeAll(UIComponent.java:942)
       at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:577)
       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: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:290)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:141)
       at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:281)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.mgenov.agreements.web.util.filters.UTF8EncodingFilter.doFilter(UTF8EncodingFilter.java:28)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:147)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.apache.myfaces.orchestra.filter.OrchestraServletFilter.doFilter(OrchestraServletFilter.java:140)
       at org.apache.myfaces.orchestra.lib.CompoundFilter$1.doFilter(CompoundFilter.java:57)
       at org.apache.myfaces.orchestra.frameworkAdapter.jsf.JsfFrameworkAdapterFilter.doFilter(JsfFrameworkAdapterFilter.java:69)
       at org.apache.myfaces.orchestra.lib.CompoundFilter.doFilter(CompoundFilter.java:62)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.apache.myfaces.orchestra.requestParameterProvider.RequestParameterServletFilter.doFilter(RequestParameterServletFilter.java:63)
       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:233)
       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
       at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263)
       at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
       at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:584)
       at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
       at java.lang.Thread.run(Unknown Source)
      
      


      This is the code which works:
      private Map lans2 = new HashMap();
      .....................
      public Iterator getChildren() {
       return lans2.entrySet().iterator();
      }
      


      This is the code which doesn't work:
      private Set<Lan> lans = new HashSet<Lan>(0);
      ..............................
      public Iterator getChildren() {
      return lans.iterator();
      



      The Lan's class implements TreeNode interface too.

      Any ideas how can I use another collection type with the tree component?

      PP: Version is 3.1.2.GA