I have a form with tree buttons on in. One of them is the "Cancel" button that goes back to the previous page.
The problem is there is any validation issue, like a mandatory field not submited, the styling of the field is not reset when I go back to the form.
This is a simplified structure of the xhtml:
<panel id="horizontal">
<form id="filterVipLoungeForm">
</form>
<form id="frmAddPax">
<form id="frmAccessType">
</form>
</form>
<panelGrid>
<commandButton value="agregar" />
<commandButton value="limpiar" />
<commandButton value="cancelar" />
</panelGrid>
</panel>
The code of the button that calls the add passenger form:
<p:commandButton
value="#{label['manageVipLoungeEntrance.button.addPassenger']}"
action="#{manageVipLoungeEntranceExtMB.setRenderStatus(3, 1)}"
actionListener="#{manageVipLoungeEntranceExtMB.hideMainForm}"
update=":filterVipLoungeForm :horizontal">
</p:commandButton>
The code of the cancel button:
<p:commandButton
value="#{label['manageVipLoungeEntrance.button.cancel']}"
onclick="showLocalDate()"
action="#{manageVipLoungeEntranceExtMB.setRenderStatus(0, 1)}"
actionListener="#{manageVipLoungeEntranceExtMB.setRenderStatus(3, 0)}"
update=":filterVipLoungeForm :horizontal">
</p:commandButton>
This calls a method from the backing bean calls setRenderStatus that set the form and he's render status to be evaluated in the rendered attribute.
In this process the render status of the cancel button's form is set to false and the render status of the previous form is set to true.
The hideMainForm method calls two times the setRenderStatus method, setting the main form render status to false and the add passenger render status to true.
The problem there is any validation error and if I go back to the previous page and come back to the form I'm still getting the validation errors.
[EDIT]
Sorry I forgot to add the code of the rendered evaluation of the two forms involucrated in this:
Render status validation for form "frmAddPax"
<h:form id="frmAddPax" rendered="#{manageMB.renderStatus.isRenderFormAddPax()}">
Render status validation for form "filterVipLoungeForm"
<h:form id="filterVipLoungeForm" style="width:95% !important;"
rendered="#{manageMB.renderStatus.isRenderFormMain()}"
onkeypress="return event.keyCode != 13">
I have tried by using the <p:resetInput>
but it didn't work, with this I was expecting the form with the id frmAddPax reset his status but it didn't work:
<p:commandButton
value="#{label['manageVipLoungeEntrance.button.cancel']}"
onclick="showLocalDate()"
action="#{manageVipLoungeEntranceExtMB.setRenderStatus(0, 1)}"
actionListener="#{manageVipLoungeEntranceExtMB.setRenderStatus(3, 0)}"
update=":filterVipLoungeForm :horizontal">
<p:resetInput target=":frmAddPax" />
</p:commandButton>
See Question&Answers more detail:
os