为什么渲染后我的表单没有重置他的样式?
我有一个带有树形按钮的表单.其中一个是返回到上一页的取消"按钮.
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.
这是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>
调用添加乘客表格的按钮的代码:
<p:commandButton
value="#{label['manageVipLoungeEntrance.button.addPassenger']}"
action="#{manageVipLoungeEntranceExtMB.setRenderStatus(3, 1)}"
actionListener="#{manageVipLoungeEntranceExtMB.hideMainForm}"
update=":filterVipLoungeForm :horizontal">
</p:commandButton>
取消按钮的代码:
<p:commandButton
value="#{label['manageVipLoungeEntrance.button.cancel']}"
onclick="showLocalDate()"
action="#{manageVipLoungeEntranceExtMB.setRenderStatus(0, 1)}"
actionListener="#{manageVipLoungeEntranceExtMB.setRenderStatus(3, 0)}"
update=":filterVipLoungeForm :horizontal">
</p:commandButton>
这会从支持bean调用setRenderStatus的方法中进行设置,该方法用于设置表单以及他的呈现状态,以在rendered属性中进行评估.
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.
在此过程中,取消按钮的表单的呈现状态设置为false,而上一个表单的呈现状态设置为true.
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.
hideMainForm方法调用两次setRenderStatus方法,将主窗体的呈现状态设置为false,将添加乘客的呈现状态设置为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.
对不起,我忘了添加以下两种形式的渲染评估代码:
Sorry I forgot to add the code of the rendered evaluation of the two forms involucrated in this:
"frmAddPax"表单的呈现状态验证
<h:form id="frmAddPax" rendered="#{manageMB.renderStatus.isRenderFormAddPax()}">
表单"filterVipLoungeForm"的呈现状态验证
<h:form id="filterVipLoungeForm" style="width:95% !important;"
rendered="#{manageMB.renderStatus.isRenderFormMain()}"
onkeypress="return event.keyCode != 13">
我已经尝试过使用<p:resetInput>
,但是它不起作用,因此我希望ID为frmAddPax的表单重设他的身份,但是它不起作用:
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>
我使用了<p:ajax resetValues="true">
,并且该代码可以根据需要工作.
我真的不知道为什么要使用ajax而不是resetInput.
I used the <p:ajax resetValues="true">
and this one works as I needed.
I really don't know why work with the ajax and not with the resetInput.
<p:commandButton
value="#{label['manageVipLoungeEntrance.button.cancel']}"
onclick="showLocalDate()"
action="#{manageVipLoungeEntranceExtMB.setRenderStatus(0, 1)}"
actionListener="#{manageVipLoungeEntranceExtMB.setRenderStatus(3, 0)}"
update=":filterVipLoungeForm :horizontal">
<p:ajax update=":frmAddPax" resetValues="true" />
</p:commandButton>