-
1. Re: rich:validator question
rhanus Nov 8, 2012 8:36 AM (in response to strannik)1 of 1 people found this helpfulfacelet snippet here works for me well
use f:validateRequired since it's prefered kind of validation
-
2. Re: rich:validator question
strannik Nov 9, 2012 3:08 AM (in response to rhanus)Hi, Radim
Thank you for the small hint. This is useful solution. However I have to update all my input components and embed this validator.
What is worse the validation message is not customizable. I specified requiredMessage attribute before and it was displayed upon validation error.
Now it is ignored.
If I want to achieve the same result now I have either to override JSF message bundles or write my own validator which will generate message with necessary text.
Not big piece of work but another one in the long list TODOs in the JSF2 migration process ...
-
3. Re: rich:validator question
rhanus Nov 9, 2012 4:25 AM (in response to strannik)1 of 1 people found this helpfulI specified requiredMessage attribute before and it was displayed upon validation error.
Now it is ignored.
attribute requiredMessage is connected with attribute required
you should use attribute validatorMessage (and converterMessage in case of invalid data type as described in link above)
If I want to achieve the same result now I have either to override JSF message bundles or write my own validator which will generate message with necessary text.
BTW message bundles are very usefull since you may easily provide multilingual applications
-
4. Re: rich:validator question
strannik Nov 9, 2012 3:20 PM (in response to rhanus)Thank you, Radim.
It's weird that requiredMessage is not used. What I see from the JSF sources(RequiredValidator class)
if (component instanceof UIInput) { requiredMessageStr = ((UIInput) component).getRequiredMessage(); } Anyway validatorMessage works for me. However what if I use several validators?
Will they all use the validatorMessage attribute in case of error?
-
5. Re: rich:validator question
rhanus Nov 12, 2012 8:49 AM (in response to strannik)Anyway validatorMessage works for me. However what if I use several validators?
Will they all use the validatorMessage attribute in case of error?
yep they will
you may also supply converterMessage if you want a custom message to handle illegal data of given type