validation - Struts 2 @RequiredStringValidator messageParams -
in message resources file have following lines:
error.required={0} required labels.email=e-mail
to validate e-mail field using annotation validators, this:
@requiredstringvalidator(key="error.required") public string getemail() { return email; }
my question is: how can pass labels.email
resource value {0}
param message using requiredstringvalidator
annotation? trying messageparam
property without success.
try this
@requiredstringvalidator(message = "${gettext('error.required', new java.lang.string[] {gettext('labels.email')})}")
the gettext()
used if action extends actionsupport
resource messages key specified parameter. applied 2 times in same expression build message. first time without parameter, second parameter , used overloaded gettext()
implementation.
Comments
Post a Comment