Can I add JSF components dynamically? I need to have a form with a button which should add one <h:inputText> to the form. Is this possible?
I know this should be possible in JavaScript somehow. Do anybody know how to do this in JSF? I think the major problem is how do I get or set values of new inputs via #{value}.
Use an iterating component like
<h:dataTable>or<ui:repeat>to display a dynamically sizedListof entities. Make the bean@ViewScopedto ensure that the list is remembered across postbacks on the same view instead of recreated over and over.Kickoff example with
<h:dataTable>(when using<ui:repeat>simply replace<h:dataTable>by<ui:repeat>, and<h:column>by e.g.<li>or<div>):Managed bean:
Model:
See also: