My forms don't seem to be working this way at all. First, I have a form
for users to edit their profile. The ProfileForm has a Profile getter
and setter, which is accessed through the jsp (property=profile.name
...). Inside the reset() method, I get the users Profile object from
the session and assign it to the instance variable in the ProfileForm.
When I access the page, I get a NullPointerException.
To solve this problem. I created an Action that is requested instead of
requesting the jsp. This Action creates the ProfileForm, then
form.setProfile((Profile)session.getAttribute("profile")), then stores
the form in the request and forwards to the jsp so the user can modify
the profile.
This is a really annoying hack, since the same code in the reset method
is now repeated in the Action that forwards to the jsp.
Any suggestions as to why the reset method is not called before the page
is displayed?
Thanks,
Jeremy
On Thu, 2003-01-23 at 05:49, Nicolas De Loof wrote:
>
> 1. Struts find the formbean on scope or creates a new one
> 2. formbean.reset() is called to set all properties to default values
> 3. formbean is populated from request parameters
> 4. formbean.validate() is called (if configured)
> 5. formbean is passed to action
>
> reset() is used to set all property to default. It is mandatory for HTML
> checkbox, wich values sent into request when checked : If you uncheck a
> checkbox, they're will be no parameter in request. reset() allow you to set
> default to false, so
>
> . if checkbox has been checked -> populate will set property to true.
> . if checkbox has not been checked -> reset has set property to false.
> Your formbean datas conforms with what showed HTML browser.
>
> Nico.
>
> >
> >
> > I had similar behavior that I found odd with 1.0.2, the actionform would
> be
> > populated, reset was then called, and then validate was called.
> >
> > Jeremy, my *solution* was to overwrite reset() to do nothing at all. By
> > creating another method to mimic the reset, I now call reset when it's
> more
> > advantageous.
> >
> >
> > >I guess struts calls reset in order to save all
> > > your input and then does the validation
> >
> > I don't get that on two assumptions, (clarification appreciated.)
> >
> > 1) Isn't reset() to clear out old data from a bean being recycled, as
> > opposed to a method for saving that old data?
> > 2) Isn't the very role of validating to prevent unruly, non-conforming
> data
> > from being saved?
> >
> > Loren
> >
> >
> >
> > -----Original Message-----
> > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> > Sent: Wednesday, January 22, 2003 1:47 PM
> > To: [EMAIL PROTECTED]
> > Subject: RE: Why is the reset method called when I submit the form?
> >
> >
> > I guess struts calls reset in order to save all your input and then does
> the
> > validation
> >
> > Regards,
> >
> >
> > PQ
> >
> > "This Guy Thinks He Knows Everything"
> > "This Guy Thinks He Knows What He Is Doing"
> >
> > -----Original Message-----
> > From: Jeremy Cavagnolo [mailto:[EMAIL PROTECTED]]
> > Sent: January 22, 2003 2:53 PM
> > To: [EMAIL PROTECTED]
> > Subject: Why is the reset method called when I submit the form?
> >
> > It seems that when I submit my form, the reset method is called before
> > the validate method. I am using struts 1.0.2.
> >
> > Any insight?
> >
> > -Jeremy
> >
> >
> >
> >
> > --
> > 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]>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>