myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sean Schofield <>
Subject New Tree Component (Update)
Date Thu, 03 Feb 2005 04:16:21 GMT
I wanted to start a new thread concerning some of the progress I have
been making with the new tree component.

The first bit of news is that I discovered that Hans Bergsten, author
of the  O'Reilly JSF book, has a fairly complete example of a custom
tree component.  Its been simplified somewhat but it did manage to
solve a few of the problems I was grappling with.  Also, it used a
similar approach to some of the ideas that I have proposed on this
list.  I contacted Hans and he gave me permission to use portions of
his code in the new component.

I've also given some more thought to how the JSF tags should work. 
Here is a revised example.

  <x:tree value="#{treeData}" var="node">
    <f:facet name="branch">
        <h:graphicImage value="open-folder.gif"
        <h:graphicImage value="closed-folder.gif"
        <h:outputText value="#{node.description}"/>
    <f:facet name="leaf">
        <h:graphicImage value="document.gif"/>
        <h:commandLink immediate="true" value="#{node.description}"/>

The major change is that I've consolidated the "open" and "close"
graphic images into a single panel group.  I've added a
getNodeExpanded method to the the TreeModel so that you can render the
appropriate image.  I also enclose everything in the facet inside a
panel group.  I discovered this was necessary after some testing (I
guess facet can only handle a single child).

If you look at all of the options this gives you, it doesn't seem like
an IconProvider is necessary.  You've go the "var" attribute which you
can combine with existing attributes like "rendered" and "disabled". 
You should be able to use backing beans and/or subclass of TreeNode to
get all of the behavior that Oliver mentioned in his use case (locked
node, etc.)

I personally like specifying the image file and location right on the
jsp page.  I am not really wild about burying the details of the
images in some class somewhere.  It seems like we could avoid this
with the solution I am proposing.

I am working on an initial version of the tree to check in (see
earlier email on the dev list).  It should be ready by the end of next
week.  It will contain a very solid starting point for people to
evaluate and make suggestions.  It probably will not have any of the
expand collapse features for another few weeks but it will be coming

I think this is going to be a sweet little JSF component.  I already
know it works and looks great in its current incarnation as a Tiles
component.  Now I am starting to get excited about how it will work in
JSF.  Also, I am getting an increasing appreciation for how powerful
of a framework JSF really is.

Looking forward to your feedback,


View raw message