| Author |
JSF - dynamic tag choice
|
Kevin McMahon
Greenhorn
Joined: Nov 03, 2008
Posts: 19
|
|
Hi all. I'm fairly new to JSF, and wondered if anyone might be able to give me a pointer in the right direction for this scenario... I have a dynamic list of properties which I need to display on a page. However, the properties have a dynamic type - so for some properties I will need a checkbox to allow the user to select on/off, others will be a text input field etc. There will be a mix of types per page, but I don't know in advance how many or what type they will be, as this comes from a database. If I were doing this in jstl, I could use something like <c:if test="${myProperty.type == 'checkbox'}> <input type="checkbox" ...> </if> or even <input type="<c ut value="${myProperty.type"} />" ....> Can anyone get me started on the right path to achieve a similar thing in JSF? sheep.
|
 |
Dave Alvarado
Ranch Hand
Joined: Jul 02, 2008
Posts: 434
|
|
Could you take advantage of the input element's rendered attribute? For example, for each property output both a checkbox and a text field, but depending on your logic, the rendered attribute would evaluate to true for one and false for the other. - Dave
|
 |
Kevin McMahon
Greenhorn
Joined: Nov 03, 2008
Posts: 19
|
|
Yes, that's not a bad idea. Alternatively, could I use the backing bean to create the correct UIInput types dynamically, according to the data? For example, my backing bean can have I think I can then create the correct UIInput for each attribute in the collection, and add them as children to the UIPanel dynamically? Can I use the valueBinding methods on the UIInput to bind to my Attribute list objects? Then, in the jsp have I can't test this until later, but the only thing I'm not sure about it whether the data will bind back to the list element Attribute object ok?  [ November 06, 2008: Message edited by: Kevin McMahon ]
|
 |
 |
|
|
subject: JSF - dynamic tag choice
|
|
|