The problem is that HTML forms pass an empty string when you leave a
field blank. They don't leave the field out, so there's always a value.
If you have a string property, you should use the required string
validator. 

> -----Original Message-----
> From: Ben Hall [mailto:[EMAIL PROTECTED] 
> Sent: Tuesday, August 19, 2003 5:42 AM
> To: '[EMAIL PROTECTED]'
> Subject: RE: [OS-webwork] RequiredFieldValidator
> 
> 
> I've got that already - the validation is firing, it's just 
> that the getFieldValue method, which ends up calling Ognl, 
> returns an empty string when i'm expecting a null string, 
> unless i'm doing something wrong (which i'm going to assume I 
> am at this stage).
> 
> Ben.
> 
> -----Original Message-----
> From: Francisco Hernandez [mailto:[EMAIL PROTECTED]
> Sent: 19 August 2003 10:39
> To: [EMAIL PROTECTED]
> Subject: Re: [OS-webwork] RequiredFieldValidator
> 
> 
> something I was forgetting to do when testing the validation 
> framework 
> was applying the ValidatorInteceptor in the interceptor-stack I was 
> using for that action.
> 
> 
> Ben Hall wrote:
> > I'm trying to make the required field validator work for me but i'm 
> > having
> a
> > slight problem.  The value that is returned by the call within the
> validator
> > - getFieldValue(fieldName, object), seems to always return 
> a non null
> value.
> > 
> > My velocity template looks a little like this:
> > 
> > <table>
> > <form action="ValidationTestX.action" method="post">
> > #tag (TextField "label=userName" "name=username")
> > #tag (Password "label=password" "name=password")
> > #tag (Submit "value='submit'")
> > </form>
> > </table>
> > 
> > I'm not using model driven so my action class has username and 
> > password members and appropriate getters and setters.
> > 
> > My xml validation snippet looks like this:
> > 
> >     <field name="username">
> >         <field-validator type="required">
> >           <message key="usernameRequired"/>
> >         </field-validator>
> >     </field>
> > 
> > The string value returned by the getFieldValue seems to be 
> "" when I 
> > don't enter anything in the text fields and submit the 
> form.  Should I 
> > be doing something extra to make this null somehow ?
> > 
> > Thanks,
> > Ben.
> > 
> > 
> > This email and any attachments are strictly confidential and are 
> > intended solely for the addressee. If you are not the intended 
> > recipient you must not disclose, forward, copy or take any 
> action in 
> > reliance on this message or its attachments. If you have 
> received this 
> > email in error please notify the sender as soon as possible 
> and delete 
> > it from your computer systems. Any views or opinions presented are 
> > solely those of the author and do not necessarily reflect 
> those of HPD 
> > Software Limited or its affiliates.
> > 
> >  At present the integrity of email across the internet cannot be
> guaranteed
> > and messages sent via this medium are potentially at risk.  All 
> > liability is excluded to the extent permitted by law for any claims 
> > arising as a re- sult of the use of this medium to transmit 
> > information by or to HPD Software Limited or its affiliates.
> > 
> > 
> > 
> > 
> > -------------------------------------------------------
> > This SF.Net email sponsored by: Free pre-built ASP.NET 
> sites including 
> > Data Reports, E-commerce, Portals, and Forums are available now. 
> > Download today and enter to win an XBOX or Visual Studio .NET.
> >
> http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet
> _072303_01/01
> > _______________________________________________
> > Opensymphony-webwork mailing list 
> > [EMAIL PROTECTED]
> > https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork
> > 
> > 
> > 
> 
> 
> 
> 
> 
> -------------------------------------------------------
> This SF.Net email sponsored by: Free pre-built ASP.NET sites 
> including Data Reports, E-commerce, Portals, and Forums are 
> available now. Download today and enter to win an XBOX or 
> Visual Studio .NET. 
> http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet
_072303_01/01
_______________________________________________
Opensymphony-webwork mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork


This email and any attachments are strictly confidential and are
intended solely for the addressee. If you are not the intended recipient
you must not disclose, forward, copy or take any action in reliance on
this message or its attachments. If you have received this email in
error please notify the sender as soon as possible and delete it from
your computer systems. Any views or opinions presented are solely those
of the author and do not necessarily reflect those of HPD Software
Limited or its affiliates.

 At present the integrity of email across the internet cannot be
guaranteed and messages sent via this medium are potentially at risk.
All liability is excluded to the extent permitted by law for any claims
arising as a re- sult of the use of this medium to transmit information
by or to 
HPD Software Limited or its affiliates.




-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01
/01
_______________________________________________
Opensymphony-webwork mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork


-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01
_______________________________________________
Opensymphony-webwork mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork

Reply via email to