Thank you David, that was the problem... it now works just fine. -----Original Message----- From: David Winterfeldt [mailto:[EMAIL PROTECTED]] Sent: Friday, March 22, 2002 11:19 AM To: Struts Users Mailing List Subject: Re: Validating an ActionForm "conditionnally"
If you have a form nested like this, it probably doesn't have the servlet reference set on it. ServletContext application = getServlet().getServletContext(); Otherwise what you are doing should be fine. David --- "Sobkowski, Andrej" <[EMAIL PROTECTED]> wrote: > Hello, > > I've been using the Struts Validator (nightly build > of November) with no > problems for a few months (great work!). > > Now I need to call the validation method of a > specific "nested form" based > on a condition: > > ParentForm > +useChild: boolean > +getChildForm:ChildForm > > If useChild returns true, I want to call the > validate(mapping, request) of > ChildForm (ie the nested form). > > I thought that the validator only needed the > "mapping.getAttribute()" (name > of the ActionForm) to perform the validation so I > tried with the following > (ugly, I know): > > if (parentForm.useChild()) { > ActionMapping newMap = new ActionMapping(); > newMap.setAttribute("childForm"); > ActionErrors errors = > parentForm.getChildForm().validate(newMap, > request); > } > > The configuration is extremely basic: > - In struts-config.xml: > <form-bean name="childForm" > type="com.company.ChildForm"/> > - In validation.xml: > <form name="childForm"> > ... > </form> > > I'm getting a NullPointerException in the > validator's code. > > What am I doing wrong? Is this a good way to handle > the problem (I doubt > it...)? Any suggestions? > > Thanks. > > Andrej > __________________________________________________ Do You Yahoo!? Yahoo! Movies - coverage of the 74th Academy Awards® http://movies.yahoo.com/ -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>