If I can't write it in validator easily, then I write it in the validate() method. I use validator for required, date mask, integer, and a few others. If I knew anything about regular expressions or struts validator's validwhen() I'd probably do more - excuses, excuses.
So, you could say something like: public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) { log.info( request.getRemoteUser() + " *** validate - Start ***"); // Struts validator is happening here ActionErrors errors = super.validate(mapping, request); // I've seen examples that use null, but when I run it now, isEmpty() is true and the errors object is not null) if (( errors == null ) || errors.isEmpty() ) { if (errors == null) errors = new ActionErrors(); // write your validation logic here, and set valid if (!valid) { // gain access to msg resource bundle... MessageResources mr = (MessageResources) request.getAttribute(Globals.MESSAGES_KEY); // lookup any replace-able values to place into msg String strArg0 = mr.getMessage("Page1.first_name"); //... // Add msg to errors: errors.add ( "property", new ActionMessage( "msg.key", strArg0 [,...] ); } } return errors; } If this is off base, then I'll assume someone else will chime in. -----Original Message----- From: fea jabi [mailto:[EMAIL PROTECTED] Sent: Wednesday, August 09, 2006 8:57 AM To: user@struts.apache.org Subject: RE: validation of two form properties can someone help me wih this please? Thanks. >From: "fea jabi" <[EMAIL PROTECTED]> >Reply-To: "Struts Users Mailing List" <user@struts.apache.org> >To: user@struts.apache.org >Subject: validation of two form properties >Date: Tue, 08 Aug 2006 15:50:58 -0400 > >have form properties a and b > >have to validate that property b is an integer, greater than 0 and also >greater than form property a. > ><field property="b" depends="integer,validwhen"> > <msg name="integer" key="errors.notvalid"/> > <msg name="validwhen" key="errors.notvalid"/> > <var> > <var-name>test</var-name> > <var-value>( (*this* >= 0) and (*this* >= a) >)</var-value> > </var> > </field> > >tried using the above. but not working. getting error message even when the >form property is greater than zero and greater than a. > >what is missing here? Thanks. > >_________________________________________________________________ >Express yourself instantly with MSN Messenger! Download today - it's FREE! >http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/ > > >--------------------------------------------------------------------- >To unsubscribe, e-mail: [EMAIL PROTECTED] >For additional commands, e-mail: [EMAIL PROTECTED] > _________________________________________________________________ Express yourself instantly with MSN Messenger! Download today - it's FREE! http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/ --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]