Meaningless Drivel is fun!
The moose likes JSF and the fly likes How to create a tree component in JSF Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "How to create a tree component in JSF" Watch "How to create a tree component in JSF" New topic

How to create a tree component in JSF

Rajesh Naidu G

Joined: Jun 24, 2009
Posts: 1
Hi ,
I am using JSF with Facelets with Spring web-flow.I want to create a tree which is equivalent to ICEFaces' <ice:tree> .I don't want to use ICEFaces. Please help me to solve this.
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968

Howdy Greeenhorn! Welcome to the ranch. And that's a great question - not an uncommon one.

So, you have a design that you want, and it's a design that largely relies on JavaScript, correct? I mean, all of those trees that expand and contract are largely JavaScript running on the client machine, with the occassional call back to the server.

How are you going to do it? Well, as you mentioned, many JSF extensions like IceFaces provide that type of functionality. But you don't want to use IceFaces, which is understandable. But, you still need that functionality! Well, you're going to have to write it yourself, and perhaps put the code in your own custom tag - essentially, you'll write your own component that is very similar to the IceFaces one. I mean, how else could you really do it.

You can get the source for IceFaces. If you're looking to roll your own, you may as well leverage what people much better looking than you and me have already coded and tested. But really, if you're not going to use a third-pary library, well, then you'll have to write one on your own.

Keep posting question! And if I said something you disagree with, please challenge it. That way we all get the very best out of this message forum.

-Cameron McKenzie
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17423

Funny you should ask. I'm looking at the source code of the RichFaces tree control right now.

RichFaces has a very nice development kit with a decent manual to tell how to use it. But custom JSF controls are not for the "All you have to do is/Git 'R Dun" crowd. Even "simple" JSF controls can be pretty complicated and nasty, and if you want the level of interactivity that you'd get from JavaScript support....

Let's put it this way. I've done custom JSF controls before. I'm subclassing a control that's mostly already complete - it's mainly just a matter of changing the look and feel.

I doubt I'll get it "Dun" in less than a week.

Unless there's a really compelling reason, Don't Reinvent it Yourself (DRY).

An IDE is no substitute for an Intelligent Developer.
I agree. Here's the link:
subject: How to create a tree component in JSF
It's not a secret anymore!