I have p:dataTable in my page. When I specify number of items in another inputText field, the specified number of rows are generated for some created items. If I increase the number of items, more rows are added, if I decrease, the rows are subtracted. If I specify 0 as number of items, all rows are removed and the model is cleared. Now, the inputText component in dataTable rows has some validation via converter. If that validation fails and I set number of items to 0, and then to more than 0, generated rows inputText fields have cached values from when validation failed even though the model is created new.
After validation fails, as I understand, EditableValueHolder component value is cached in its value field. So for a regular field, to clear component's value I need to call
((EditableValueHolder) component).setValue(null);
((EditableValueHolder) component).setValid(true);
This works fine. However, when the inputText is inside datatable, this does not work. I have binded datatable component to my bean and tried accessing inputTexts from datatable component and then clearing them. It seems I cannot access them, datatable component has generic children list of columns, that does not correspond to different datatable rows. Is there any way to access datatable input components used in different rows programatically? I am using primefaces by the way. I then tried binding specific inputText component to my bean by specifying
<p:dataTable>
<p:column>
<h:inputText binding=#{myBean.component}/>
</p:column>
</p:dataTable>
attribute just to see if I can clear at least one inputText from its cached value. However, when I access the component, it has its value and submittedValue fields already null.. But still, on page rerender, datatable inputText components show old values that were set when validation failed.. Validation is done by converter by the way. Any help on how to clear cached values would be appreciated.