[prev in list] [next in list] [prev in thread] [next in thread] 

List:       struts-dev
Subject:    [jira] [Commented] (WW-4272) Add a fieldKey attribute to validators
From:       "cococo42 (JIRA)" <jira () apache ! org>
Date:       2014-07-31 18:59:39
Message-ID: JIRA.12687626.1389099179902.88801.1406833179479 () arcas
[Download RAW message or body]


    [ https://issues.apache.org/jira/browse/WW-4272?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14081274#comment-14081274 \
] 

cococo42 commented on WW-4272:
------------------------------

In the given example we have the annotation:

@RequiredStringValidator(type = ValidatorType.SIMPLE, fieldName = "model.name", key = \
"errors.required")

supposing that in .properties we have:

errors.required=Field ${getText(fieldName)} is required

And my problem is that in spite of the fact that I've used an alias (a fieldKey) I \
must have also model.name in .properties.

I've tried this change in .properties:

errors.required=Field ${getText(fieldKey)} is required

But it doesn't work (I suppose that it's because fieldKey is not on the stack). Is \
there a problem with my notation or simply it's not possible to do what I would like \
to do? Obviously I don't want to use different errors keys for each required field in \
my application. If it's possible, could you tell me the correct notation in \
.properties and/or in validation annotation to achieve that? (to use only one \
errors.required entry in .properties which make reference to fieldKey attribute of \
the field).

> Add a fieldKey attribute to validators
> --------------------------------------
> 
> Key: WW-4272
> URL: https://issues.apache.org/jira/browse/WW-4272
> Project: Struts 2
> Issue Type: Improvement
> Components: Annotations, XML Validators
> Reporter: cococo42
> Priority: Minor
> Labels: ValidationMessages
> Fix For: 2.3.18
> 
> 
> Taking into account that in the struts2 taglib a field usually has a name and a key \
> (for its label), why there isn't also a fieldKey in validators? For example, you \
> have the following field in JSP: {code:xml}
> <s:textfield name="name" key="personalData.name"/>
> {code}
> and then in the Action (ModelDriven) :
> {code:java}
> @RequiredStringValidator(type = ValidatorType.SIMPLE, fieldName = "model.name", key \
> = "errors.required") {code}
> so you have to add to the .properties file {{personalData.name}} and also {{name}}. \
> I would prefer something like: {code:java}
> @RequiredStringValidator(type = ValidatorType.SIMPLE, fieldName = "model.name", \
> fieldKey = "personalData.name", key = "errors.required") {code}
> Am I missing something? If not, why does not exist the fieldKey in validators?
> Thank you in advance



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


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic