struts-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "cococo42 (JIRA)" <>
Subject [jira] [Commented] (WW-4272) Add a fieldKey attribute to validators
Date Thu, 31 Jul 2014 18:59:39 GMT


cococo42 commented on WW-4272:

In the given example we have the annotation:

@RequiredStringValidator(type = ValidatorType.SIMPLE, fieldName = "", 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 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:
>             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=""/>
> {code}
> and then in the Action (ModelDriven) :
> {code:java}
> @RequiredStringValidator(type = ValidatorType.SIMPLE, fieldName = "", key =
> {code}
> so you have to add to the .properties file {{}} and also {{name}}. I
would prefer something like:
> {code:java}
> @RequiredStringValidator(type = ValidatorType.SIMPLE, fieldName = "", fieldKey
= "", 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

View raw message