I have been learning JSF recently and found a very nice article at http://balusc.blogspot.com/. I keep going back to it for more information. After banging my head a bit trying to get a grasp on how to dynamically add fields to a form I remembered the article and there in the middle was information about dynamically adding data to a JSF form.
Add new rows to datatable
Adding new rows to the datatable is in fact easy, just add a new and empty MyData item to the dataList and let the rendered attribute of the components intercept on the ID being null. Also add a counter to inform the bean how many rows are been added so that it knows how to prepare the list and how many of the last rows have to be saved.
But in the request scope you’ll have to store the counter in a HtmlInputHidden component bound to the page so that its value can be retained in the next request, regardless the outcome of the validations phase.