This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JSF and the fly likes Add Rows To Datatable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Add Rows To Datatable" Watch "Add Rows To Datatable" New topic
Author

Add Rows To Datatable

James Ellis
Ranch Hand

Joined: Oct 14, 2004
Posts: 205
I want to be able to add rows to a datatable based on a selection from a dropdown box. So I know that you can use the ValueChangeListener to fire off an event where I should lookup the datatable and add rows to it, but I don't know how to look up the datatable nor do I know how to add a row to it once I've found it.

Any sample code out there?
Hemanth Pillai
Greenhorn

Joined: Dec 14, 2005
Posts: 3
Please get hold of a copy of Core JavaServer Faces by David Geary and Cay Horstmann. Chapter 5 covers this in detail.

HTH
Hemanth
James Ellis
Ranch Hand

Joined: Oct 14, 2004
Posts: 205
I accomplished this using a panelGrid. Basically what I did was this. Create a panelGrid on a JSF page with two columns. Bind the panelGrid to a backing bean. In the getter for the panelGrid on the backing bean you can add elements to the panelGrid using code like below:

 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Add Rows To Datatable
 
Similar Threads
Adding subrow with additional information for each row in dataTable
how to add HR tag between rows when using datatable???
grouping in datatable
Pagination in JSF
Splitting a column in a datatable