为什么渲染后我的表单没有重置他的样式? [英] Why does my form isn't reseting his styling after render?

查看:277
本文介绍了为什么渲染后我的表单没有重置他的样式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有树形按钮的表单.其中一个是返回到上一页的取消"按钮.

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>

这篇关于为什么渲染后我的表单没有重置他的样式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆