• Post Reply Bookmark Topic Watch Topic
  • New Topic

Swapping out component subtrees during postbacks.

 
Frank Silbermann
Ranch Hand
Posts: 1408
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Bartender
Posts: 18408
58
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!