Java
Java

Reputation: 2489

How to show a single validation message for the whole JSF form?

I have a JSF form with number of fields. PrimeFaces normally does validation in this way: http://www.primefaces.org/showcase-labs/ui/pprAjaxValidations.jsf

But I have more than 30 fields in my JSF form, so if I did this validation, it does not look good. How can I provide only a single message like "Please fill missing values" for any field if it is missing?

Upvotes: 1

Views: 2366

Answers (1)

BalusC
BalusC

Reputation: 1108567

Your could render the message conditionally based on FacesContext#isValidationFailed().

<h:outputText value="Please fill out missing values" rendered="#{facesContext.validationFailed}" />

Note that this would only make sense if you have only the required="true" validation enabled and you thus don't use any converters or other more specific validators for which the enduser would of course like to see a more specific message.

Upvotes: 3

Related Questions