Hello! Found a similar question for PHP, but I can not find implementation for Java and PrimeFaces.
Task: There is a UI interface (for example, a form for filling in user data) on PrimeFaces, in which at the touch of a button the InputText fields are added (for example, an extension phone number). Further, the data from this form is stored in the database. The task of the idea should be found everywhere.
Question: For this UI form, is there a Java model (object), how to organize the dynamic addition of properties to this model when adding another phone number?
How to add fields to the form I know how to add columns to the database table too.
I don’t consider the option “immediately to provide in the model a sufficient number of properties for phones”, since I saw the implementation I needed a lot where I would like to try it.
Thank you and I apologize if I missed a similar topic with an answer somewhere.
I will clarify the question ...
1) Fragment JSF with the addition of an element
<p:panelGrid id="testPanel" columns="1"> **//НЕПОНЯТНО ЧТО ДОЛЖНО БЫТЬ ЗДЕСЬ!!!** <p:inputText value = "#{**ЧТО ЗДЕСЬ????**}"/> //По идее value параметр связан с атрибутом модели. </p:panelGrid> <h:form> <p:commandLink id="test" update=":testPanel" actionListener="#{managedBean.addInputText(event)}" value="Добавить телефон"/> </h:form> 2) Fragment ManagedBean
public void addInputText(ActionEvent event) { UIComponent component = FacesContext.getCurrentInstance().getViewRoot(). findComponent("testPanel"); if (component != null) { InputText it = new InputText(); it.setValue(**ЧТО ЗДЕСЬ ЕСЛИ ИСПОЛЬЗОВАТЬ ВАРИАНТ С List<Phone> phones???**); component.getChildren().add(it); } }
private ArrayList<Phone> phones;not? - rjhdby