Hi All,
I am wrecking my brain trying to get field names in error messages to be displayed correctly when using VisitorFieldValidator annotation and (for example) RequiredStringValidator annotation in the in the Model Bean, basically I have a CustomerAction with:
@VisitorFieldValidator()
public Customer getCustomer() {
return this.customer;
}
Then in the Customer bean:
@RequiredStringValidator(message = "", key = "Message.required", trim = true)
public String getCustomerName() {
return super.getCustomerName();
}
Then in the JSP within the Struts form tag:
<s:textfield key="customer.customerName" />
The validation works correctly, however when the messages are displayed within the JSP indicating that the customer name field is missing they come up as:
nullcustomerName is a required field
If I change the
@VisitorFieldValidator()
annotation to:
@VisitorFieldValidator(addPrefix=false)
I get:
customerName is a required field
despite the fact that within my resource bundle I have:
Message.required = ${getText(fieldName)} is a required field
customer.customerName = Company Name
I tried defining the fieldName manually within the RequiredStringValidator annotation, but this does not help.
When the form is initially displayed within the JSP the customer.customerName is resolved corrrectly to Company Name.
Any clues would be much appreciated. Thank you.