1 Reply Latest reply on May 3, 2010 8:02 PM by Nick Belaevski

    cast in tree selectedEventListener

    dario catani Newbie

      Hi all,

      i'm getting stuck handling the selection event on a simple tree component.

      my code.

       

      xhtml page:

      {code}<rich:tree id="treeConcept" style="width:300px"

            ajaxSubmitSelection="true"  switchType="client"
            value="#{myBean.treeNode}" ajaxKeys="#{null}"

            nodeSelectListener="#{myBean.selectLeaf}">
            </rich:tree>{code}

       

      my Bean

       

      {code}private MyObject selectedLeafConcept;

      private TreeNodeImpl<MyObject> rootNode = null;

       

      ... I initialize the rootNode...

       

      public void selectLeaf(NodeSelectedEvent event) {
              HtmlTree tree = (HtmlTree) event.getComponent();
              this.selectedLeafConcept = (MyObject) tree.getRowData();

        [... code verifying it's a leaf..]
          }{code}

       

      I can see and browse the tree...but if I select a node i get this Exception in console ...

       

      {code}java.lang.ClassCastException:

      org.richfaces.component.html.HtmlTree cannot be cast to org.richfaces.component.html.HtmlTree{code}

       

      ...why?