struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alexandru BARBAT" <alexandrubar...@ucs.ro>
Subject RE: Struts validator
Date Mon, 04 Feb 2008 17:08:58 GMT
Hi,

You can override method 
 public String getValidationKey(ActionMapping mapping,
                                   HttpServletRequest request) {..}

>From your ValidatorForm (it doesn't matter if it is dyna or not)

And return different validation keys for each button pressed.

Validation key identify the rules of validation.

The validation file will look then something like:

<form name="myAction_button1">
		 <!--if submit button 1 clicked, I validate the
following field>-->
		<field property="myProperty" depends="required">
			<msg name="required" key="error.key1" />
		</field>   
</form>

<form name="myAction_button2">
		<!--if submit button 2 clicked, I validate the following
field>-->
		<field property="name" depends="myValidator">
			<msg name="myValidator"	key="error.key2" /> 
		</field>
</form>


alex

-----Original Message-----
From: Dave Newton [mailto:newton.dave@yahoo.com] 
Sent: Friday, February 01, 2008 6:29 PM
To: Struts Users Mailing List
Subject: RE: Struts validator

--- "Zhang, Larry (L.)" <lzhang20@ford.com> wrote:
> No, I am using struts 1.1,

Oh, wow.

Does validwhen[1] not exist in S1.1? You can always create a custom
validator
as well if you find your validation stretches what's easy to do with the
existing validation configuration possibilities. You may also be able to
combine declarative validation (via XML) and Java-based validation, although
it's been a pretty long time since I've thought about that :)

Dave

[1] http://struts.apache.org/1.1/userGuide/dev_validator.html (about 1/3 of
the way down)


---------------------------------------------------------------------
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