Why does my form isn't reseting his styling after render?

泪湿孤枕 提交于 2019-12-13 09:46:26

问题


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>

回答1:


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>


来源:https://stackoverflow.com/questions/57716888/why-does-my-form-isnt-reseting-his-styling-after-render

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!