title: JSF 2.0 Saving dynamic form to a database
body: <p>I'm writing an application that serves as an admin panel using JSF 2.0 and Hibernate. I have a JSP page with a JSF form which elements are added dynamically using javascript (jQuery to be specific). So I cannot make any assumption on how much data do I have to process. I have a managed bean but I don't know how to put the getters and setters for the dynamic fields that I want to save in a database. The solution seems to use a list rather than a single element but how do I use the value tag of the JSF element? Could it be something like this:</p>
  
  <pre><code>&lt;h:form&gt;
  &lt;h:inputText id="i1" value="#{UserBean.list}" /&gt; 
  &lt;h:inputText id="i2" value="#{UserBean.list}" /&gt;
  &lt;h:commandbutton id="submit" value="Submit" action="#{UserBean.submit}"/&gt;
  &lt;/h:form&gt;
  </code></pre>
  
  <p>And the managed bean:</p>
  
  <pre><code>@ManagedBean(name="UserBean")
  @RequestScoped
  public class UserBean {
  
     public UserBean() {
         List&lt;String&gt; list = null;
  
  
  }
      public List getList() {
      return list;
  }
      public List setList(List&lt;String&gt; newlist) {
      list = newList;
  }
  
  }
  </code></pre>
  
  <p>However, the above code does not seem correct and certainly does not work. I need to bind two or more values of the inputtext to the same list. Does anyone have any suggestions how to solve it? Thanks in advance.
  Regards,
  sass.</p>