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. > > Any helpers? > > Cheers, Allistair. > > > > <FONT SIZE=1 FACE="VERDANA,ARIAL" COLOR=BLUE> > ------------------------------------------------------- > QAS Ltd. > Developers of QuickAddress Software > <a href="http://www.qas.com">www.qas.com</a> > Registered in England: No 2582055 > Registered in Australia: No 082 851 474 > ------------------------------------------------------- > </FONT> > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]