File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSF and the fly likes Swapping out component subtrees during postbacks. Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » JSF
Reply Bookmark "Swapping out component subtrees during postbacks." Watch "Swapping out component subtrees during postbacks." New topic
Author

Swapping out component subtrees during postbacks.

Frank Silbermann
Ranch Hand

Joined: Jun 06, 2002
Posts: 1328
I have a Wicket application that I would like to re-implement in JSF. Here is one problem I need to solve. Lets say we are presenting tables of data obtained by SQL queries, and the set of columns as well as the order of the columns can be controlled by the user. Essentially, on each post back, the table component must be replaced by a quite different table. (Note: there are FAR too many permutations to select between alternatives by manipulating component visibility.)

In Wicket, I simply replace a sub-tree of components containing the table during post-back.

I've seen a web page which explains how to dynamically determine details of a JSF page's component tree when that page is requested. But I'm looking for a way to change a JSF page's component sub-tree between post-backs.

Can anyone link me to an article or post which explains how to do this?
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 14456
    
    7

I have an app similar to this, where a user selects a database table and I provide the ability to browse it and edit the entries.

It's just about the only JSF app I've done in about 6 years working with JSF that uses bindings and UIComponent manipulation. I bind the table to the backing bean and build up the column UIComponents. It's not done on postback, however, as I am working with a set of Views and the top-level View selects the table, whose format remains constant while the user browses it.

The only real "gotcha" here is that you should construct your UIComponent sub-components in a method that doesn't get called repeatedly and redundantly, since A) it's a lot more overhead and B) in-process data could be mangled.

Before diving into this, however, I would recommend that you check out the RichFaces extendedDataTable components. They can't do everything that low-level UIComponent tree manipulation can, but they can do an awful lot, and they're A) simpler to code and B) pre-debugged, so they might be able to save you some work.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
I agree. Here's the link: http://jrebel.com/download
 
subject: Swapping out component subtrees during postbacks.
 
Similar Threads
Fundamental life cycle question
a decade of "keep the code out of the jsp"
[forEach / commandLink / ajax] Illogical functionality
How to set the icon for JSF Tree Node in the backing bean
Seam in Action: Can I mix Seam controls with non-seam JSF Controls