This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I'm making good progress with my first JSF application, and one requirement I have is to have a page with an arbitrary number of names, like a sign up sheet. There can be 0 names to several hundred, depending on how many names the user cares to enter. This was easy to do in Stripes/Struts, but I haven't figured out the JSF equivalent.
I know that JSF web page variables are tied to a back bean. So for example, if I have the below code in the backing bean:
And the front end:
Now I have 10 fields to input names - but what strategy can I employ to add new fields dynamically as the user enters them?
When I did it in Stripes, what I'd do is clone the inputText using jQuery with a pattern, like this:
However, this doesn't seem to work in JSF, if you create new DOM input elements following the pattern of existing JSF generated input elements, JSF isn't going to expand the array holding the list of names upon submit.
Is there a way to accomplish having a growing list of input fields in JSF? I'd like to avoid needing an ajax call to the server just to allocate a new String to the name array and needing to refresh the page.