2 Replies Latest reply on Mar 11, 2008 12:00 AM by Paul Pantages

    Trying to cast org.richfaces.component.html.HtmlTree

    Paul Pantages Novice

      I am using Seam 2.0.1.GA, Jboss 4.2.2


      This is not a seam problem per se, but I am hoping someone has run into this...


      I am using a rich:tree backed by a seam component.


      I have bound the component to the bean using the binding attribute. I want the tree state to be retained as the tree is expanded/collapsed by the user.


      Everything worked as expected.


      So, I wanted to also expand the tree when the component is first created. I expected to do this by casting it as HtmlTree or UITree and calling expandAll().


      This results in a classCast exception.


      If I print out the classname with getClass().getName()
      I can see that it is really an org.richfaces.component.html.HtmlTree. But I cannot cast it as such.


      I assume that my problem is really a classLoader problem...



      My Tree Binding


      <rich:tree switchType="ajax" binding="#{subnetTreeImpl.nodeTableTree}"> 
      ....
      ....
      
      



      The setter



          public void setNodeTableTree( UIComponent nodeTableTree ) {
      
              if ( this.nodeTableTree == null ) {
      
                  System.out.println("nodetabletree " + nodeTableTree.getClass().getName());
      
                  if ( nodeTableTree instanceof org.richfaces.component.html.HtmlTree ) 
                  {
                      System.out.println("nodetabletree is instanceof HtmlTree");
                      this.expandAll( (org.richfaces.component.html.HtmlTree) nodeTableTree );
                  }
                  else
                  {
                      System.out.println("nodetabletree is not HtmlTree");
                  }
              }
              this.nodeTableTree = nodeTableTree;
          }
      
      



      My build file started out based on the seam-booking example, with the  richfaces-api in the ear lib dir, and richfaces-impl and richfaces-ui in the war WEB-INF/lib.


      In order to access HtmlTree (fix classNotFound), I copied richfaces-ui and impl to the ear ./lib. This worked but results in the class cast exception.


      I tried also removing these from the war ./lib dir, but this causes other classNotFound error.


      I think I am going about this the wrong way ( moving jars around ); Is there something obvious that I am missing?



      Here is my application.xml


      <application>
         <display-name>Centina SA Client</display-name>
         <module>
            <web>
               <web-uri>client.war</web-uri>
               <context-root>/client</context-root>
            </web>
         </module>
      
         <module>
            <ejb>client.jar</ejb>
         </module>
      
         <module>
            <ejb>jboss-seam.jar</ejb>
         </module>
      </application>
      



      jboss-app.xml



      <jboss-app>
            <loader-repository> 
            seam.jboss.org:loader=client
            </loader-repository> 
      </jboss-app>