File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSF and the fly likes Composite Recursive List Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Composite Recursive List" Watch "Composite Recursive List" New topic

Composite Recursive List

Robe Eleckers

Joined: Jul 08, 2009
Posts: 9
Hi, I'm trying to build a multi-layer list, preferably from a composite component. The eventual result should be something like this:

This should be generated dynamically based on a structure in a backing bean. What I found so far is that it cannot be done using the c:foreach tag (it gives a stackoverflow). So therefore I started writing my own FacesComponent by implementating of the UIComponentBase which handles the recursive writing of the <ul> and <li> tags. I created a facelet-taglib for this and this works as it should.

However, I would still prefer to implement this using the composite mechanisme. Any ideas on how to do this? I do know how to create a composite component, but I do not know how to handle the 'recursiveness'.

Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17412

Well, JSTL once again fails. No surprise.

I think your main constraint here is that you're thinking in HTML terms, not in JSF terms. There are other ways to render stuff like this than using <li> elements, especially for unordered lists. For example, using nested <div> elements. CSS provides a way to make divs look like listitems. Or, for that matter, like a lot of other things that used to require a discrete HTML element type.

However, that's still thinking in HTML terms, and I generally discourage use of raw HTML in JSF views. The closest JSF approximation to a div would be a single-column panelGrid.

I'm actually doing something like that for a quick-and-dirty app where I have headings that I can pop open via a mouse click.

But that's only one approach. It might actually make more sense to use one of the treeview or menu components that often come with extension tagsets.

An IDE is no substitute for an Intelligent Developer.
I agree. Here's the link:
subject: Composite Recursive List
It's not a secret anymore!