Adding a general message if there is no check

I have a form with all types of fields, and for each field I have a validator and a message p: when the validation is complete. I need to add a message at the top of the \ form page using custom text (something like: "fix the whole problem in the form") only if I have validation (I don't want to use a growl).

how to install a custom message and how to call it (it is not tied to a specific field).

I am using JSF 2 and the main value is 3.4.

+4
source share
1 answer

You can post

<h:panelGroup id="my_custom_error_msg">
    <h:outputText value="Please fix all problem in form" 
        rendered="#{facesContext.validationFailed}"/>
</h:panelGroup>

And draw it when submitting the form, for example:

<h:commandButton value="Submit">
    <f:ajax render="@form my_custom_error_msg" execute="@form"/>
</h:commandButton>

, bean , rendered

rendered="#{facesContext.validationFailed or not empty facesContext.messageList}"

+2

Source: https://habr.com/ru/post/1523867/


All Articles