I try to dynamically add row in datatable. I want the user click on add button which open a dialog with a form, and then click on "ok" button to add the row.
I 'm able to do this, but just the first time. If I retry, it doesn't work but if I refresh I see the new row.
Here is my dialog, I include the form :
Code: Select all
<p:dialog header="My Dialog" widgetVar="dialog">
<h:form>
<ui:include src="form.xhtml" />
<p:commandButton value="Ok" update="@form :main_form" actionListener="#{myBean.addRow}" oncomplete="handleDialogClose(xhr, status, args)" />
</h:form>
</p:dialog>
Code: Select all
public void addRow(ActionEvent event) {
MyObject object = myFormBean.getMyObject();
((Collection<MyObject>) this.getDataModel().getWrappedData()).add(object);
}
I really don't understand the problem.
Thanks.