The "bundle" attribute in Commons Validator (i.e. in your validation.xml) is
not supported in the current release of Struts (Version 1.2.4) which is why
it isn't finding your <arg> values. This has now been implemented in the
latest Struts version (version 1.2.7) which I announced today:

http://www.mail-archive.com/user%40struts.apache.org/msg26228.html

In that version there are a couple of pages in the struts-examples webapp
showing use of alternative message resource bundles. Also I posted some
stuff recently here about this:

http://www.niallp.pwp.blueyonder.co.uk/HelpTagsErrorsAndMessages.html#section7_2

Having said all that, looks like you're doing everything right - except you
need Version 1.2.7 (and Validator 1.1.4)

Niall

----- Original Message ----- 
From: "Allistair Crossley" <[EMAIL PROTECTED]>
Sent: Friday, May 06, 2005 4:51 PM


Some more information; my message resources were declared as follows

<message-resources key="MYRESOURCES" null="false"
parameter="com.qas.newmedia.internet.core.ApplicationResources" />

Note the use of a key on the bundle. In my JSP output of the errors I used

<logic:messagesPresent>
<ul>
<html:messages id="error" bundle="MYRESOURCES">
<li><bean:write name="error" /></li>
</html:messages>
</ul>
</logic:messagesPresent>

Interestingly, then, when I remove the key from message-resources AND remove
the bundle instruction from the html:messages tag, the whole thing works.

I have to say, the whole struts validator stuff is a little unclear from the
documentation. The distinction between ActionMessages and ActionErrors and
when to use html:errors and html:messages is not clear.

Furthermore, the use of bundle on html:messages DOES work when you wish to
use bean:message or indeed, just iterating over ActionMessages that were not
linked to validator.

Some clarification on the matter would be appreciated,

Allistair

> -----Original Message-----
> From: Allistair Crossley
> Sent: 06 May 2005 16:12
> To: user@struts.apache.org
> Subject: Validator not plugging in keyed values
>
>
> Hello Again,
>
> Having a spot of bother with validating an ActionForm. It's
> all setup and I believe accurately.
>
> I have 2 text fields. Each are specified as needing the
> required rule. I do not ask my action mapping to validate.
>
> <?xml version="1.0" encoding="iso-8859-1"?>
> <!DOCTYPE form-validation SYSTEM
> "http://intranet/iq/j2ee/validator_1_1_3.dtd";>
> <form-validation>
>     <formset>
>         <form name="testForm">
>             <field property="testField" depends="required">
> <arg position="0" bundle="core"
> key="test.field.key" />
>     </field>
>     <field property="testField2" depends="required">
> <arg0 key="test.field2.key" />
>     </field>
>         </form>
>     </formset>
> </form-validation>
>
> Instead I run the validation in an Action class
>
> ActionMessages errors = form.validate();
>
> I log the output of this, and I accurately get 1 error or 2
> errors according to whether I left one or two fields blank in
> my form. So that's fine. I save the errors container using
> saveErrors(request, errors) and back in the JSP:
>
> <logic:messagesPresent>
>   <ul>
>     <html:messages bundle="core" id="error">
>       <li><bean:write name="error" /></li>
>     </html:messages>
>   </ul>
> </logic:messagesPresent>
>
> This, too, works to some extent. In my ApplicationResources, I have:
>
> errors.required={0} is required.
> test.field.key=Some random value
> test.field2.key=Some random value 2
>
> The problem I am seeing is that when my form validates, all I
> get back are bullet points with
>
> - is required
>
> which is the errors.required key's value. That is,
> test.field.key's value is not being inserted into the {0}
> placeholder of the errors.required value.
> Like I say, everything is working in terms of the system
> spotting I have errors according to the rule, and the
> messages are being found by validator because it finds "is
> required". But the error is that is does not pump in the
> value from the custom key.



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to