struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Niall Pemberton" <niall.pember...@blueyonder.co.uk>
Subject Re: Validator maxlength, minlength
Date Fri, 02 Jul 2004 11:10:14 GMT
The variable name for your maxlengths are incorrect - change the names to
"maxlength"....

<var-name>maxlength</var-name>
<var-value>${addressLength}</var-value>
</var>

<var>
<var-name>maxlength</var-name>
<var-value>${cityLength}</var-value>
</var>

Niall

----- Original Message ----- 
From: "Jim Barrows" <jbarrows@sssc.com>
To: <user@struts.apache.org>
Sent: Thursday, June 24, 2004 12:32 AM
Subject: Validator maxlength, minlength


In essence, maxlength and minlength are working backwords from what I would
expect.
I fully expect this to pebcak error, but I can't seem to find it.
I'm getting :
Address 1 can not be greater than 30 characters.
Address 2 can not be greater than 30 characters.
City can not be greater than 30 characters.

When address 1 is 27 characters, address 2 is blank and city is 10.
Clearly I've fat fingered something somewhere.
Can anyone help me figure out why maxlength is acting like minlength?


btw.... minlength also works backwards.

Validation file looks like:
...
<constant>
<constant-name>addressLength</constant-name>
<constant-value>30</constant-value>
</constant>
<constant>
<constant-name>cityLength</constant-name>
<constant-value>30</constant-value>
</constant>
...
<field property="address1" depends="required, maxlength">
<arg0 key="ChangeAddressForm.address1" />
<arg1 name="maxlength" key="${var:addressLength}" resource="false" />
<var>
<var-name>addressLength</var-name>
<var-value>${addressLength}</var-value>
</var>
</field>
<field property="address2" depends="maxlength">
<arg0 key="ChangeAddressForm.address2" />
<arg1 name="maxlength" key="${var:addressLength}" resource="false" />
<var>
<var-name>addressLength</var-name>
<var-value>${addressLength}</var-value>
</var>
</field>
<field property="city" depends="required,maxlength">
<arg0 key="ChangeAddressForm.city" />
<arg1 name="maxlength" key="${var:cityLength}" resource="false" />
<var>
<var-name>cityLength</var-name>
<var-value>${cityLength}</var-value>
</var>
</field>
...
and the form:
...
private String address1 = null;
private String address2 = null;
private String city = null;
...
appropriate getters setters etc.

James A Barrows

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org





---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message