struts-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "cococo42 (JIRA)" <j...@apache.org>
Subject [jira] [Comment Edited] (WW-4272) Add a fieldKey attribute to validators
Date Thu, 31 Jul 2014 19:01:42 GMT

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

cococo42 edited comment on WW-4272 at 7/31/14 7:01 PM:
-------------------------------------------------------

In the given example we have the annotation:

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

supposing that in .properties we have:

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

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:

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

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).


was (Author: cococo42):
In the given example we have the annotation:

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

supposing that in .properties we have:

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

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:

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

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)

Mime
View raw message