Hey Hubert,

But how is anything going to ever validate correctly if I have not had time
to initially populate the form.  The action which is being skipped allows me
to prepopulate the form before sending it to the user for them to add
information.

I get the feeling the workflow is something like

1.  Initial Action Ending with call to new action
2.  Validate occurs
3.  JSP Page displayed
3.  New Action called after user request

Instead of what I am used to:

1.  Initial action ending with call to new action
2.  New action called
3.  New action ends
4.  JSP Page displayed
5.  Validate occurs after user request.
5.  New action called after validation succeeds.

Cheers
Tom

On 2/7/06, Hubert Rabago <[EMAIL PROTECTED]> wrote:
>
> On 2/7/06, Tom Ansley <[EMAIL PROTECTED]> wrote:
> > > > <action path="/addCamper"
> > > >       type="com.camp.actions.camper.addCamperAction"
> > > >       name="CamperForm"
> > > >       scope="session"
> > > >       validate="true"
> > > >       parameter="submit"
> > > >       input="/addCamper.jsp">
> >
> > So, it's looking for getFirstName, which DOES exist in the form, except
> the
> > "camper" object has not been populated yet because the action which
> > populates it has not been called. Hence, the null pointer exception.
>
> This is your problem right here.  You request /addCamper which
> validate='true'.  Because of this, Struts will always call validate(),
> and so calls to your getters will be made.  Since your getters rely on
> camper, and camper is null, you'll get NPE's each time.
>
> The quickest way to fix this would be make sure camper is always
> available before your getters are called.  The better way to fix this
> would be to use a different action that doesn't require validation if
> you don't have data to validate.
>
> Hubert
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

Reply via email to