[ 
https://issues.apache.org/struts/browse/WW-2263?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=44217#action_44217
 ] 

Bob Tiernay commented on WW-2263:
---------------------------------

I agree that this is quite confusing and lead to a lot of message="".

Recommend making this this optional.

> validation annotation message attribute required even if using key attribute
> ----------------------------------------------------------------------------
>
>                 Key: WW-2263
>                 URL: https://issues.apache.org/struts/browse/WW-2263
>             Project: Struts 2
>          Issue Type: Bug
>          Components: XML Validators
>    Affects Versions: 2.0.9
>         Environment: Debian Linux
>            Reporter: chad michael davis
>             Fix For: 2.1.3
>
>
> This "bug" is about a quirky interface to validations using annotations.  In 
> the XML, the message element can contain the text of the message in its body, 
> or omit the body and use key attribute to name the key into the resource 
> bundles for retrieving the message.  
> Under annotations, the message attribute is always required.  Seems like you 
> should be able to specify a key and drop the message attribute but you can't. 
>  To specify a key you must use the  key attribute ( note, key and message are 
> sibling level attributes of the annotation itself; this is different from the 
> xml ) such as follows:
> @EmailValidator(type = ValidatorType.FIELD, key="email.invalid", 
> message="Email no good.")
> In this annotation, I still have a message specified, as a back up I guess.  
> But if I try to remove it altogether, the equivalent of what i do in XML with 
> the following:
>   <field-validator type="requiredstring">
>          <message key="username.required"/>
>      </field-validator>
> Then it blows up.  i guess this isn't a bug, but it seems kind of odd, 
> forcing the user to specify a message text that won't be used ( a default 
> message will be provided in the form of the key string itself if the 
> properties file is missing, right? ), and its clearly inconsistent between 
> the XML and the annotations

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to