True, so I guess the null test will work.
----- Original Message ----- From: "Sid Stuart" <[EMAIL PROTECTED]> To: "Struts Users Mailing List" <[EMAIL PROTECTED]> Sent: Tuesday, February 05, 2002 2:55 PM Subject: Re: Design question about ActionForm's validate method > You get a zero length string. > > Sid > > dderry wrote: > > > What if your user then hits the Submit button without populating any of the > > form fields? > > > > ----- Original Message ----- > > From: "Sid Stuart" <[EMAIL PROTECTED]> > > To: "Struts Users Mailing List" <[EMAIL PROTECTED]> > > Sent: Tuesday, February 05, 2002 2:06 PM > > Subject: Re: Design question about ActionForm's validate method > > > > > Hi, > > > > > > My friend, Lee Crawford, just pointed out to me that the fields of the > > > ActionForm will be null if the validate method is called before the form > > is > > > submitted, but will be non-null afterwards. This provides a quick and > > simple > > > test that works for JSP called pages and for Action called pages, > > > > > > > > > public ActionErrors validate (ActionMapping mapping, > > > HttpServletRequest request) { > > > // See if the form has been submitted, if not do not > > > validate. > > > if (logon == null || password == null ) return null; > > > // Validate the data > > > final ActionErrors errors = new ActionErrors (); > > > if (logon.length() < 1) { > > > errors.add ("logon", new ActionError > > > ("error.logon.logonRequired")); > > > } > > > if (password.length() < 1) { > > > errors.add("password", new ActionError > > > ("error.logon.passwordRequired")); > > > } > > > return errors; > > > } > > > > > > > > > Sid > > > > > > > > > > -- > > To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> > > For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> > > > -- > To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> > For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> > > -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>