My requirement is something like this. In a JSF(2.0) page, I have a section called Address. I have added a button which says "Add an Address". When the user clicks the button, new address fields(input text) should be generated dynamically (Line1, Line2, City etc..,). And when I click submit, all the values (Address 1, Address 2 ... Address N) should go to an array list.
So I need to
- Dynamically generate UI components on click on a button
- Link those UI components to a backing bean (Preferably to a list)
- Data tables should not be used for the above
It is very difficult to find proper JSF documentations online, so if anyone can help me out it would be great
Update : The answer posted by noone works good, but I want something more robust, like creating dynamic UI components from the Java Controller (The java bean, using HtmlPanelGrid component). I have been able to create components dynamically using htmlPanelGrid, but I cannot find a way to bind those generated components to the address list in the bean (The one which stores details of all the addresses)
<ui:repeat>
then. I'm really not seeing why programmatically creating components in Java side would be "more robust" instead of just building/declaring them in the view side. – BalusC