Just wondering if it is possibly to dynamically add elements (in AJAX fashion) to a form using h:dataTable without always submitting the current contents? Normally one has to always send the full contents of the datatable, because the whole datatable is re-rendered. If the datatable gets big (say, 100 rows) this can radically slow down the page, as each row always gets posted.
Doing this with raw JS this is not a problem, but can it be avoided with JSF? Of course if we don’t send all the row data with the AJAX request, it remains lightweight, but we will lose all the changes made to the form.
Using JSF, which re-renders the whole component when making changes on it, this is simply not possible.
As the whole component is re-rendered, all changes to it are lost except when they are submitted to the server before refresh.
JSF is designed in a way that this is not (easily) possible. One good hack to this would be to keep track of those rows that have been modified and then submit only those. This can be achieved by attaching a change listener to each field in the form.