0 Replies Latest reply on Apr 2, 2007 7:09 AM by Eugene Batogov

    rich:tree component don't see what my class implements TreeN

    Eugene Batogov Newbie

      Hello!
      My configuration:
      JSF: 1.2._04
      JBoss SEAM: 1.2.1.GA
      RichFaces: 3.0.1-20070402
      JVM: Sun RI JVM 6.0
      OS: Fedora Linux

      I am trying use rich:tree component, but afoul with next trouble.
      I have class which implements TreeNode interface:
      ------------------------------------------------
      @Name("treeMenu")
      public class TreeMenu implements TreeNode, Serializable {

      private static final long serialVersionUID = 6980908422325671888L;

      private Map sections = null;

      private long nextId = 0;

      public long getNextId() {
      System.out.println("call method getNextId()");
      return this.nextId++;
      }

      private Map getSections() {
      System.out.println("call method getSections()");
      if (this.sections == null) {
      this.sections = new HashMap();
      this.initData();
      }
      return this.sections;
      }

      public void addSection(final Section section) {
      System.out.println("call method addSerction()");
      this.addChild(Long.toString(section.getId()), section);
      section.setParent(this);
      }

      public void addChild(final Object identifier, final TreeNode child) {
      System.out.println("call method addChild()");
      this.getSections().put(identifier, child);
      }

      public TreeNode getChild(final Object id) {
      System.out.println("call method getChild()");
      return (TreeNode) this.getSections().get(id);
      }

      public Iterator getChildren() {
      System.out.println("call method getChildren()");
      return this.getSections().entrySet().iterator();
      }

      public Object getData() {
      System.out.println("call method getData()");
      return this;
      }

      public TreeNode getParent() {
      System.out.println("call method getParent()");
      return null;
      }

      public boolean isLeaf() {
      System.out.println("call method isLeaf()");
      return this.getSections().isEmpty();
      }

      public void removeChild(final Object id) {
      System.out.println("call method removeChild()");
      this.getSections().remove(id);
      }

      public void setData(final Object date) {
      }

      public void setParent(final TreeNode parent) {
      }

      public String getType() {
      System.out.println("call method getType()");
      return "treeMenu";
      }

      private void initData() {
      .....
      }

      }
      ------------------------------------------------

      But, when I try to adress at my.xhml page JBoss throw nest stack with errors:
      -------------------------------------------------
      14:47:31,940 ERROR [STDERR] 02.04.2007 14:47:31
      com.sun.facelets.FaceletViewHandler handleRenderException
      SEVERE: Error Rendering View[/index.xhtml]
      java.lang.ClassCastException:
      ru.cti.oss.iptv.manager.jsf.TreeMenu$$EnhancerByCGLIB$$a41f6355 cannot
      be cast to org.richfaces.component.TreeNode
      at
      org.richfaces.component.AbstractTreeDataModel.setWrappedData(AbstractTreeDataModel.java:63)
      at org.richfaces.component.UITree.createDataModel(UITree.java:477)
      at
      org.ajax4jsf.ajax.repeat.UIDataAdaptor.getExtendedDataModel(UIDataAdaptor.java:464)
      at
      org.ajax4jsf.ajax.repeat.UIDataAdaptor.setRowKey(UIDataAdaptor.java:280)
      at
      org.ajax4jsf.ajax.repeat.UIDataAdaptor.setRowKey(UIDataAdaptor.java:265)
      at
      org.richfaces.renderkit.TreeRendererBase.writeContent(TreeRendererBase.java:395)
      at
      org.richfaces.renderkit.TreeRendererBase.encodeChildren(TreeRendererBase.java:299)
      at
      javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:809)
      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:809)
      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:809)
      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:809)
      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:578)
      at
      org.ajax4jsf.framework.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:108)
      at
      org.ajax4jsf.framework.ajax.AjaxViewHandler.renderView(AjaxViewHandler.java:229)
      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:252)
      at
      org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      at
      org.ajax4jsf.framework.ajax.xmlfilter.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:96)
      at
      org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter.doFilter(BaseFilter.java:220)
      at
      org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
      at
      org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      at
      org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:63)
      at
      org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:57)
      at
      org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:49)
      at
      org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
      at
      org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:49)
      at
      org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:79)
      at
      org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:49)
      at org.jboss.seam.web.SeamFilter.doFilter(SeamFilter.java:84)
      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.jboss.web.tomcat.tc5.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156)
      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:619)

      -------------------------------------------------
      Why this occurred?
      Eclipse tell me, that I implements interface TreeNode properly !
      Why occured : ClassCastException ?
      Help me , please .