2 Replies Latest reply on Jan 13, 2011 3:36 AM by lrp

    Is it possible to have different icons for the nodes in an HtmlTreeNodesAdaptor based on their class?

    lrp

      I'm guessing this isn't possible, but I figured I'd ask anyways in case there was some way of accomplishing it.

       

      Let's say I have two classes:

       

      - SubClassOne

      - SubClassTwo

       

      Both of these extend the class "SuperClass" (these are hypothetical names). I then do as follows:

       

      ArrayList<SuperClass> values = new ArrayList<SuperClass>();
      // Code that fills the ArrayList with a number of objects that can be of either class SubClassOne or SubClassTwo.
      
      HtmlTreeNodesAdaptor adaptor = (HtmlTreeNodesAdaptor) app.createComponent(HtmlTreeNodesAdaptor.COMPONENT_TYPE);
      adaptor.setNodes(values);
      // adaptor added to tree
      
      HtmlTreeNode node = (HtmlTreeNode) app.createComponent(HtmlTreeNode.COMPONENT_TYPE);
      node.getChildren.add(someText); // In reality this is wired to a field on the object through a value expression.
      node.setIconLeaf(somePath);
      adaptor.getChildren().add(node);
      

       

      And this works fine. The tree branch displays as it should with all the elements. However, my problem is that I wish to have separate icons for nodes of SubClassOne and nodes of SubClassTwo. Originally I thought about having two separate adaptors for the two, but the objects have an implicit order which is important to preserve in the presentation, so that's not an option. I then thought about setting the iconLeaf through a ValueExpression that would evaluate whether the calling object was of SubclassOne or SubClassTwo, but found no way of letting the getter know what object was the source of the call.

       

      Is there any way of accomplishing what I need without rearranging the tree structure?