struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jim Barrows" <jbarr...@sssc.com>
Subject RE: Help Validating Accepted/Not Accepted radio buttons
Date Thu, 02 Dec 2004 23:06:31 GMT

> -----Original Message-----
> From: Wendy Smoak [mailto:java@wendysmoak.com]
> Sent: Thursday, December 02, 2004 3:42 PM
> To: Struts Users Mailing List
> Subject: Re: Help Validating Accepted/Not Accepted radio buttons
> 
> 

<snip/>

> 
> The problem with both of these is that they just ask for 
> <arg0> which is
> generally the field label, and then complain that the 'field 
> is invalid' or
> (strangely) 'field is required'.  (validWhen is using 
> 'error.required'.)
> 
> So I'm down to creating a custom "rule" copying validWhen but 
> giving it a
> different message, or just doing it manually in the Action, 
> in which case I
> think the info here will help:

<field
    property="lastName"
    depends="required,mask">

<!--The magic bit that can do what you want: -->
    <msg
        name="mask"
        key="registrationForm.lastname.maskmsg"/>
    <arg0 key="registrationForm.lastname.displayname"/>
    <var>
        <var-name>mask</var-name>
        <var-value>^[a-zA-Z]*$</var-value>
    </var>
</field>

Quote:
 The default error message for a pluggable validator can be overriden with the msg element.
So instead of using the msg attribute for the mask validator to generate the error message
the msg attribute from the field will be used if the name of the field's name attribute matches
the validator's name attribute.
from 
http://struts.apache.org/userGuide/dev_validator.html

> http://wiki.apache.org/struts/StrutsDeprecatedActionErrors.
> 
> Thanks!
> -- 
> Wendy Smoak
> 
> 
> ---------------------------------------------------------------------
> 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