I'm trying to add a new row in a Primefaces datatable, then I would like to submit the content of this table and do some business logic. The datatable model is a collection that is maintained in a ViewScoped managed bean.

I'm using JSF 2.1 with Primefaces 3.3.

Short example:

```
    <h:form id="my-form">
        <p:dataTable value="#{testBean.list}" var="s" id="datatable">
            <p:column>
                <h:inputText value="#{s}"/>
            </p:column>
            <f:facet name="footer">
                <p:commandButton value="Add row" action="#{testBean.addRow()}" process="@form" update="@form" immediate="true" />
                <p:commandButton value="Do stuff" action="#{testBean.doSomeLogic()}" process="@form" update="@form"/>
            </f:facet>     
        </p:dataTable>
    </h:form>

```

Managed Bean:

```
@ManagedBean
@ViewScoped
public class TestBean implements Serializable {

private List<String> list;

public TestBean() {
}

@PostConstruct
public void init() {
    list = new ArrayList<String>();
    list.add("one");
    list.add("two");
}

public void addRow(){
    list.add(new String());
}

public void doSomeLogic(){
    for (String string : list) {
        System.out.println(string);
    }
}

// getters and setters

}

```

What actually happens: 

* the user clicks on "add row" button, a new row is added (I need immediate to be true so no validation is done, those fields are part of a bigger form).
* the user clicks on "do stuff", the collection has the right size (with new rows) but the user's input in not taken into account (neither modification to pre exiting rows, nor new values in freshly added rows).

What can I do to submit the new values too? I'm only beginning JSF and I'm not sure I'm already 100% getting it.

Thanks for your help.

Possible duplicates:

* [Add a row to h:dataTable via AJAX with request-scoped bean without losing the row data](https://stackoverflow.com/questions/3635013/add-a-row-to-hdatatable-via-ajax-with-request-scoped-bean-without-losing-the-ro)
* [How to Dynamically add a row in a table in JSF?](https://stackoverflow.com/questions/2278353/how-to-dynamically-add-a-row-in-a-table-in-jsf/2280157#2280157)
* [JSF datatable: adding and removing rows clear rows values](https://stackoverflow.com/questions/11092513/jsf-datatable-adding-and-removing-rows-clear-rows-values)

**Edit:** problem is solved thanks to Jitesh, a working example can be found here: [JSF2, can I add JSF components dynamically?](https://stackoverflow.com/questions/3409053/jsf2-can-i-add-jsf-components-dynamically?lq=1)