Reputation: 1523
Is there an easy way to customize FacesMessages
that are created by bean validation annotations?
In my case I'm using:
import javax.validation.constraints.NotNull;
@NotNull (message = "Date is required!")
private Date date;
The message is being added to the facescontext correctly, but my message is both summary and detail at the same time, so it's displayed twice. How can I avoid that behavior?
Edit: Solution found
I found a solution as follows:
I'm using p:growl
to display my facesMessages. Using the showSummary
tag allows to hide the summary text.
For sure, the tag supports EL, so it is asking a bean for the boolean value. The job is done by method
public boolean isShowSummary(){
return ! facesContext.isValidationFailed();
}
Upvotes: 2
Views: 290
Reputation: 1523
I found a solution as follows:
I'm using p:growl
to display my facesMessages. Using the showSummary
tag allows to hide the summary text.
For sure, the tag supports EL, so it is asking a bean for the boolean value. The job is done by method
public boolean isShowSummary(){
return ! facesContext.isValidationFailed();
}
Upvotes: 1