Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to Create Repeated Fields?  RSS feed

 
Phoenix Kilimba
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Sirs et Madames,
I wish to create a JSF page which collects a number of details (e.g first, middle and last name, gender, age, location) from an initially unknown number of members of a household (household has a one-to-many-relationship with members, but we dont know how many members there will be). Therefore I would like to be able to have a row of components which will capture these attributes' values for a single member and at the end of the row I should have 2 buttons, one to SUBMIT or the other to ADD ANOTHER MEMBER. If the ADD ANOTHER MEMBER button is clicked, then this should result in a new row of exactly the same fields that captured the previous members information, and so on until there are no more users to add and the data entrant clicks on submit.

How does one go about achieving this result?

Thanks in advance
 
Max Neves
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I've already done something similar using the Facelet 'ui:repeat' and Ajax4JSF 'a4j:repeat'.
In general lines, ui:repeat points to the object-list (like "value=#{bean.objectList}") and we loop using var.
Whenever you add an object to your object-list (e.g. by firing an action with a commandButton), you re-render the page and ui:repeat will now loop over the updated 'objectList'. a4j:repeat works similar.
Google these terms to get some examples.
 
suresh dasari
Ranch Hand
Posts: 121
Chrome Eclipse IDE Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

by using ui:repeat I can able to add rows dynamically, but how to set the modified values to backing back as the setters not calling validation is failing.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!