• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to add complete component List of PanelGrid again dynamically  RSS feed

 
karthik chandra
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I hava a panelGrid which contain label and inputtext. Below that there is a commandLink.

What I want is, when I click the commandLink, the panegrid repeat itself(mean if the panelgrid has 2 row prviously then after comandLink click it should display 4 row). Please help
 
Prithvi Sehgal
Ranch Hand
Posts: 774
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
What i get from your problem is something related to Add functionality. In that case if your panelGrid is associated with some collection
at the managed bean. On the action, you have to add this collection to a master collection and re-iterate.
HTH,
 
Tim Holloway
Bartender
Posts: 18663
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Usually the best way to do this is to use a dataTable. Each instance of the panelGrid would be one row in the table. The backing data for that panelGrid instance would be one row in the dataTable's corresponding DataModel object. JSF will automatically track which row you are working with using the DataModel to store the tracking information so that if you build the DataModel on top of (wrapping) a more generic collection, that collection won't have to keep JSF-only data in it.

A lot of people like to abuse the <ui:repeat> element for this kind of thing, but I strongly discourage that. It smells of polluting the MVC View definition with logic when actually, the logic is immaterial, since all the user cares about is getting a 2-dimensional display and could care less about how it's done, whether it's via a loop, a parallel-processing function or something even more exotic. The DataTable does a much cleaner job of this. Save the ui:repeat tag for cases where a tabular display isn't what you need and/or iteration at the View level is unavoidable.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!