Feeds:
Posts
Comments

Archive for the ‘STRUTS’ Category

Prerequisites:
Knowledge about Struts Validator Plugin & Message Resources.

Problem:

Most of the project tend to group the resources into more than one resource bundles.
And specify all the message resources with ‘key’ attribute in <message-resources> tag.

<message-resources key=”en” parameter=”resources”/>
<message-resources parameter=”ValidationErrors” null=”false” key=”err”/>

In ValidationErrors.properties I have the following messages,

errors.required={0} is required.
errors.missing.Name=Name

If I intend to use Validator with ‘required’ type for ‘Name’, and use <html:errors bundle=”err” />
I get the following message displayed in screen..

???en_US.errors.missing.Name??? is required.

The reason being “errors.required” is extracted correctly from bundle ‘err’ as it is specified in <html:errors/> tag.
Whereas the argument of the message ‘errors.missing.Name’ is taken from the default bundle of struts, and
sicne Validator cannot find the key…it returns the above message.

Solution:

Configure your <field> tag validation.xml like the following…

<field property=”activeApplicationId” depends=”required“>
       <msg name=”required” bundle=”err” key=”errors.required”/>
        <arg0 key=”missing.applicationId” bundle=”err”/>
</field>

Specify bundle in <msg> tag with name = “validation type”
and key = “your message resources key for that validation type”

I know that this actually sucks, but this is the only workaround for the problem.

Advertisements

Read Full Post »