struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Per Johansson <perj...@gmail.com>
Subject RequiredFieldValidator and error message from property file via key
Date Fri, 04 Dec 2009 10:25:18 GMT
Hi,

I'm trying to get error messages from a resource bundle.

This is the code for my action class:

@RequiredFieldValidator(type=ValidatorType.FIELD,
key="myFieldErrorMsg", message="Error!!!!")
public void setMyField(int myField) {
    this.myField = myField;
}

@Override
public void validate() {
    if (!isMyFieldValid(myField)) {
        addFieldError("myField", getText("myFieldErrorMsg"));
    }
}

When validation fails for setMyField I don't get the expected error
message from my resource bundle.
Instead I get a struts default error message "Invalid field value for field ..."

But when i call getText from the validate method, I get the expected
error message.

How can I get a message from a resource bundle using the annotation
based validator?
I'm using weblogic 10.0.


/Best regards, Per Johansson

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message