• 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

How to Create Repeated Fields?

 
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 121
Mac Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Don't sweat petty things, or pet sweaty things. But cuddle this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic