struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jerry Jalenak" <Jerry.Jale...@LABONE.com>
Subject RE: how do i get a Field object in Validator?
Date Tue, 22 Oct 2002 19:28:55 GMT
Not quite sure I understand your question then.  Are you wanting to
manipulate the error message that is being returned?  In other words, if one
of the 'other' variables fails, then return a message for that failure ?

Jerry

> -----Original Message-----
> From: Andy Kriger [mailto:akriger@greaterthanone.com]
> Sent: Tuesday, October 22, 2002 1:45 PM
> To: Struts Users Mailing List
> Subject: RE: how do i get a Field object in Validator?
> 
> 
> That much I understand - but is it possible to get a 
> reference to the Field
> objec that represents that 2nd property? For example, if you 
> wanted to get
> message arguments from the other field.
> 
> -----Original Message-----
> From: Jerry Jalenak [mailto:Jerry.Jalenak@LABONE.com]
> Sent: Tuesday, October 22, 2002 14:19
> To: 'Struts Users Mailing List'
> Subject: RE: how do i get a Field object in Validator?
> 
> 
> In your validator-rules.xml file, add the following for each 
> form field you
> need access to:
> 
> 	<form name="yourForm">
> 		<field property="firstProperty" 
> depends="yourCustomRoutine">
> 			<var>
> 				
> <var-name>secondProperty-Label</var-name>
> 				
> <var-value>secondProperty-Value</var-name>
> 			</var>
> 		</field>
> 	</form>
> 
> secondProperty-Label would be what you want to call the 
> variable in your
> custom routine; secondProperty-Value would be the actual form 
> field name
> that contains the entered value.  Then in your custom routine 
> you can access
> these values by
> 
> 	public static boolean yourCustomRoutine(Object object,
> ValidatorAction va, Field field, ActionErrors errors, 
> HttpServletRequest
> request)
> 	{
> 		String fp = ValidatorUtil.getValueAsString(object,
> field.getProperty());
> 		String sp = ValidatorUtil.getValueAsString(object,
> field.getVarValue("secondProperty-Label"));
> 
> 		... do something ...
> 		return true;  // or false if the validation fails
> 	}
> 
> HTH,
> 
> Jerry
> 
> > -----Original Message-----
> > From: Andy Kriger [mailto:akriger@greaterthanone.com]
> > Sent: Tuesday, October 22, 2002 11:33 AM
> > To: Struts Users Mailing List
> > Subject: how do i get a Field object in Validator?
> >
> >
> > I am writing a custom rule and I need to know how I can get a
> > handle to a
> > different Field object? (not the one passed into the method
> > in the first
> > place)
> >
> > thx
> > a
> >
> >
> >
> > --
> > To unsubscribe, e-mail:
> > <mailto:struts-user-unsubscribe@jakarta.apache.org>
> > For additional commands, e-mail:
> > <mailto:struts-user-help@jakarta.apache.org>
> >
> >
> 
> This transmission (and any information attached to it) may be 
> confidential
> and is intended solely for the use of the individual or 
> entity to which it
> is addressed. If you are not the intended recipient or the person
> responsible for delivering the transmission to the intended 
> recipient, be
> advised that you have received this transmission in error and 
> that any use,
> dissemination, forwarding, printing, or copying of this information is
> strictly prohibited. If you have received this transmission 
> in error, please
> immediately notify LabOne at (800)388-4675.
> 
> 
> 
> --
> To unsubscribe, e-mail:
> <mailto:struts-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail:
> <mailto:struts-user-help@jakarta.apache.org>
> 
> 
> 
> --
> To unsubscribe, e-mail:   
<mailto:struts-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail:
<mailto:struts-user-help@jakarta.apache.org>


This transmission (and any information attached to it) may be confidential and is intended
solely for the use of the individual or entity to which it is addressed. If you are not the
intended recipient or the person responsible for delivering the transmission to the intended
recipient, be advised that you have received this transmission in error and that any use,
dissemination, forwarding, printing, or copying of this information is strictly prohibited.
If you have received this transmission in error, please immediately notify LabOne at (800)388-4675.



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


Mime
View raw message