That article isn't describing how to create a table with different components in each row; it simply describes how to use java code to define a table that has the *same* components in each row. With this approach, it is possible to vary the number of columns present in the table each time the page is re-rendered. However you cannot have different components in different rows of the table.

MyFaces should work fine with this example code.

To solve your original problem, you should simply use the approach you described in your first posting - define all the components that can possibly exist in the row, then set the rendered attribute to false for ones that you don't want visible in a specific row.

kevin_zhai wrote:
Hi simon:

   I find a url desc how to implement,but it's sun's tool(jscreator),myfaces
it's real can't do that...
http://developers.sun.com/prodtech/javatools/jscreator/reference/techart/2/createTableDynamically.html

Simon Kitching-3 wrote:
The UIData component uses the "flyweight" pattern to process its rows, as described in the javadoc I pointed out. Because of this, I'm pretty sure that attempting to change the child components of a UIData object while it is iterating over its rows will have most unpleasant
side-effects.

Regards,

Simon

kevin_zhai wrote:
Hi If we can create table in back bean dynamically,
maybe it can attach me the requirement,
can  anybody give me advice,thanks


Simon Kitching-3 wrote:
Hi Kevin,

kevin_zhai wrote:
I have a  Table that has a column containing buttons for operations on
each
row. Each row may have different operations applicable to it, so the
buttons
for each row need to be determined dynamically based on the contents of
row.
I have seen code to dynamically create buttons, but what I would like
to
know is how to do this on a per-row basis, so that row 1 would might
have
1
button, row 2 would have 3 buttons and so on. I would like to avoid the
solution of creating all of the possible types of buttons and hiding
the
ones that do not apply to the current row.
It is not possible to change the set of components per-row. Instead, you *must* define all the possible types of components present in a row, then use the rendered attribute to show/hide them based on what you want to display on a specific row.

See the javadoc for the UIData component for details:
  http://myfaces.apache.org/api/apidocs/index.html

Regards,

Simon






Reply via email to