I am trying to reset the form fields after choosing confirm button in a dialog form
<h:form id="form">
<p:panel id="panelform">
<h:panelGrid id="formulaire" columns="2">
...
</h:panelGrid>
</p:panel>
<p:dataTable ..... </p:dataTabe>
</h:form>
<p:confirmDialog style="position: absolute; width: 50px; border-color: blue" id="deleteData" message="Your Database Will be completely removed. Are you sure? "
appendToBody="true"
header="Delete List" severity="alert" widgetVar="deleteDialog">
<h:form>
<p:commandButton id="confirm" value="Confirm" actionListener="#{MB.deleteData()}" update=":form" ajax="true" oncomplete="deleteDialog.hide(); purchase.hide();" >
</p:commandButton>
<p:commandButton id="cancel" value="Later" onclick="deleteDialog.hide();" type="button" />
</h:form>
</p:confirmDialog>
My deleteData method in my sessionScoped bean is
public String deleteData() {
logger.log(Level.SEVERE, "*****delete Datas***** ");
dataBusinessLocal.deletedatas(datas);
logger.log(Level.SEVERE, "*****delete Data***** ");
dataBusinessLocal.deleteData(data);
datas.clear();
RequestContext.getCurrentInstance().reset("form:panelform");
return "datasList";
}
RequestContext.getCurrentInstance().reset("form:panelform");
clears cached values - in case a validation during ValidationPhase
did not work out correctly, the wrong values can be shown to the user on the following page.
I guess, what it not does is to clear values from the Model. Caused by this, during RenderResponse
the Model values will be written back to the xhtml-output. To prevent that, just set the input fields to null manually in your action method.
The following link "How to clear all input fields in p:dataTable?"suggests setting the input type="reset"
. If it works, give me a hint. :-)