Hi struts users!
I'm on my way to change from XML based validation to annotation validation.
I've manage to get it working, but (probably due to my little knowledge
of Java annotations) there are some things I can't get to work, so I
apologise if this question is not entirelly Struts related.
I'm trying to get the following XML based validation to annotations at
method level:
<validators>
<field name="user.name">
<field-validator type="requiredstring">
<message>${getText("error.required",
{getText("label.name")})}</message>
</field-validator>
</field>
...
</validators>
So far this works in my action:
@Validations(
requiredStrings = {
@RequiredStringValidator(
fieldName = "user.name",
message = "Name required.")}
)
public String save() {
...
return SUCCESS;
}
But the problem is with this bit <message>${getText("error.required",
{getText("label.name")})}</message> which retrieves a message that has
arguments (also retrieved from a resource bundle).
So how should I use the annotation parameters (key or message) to
retrieve a key with args?
I tried message = getText("error.required", new
String[]{getText("label.name")})
but of course values of annotation params must be constant, and I cannot
define a static value that depends on a getText() lookup.
Is this ever possible to do with annotations?
Any help appreciated!!
Summary: How to use i18n messages with args using annotations for field
validation?
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org