Add a row to h:dataTable via AJAX with request-scoped bean without losing the row data <p>I think the title tells it all: I want to add a row to dataTable over AJAX. The datatable has input fields where user can put text. As simple as that, a pretty common case.</p> <p>With session-scoped bean this no issue, as the same bean is updated over and over again. However, I want to do this in request scope. For each request, I guess I want to create a new bean and to populate it with the values from my form. Then I want my <code>commandButton</code>'s <code>action</code> to add a new row, finally render the <code>dataTable</code> over AJAX as usual.</p> <p>The issue is that I don't know how to make JSF fill the newly-created request-bean with the current data from the dataTable component?</p> <p>There was <a href="http://stackoverflow.com/questions/2278353/how-to-dynamically-add-a-row-in-a-table-in-jsf">a similar question</a> asked and <a href="http://stackoverflow.com/questions/2278353/how-to-dynamically-add-a-row-in-a-table-in-jsf/2280157#2280157">answered</a>. However, that solution seems to reload the contents of the dataTable each time it is refreshed and manually inserts empty elements for the newly-inserted rows like this:</p> <pre><code>// Preserve list with newly added items. ror (int i = 0; i &lt; (Integer) count.getValue(); i++) { list.add(new Item()); } </code></pre> <p>To me, it seems that this approach also wipes the possible changes that the user did to rows (new and old)... if he doesn't first save them.</p> <p>Any pointers?</p>