struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Allistair Crossley" <Allistair.Cross...@QAS.com>
Subject Validator not plugging in keyed values
Date Fri, 06 May 2005 15:12:07 GMT
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: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message