[ 
https://issues.apache.org/jira/browse/MYFACES-3903?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Mike Kienenberger resolved MYFACES-3903.
----------------------------------------

    Resolution: Won't Fix

Adding new attributes to core validators would have to be addressed by changing 
the JSF specification, so it's not something Apache Myfaces can do.  Here's 
where to report the issue:

https://javaserverfaces-spec-public.java.net/
https://java.net/jira/browse/JAVASERVERFACES_SPEC_PUBLIC

Creating custom subclasses of each validator/converter which add support for 
custom message attributes is probably your best bet, and relatively easy to 
implement.  You can ask about this on the MyFaces Users mailing list.   It's 
not as complicated as it might seem at first, and JSF is designed to be 
extended this way, although few people seem to do so.

> Allow custom validation message per validator
> ---------------------------------------------
>
>                 Key: MYFACES-3903
>                 URL: https://issues.apache.org/jira/browse/MYFACES-3903
>             Project: MyFaces Core
>          Issue Type: Improvement
>    Affects Versions: 2.2.3
>         Environment: myfaces 2.2.3, java 7, tomcat 7
>            Reporter: Rene O
>
> At the moment only this is possible:
> {code}
> <h:inputText value="#{myBean.value}" validationMessage="My validation 
> message">
>       <f:validateLength minimum="1" maximum="30"/>
>       <f:validateRegex pattern="^\d{5}$" />
> </h:inputText>
> {code}
> You can't define a validation message per validation event, but only one 
> message for all validations. 
> As a workaround you can write a custom validator, which contains all 
> validations rules, and then throw ValidatorExceptions containing your desired 
> messages.
> I think, that this limits the usablity.
> It should be possible to do the following without writing a custom validator
> {code}
> <h:inputText id="myFieldA" value="#{myBean.value}">
>       <f:validateLength minimum="1" maximum="5" validationMessage="My custom 
> validation message for validateLength"/>
>       <f:validateRegex pattern="^\d{5}$" validationMessage="My custom 
> validation message for validateRegex"/>
> </h:inputText>
> <h:inputText id="myFieldB" value="#{myBean.value}">
>       <f:validateLength minimum="1" maximum="5" validationMessage="Another 
> custom validation message for validateLength"/>
>       <f:validateRegex pattern="^\d{5}$" validationMessage="Another custom 
> validation message for validateRegex"/>
> </h:inputText>
> {code}



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to