JSF 2.0 Saving dynamic form in database

I am writing an application that serves as an admin panel using JSF 2.0 and Hibernate. I have a JSP page with a JSF form whose elements are dynamically added using javascript (specific jQuery). Therefore, I cannot make any assumptions about how much data I need to process. I have a managed bean, but I don’t know how to set getters and setters for dynamic fields that I want to store in the database. The solution seems to be using a list, not a single item, but how to use the JSF item value tag? Could there be something like this:

<h:form>
<h:inputText id="i1" value="#{UserBean.list}" /> 
<h:inputText id="i2" value="#{UserBean.list}" />
<h:commandbutton id="submit" value="Submit" action="#{UserBean.submit}"/>
</h:form>

And driven bean:

@ManagedBean(name="UserBean")
@RequestScoped
public class UserBean {

   public UserBean() {
       List<String> list = null;


}
    public List getList() {
    return list;
}
    public List setList(List<String> newlist) {
    list = newList;
}

}

, , . . - ? . , .

+3
2

JSF jQuery. jQuery "plain vanilla" HTML DOM . JSF, . JSF HTML DOM, "plain vanilla" jQuery/JavaScript, JSF . JSF JSF , HTML DOM.

JSF JSF. , , , , :

+5

Source: https://habr.com/ru/post/1764564/


All Articles