I have some issues with my validation messages since I use 9.7 instead of 7.1.3.
If I set on my text input field required = true. The validation message shows the id of the text input field. Is it possible to remove this id in the validation message?
My other problem is with a custom validator. In 9.7 the mws set to the validation message the css class “portlet-msg-info” instead of “portlet-msg-alert”. So the message is grey and not red like the is required message.
The default “required” message uses this pattern: “{0}: Validation Error: Value is required.” Where {0} is replaced by the label associated with that input control. If no label attribute is specified, then it uses the clientId as the label.
Alternatively, JSF 2.x supports supplying your own custom message via the “requiredMessage” property of the input control that is used instead of the default message.
For your custom validator, can you provide a snippet of how you are raising the ValidatorException? The FacesMessage you pass to the ValidatorException constructor has the ability to specify the Severity (see [1]).
Supplying your own custom message via the “requiredMessage” property of the control is the best practice way of changing the message as it would ensure that both the client-side validation and server-side validation use your custom text.
I haven’t tested this, but you may try raising the ValidatorException with a different severity (the default is FacesMessage.SEVERITY_INFO) with something like this to affect how it is displayed:
throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR, msg, null));
Of course that would be a solution but than I have to change every text input that is required. I will try to avoid this because I have tons of portlets :roll: