Ignore validation when you press CommandButton

I have a page in which I edit some entity. This page has two command buttons. One is Back and one is Save, and on this page I have a form with input fields (idInputSubject). Some of them are necessary, some are not.

How can I guarantee that I press the "Back" button (cancel editing and return), the check will be ignored, which is not the case now. Now, when I press the back or save confirmation buttons, if I did not fill out the required entry with the correct values ​​(idInputSubject).

The "Back" and "Save" buttons are in the same form:

<h:form id="idFormMeasureDetail" styleClass="bodyForm" prependId="false">
   ...
   <p:commandButton value="#{contentMB.msg.label_back.value}"
        action="#{chooseMeasureControllerMB.aSearch}"
        rendered="#{detailMeasureMB.navigation eq 0}" ajax="false"
        icon="ui-icon-arrowreturnthick-1-w"/>
   <p:commandButton value="#{contentMB.msg.button_save.value}" ajax="false" 
        icon="ui-icon-disk" actionListener="#{detailMeasureControllerMB.alApplyChanges}" 
                    title="#{contentMB.msg.tip_Apply.value}" />

   ...
   <p:inputTextarea id="idInputSubject" value="#{detailMeasureMB.measure.aufgabe}"
    readonly="#{!userSessionMB.supervisor and !detailMeasureMB.isCreator}"
    required="#{globalSessionMB.globalWebOptionsMap['MMRequiredSubject'].propvalue}"
            title="#{contentMB.msg.tip_Betreff.value}"
            autoResize="false" style="width:100%;" >
   </p:inputTextarea>
   <p:message id="inputSubjectMsg" for="idInputSubject" display="icon" />
   ...

</h:form>

ChooseMeasureControllerMB:

@ManagedBean(name = "chooseMeasureControllerMB")
@RequestScoped
public class ChooseMeasureControllerMB extends BaseMeasureControllerMB {
...
public String aSearch() {
            ...
    // navigate to target-page
    return "/pages/mm/showMeasuresList.xhtml?faces-redirect=true";
}
...
}
+5
source
2

/ ,

immediate="true"

immediate="true" BalusC

, , imemdiate =" true works

+10

, "", , . , Java- script .

, , , . . , <p:commandButton> <p:button> . , .

0

All Articles