• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Editing datatable column content dynamically

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 598
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Works perfectly. Thanks!
reply
    Bookmark Topic Watch Topic
  • New Topic