| Author |
Editing datatable column content dynamically
|
Per-Morten Lindanger
Greenhorn
Joined: Oct 13, 2008
Posts: 10
|
|
I am currently trying to list out a collection of objects from an arraylist stored in a bean. The objects all implement a common interface, but are of different object types. What I want to do, is to display the list so that some of the objects are displayed as combo boxes, and others as inputfields, depending on what kind of object they are. Is this doable? and in that case how? I don't want to generate the content of the JSP in doview() unless I really really REALLY have to.
|
 |
Himanshu Gupta
Ranch Hand
Joined: Aug 18, 2008
Posts: 598
|
|
|
Well i am thinking of an another work around. Why dont you make two boolean properties in each object like isList or isCombo and give one of these fields in Rendered. So at a time only one will be displayed.
|
My Blog SCJP 5 SCWCD 5
|
 |
Per-Morten Lindanger
Greenhorn
Joined: Oct 13, 2008
Posts: 10
|
|
Would'nt the ".setRendered(false)" cause all the inputTexts/comboboxes in the column to be hidden? The list will contain objects of different classes at the same time.
|
 |
Himanshu Gupta
Ranch Hand
Joined: Aug 18, 2008
Posts: 598
|
|
You can go like this that in your both classes you have two boolean variables say isListable and isInput(something like that. you may think of some better name). Now set it whenever your object gets initialized. Categorise it such that when your object gets created it will sets its properties(Boolean properties) by itself. Now in the code provide two components in a single column of your datatable 1. <h:input... rendered=#{bean.input}> 2. <h:selectmany... rendered=#{bean.listable}> Hope this works... [ October 13, 2008: Message edited by: Himanshu Gupta ]
|
 |
Per-Morten Lindanger
Greenhorn
Joined: Oct 13, 2008
Posts: 10
|
|
Works perfectly. Thanks!
|
 |
 |
|
|
subject: Editing datatable column content dynamically
|
|
|