I guess the big thing I do not understand here is why validator is being
called when the form has not even had time to initialize.

In my application I rely on the action.execute() method being the first to
be called because it allows me to prepopulate the form associated with the
action.  This makes good sense.  Then, the jsp page is created.  Then, when
the reply comes back from the user, that is when the validation should
occur.

Is this assumption about the action.execute() method being the first thing
called a BIG mistake?  What happens if the form needs to retrieve a number
of lists which are to be displayed in the JSP page?  I do this retrieval in
the action.execute and place the lists in the form.  Should I be doing it
somewhere else?

Thanks so much to all for their previous thoughts by the way.

Cheers
Tom



On 2/7/06, Tom Ansley <[EMAIL PROTECTED]> wrote:
>
> Hey Dave,
>
> Referring to this:
>
> > <forward   name="addCamper" contextRelative="true"
> > path="/jsp/camper/addCamper.do" redirect="true"/>
> >
> The "path" attribute strikes me as being very suspicious, but you might
> just be doing something... unexpected with how your application is set up.
>
>
> Why does the path look a little suspicious to you?  I was thinking maybe I
> am calling something in a weird way which was fine before but is causing
> problems now.  How should the path look?
>
> Cheers
> Tom
>
>
>
> On 2/7/06, Nick Sophinos <[EMAIL PROTECTED]> wrote:
> >
> > The initially easiest solution is to have a init version of that action.
> > Note that it is a Forward Action, thus bypassing the need for a nearly
> > empty backing Java class.
> > ie:
> > <action path="/AddCamperInit" type="
> > org.apache.struts.actions.ForwardAction"
> > parameter="/addCamper.jsp" />
> >
> > Alternatively, MappingDispatchAction is good here too, where one Action
> > class
> > can handle all cases, including the init case.
> >
> > - Nick
> >
> > On 2/7/06, Tom Ansley <[EMAIL PROTECTED]> wrote:
> > > 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]
> > > >
> > > >
> > >
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
>

Reply via email to