Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
136 views
in Technique[技术] by (71.8m points)

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

I have a form with tree buttons on in. One of them is the "Cancel" button that goes back to the previous page.

enter image description here

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.

enter image description here

[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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...