• Post Reply Bookmark Topic Watch Topic
  • New Topic

Editing datatable column content dynamically  RSS feed

 
Per-Morten Lindanger
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 598
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Per-Morten Lindanger
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 598
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Works perfectly. Thanks!
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!