Thanks for your prompt response, I believe it will not work for the
following reason:

My preparation action does thing such as setting collection for html:options
in request attribute.  Imagine that PrepAction initialize a new ActionForm
setting the defaults and overwritting the one created by the controller, we
now forward to the jsp view and all fields are set to their default.  so far
so good.
Next the user enters data, I post that request to the action that
validates...this action makes server call, create some errors and forward
back to preparation handler (because it needs to do so since I have code in
there to build up my collection for the html:options)
Now this prep handler will create a new ActionForm effectively resetting the
one with all the data filled in by the user.  Not the desired effect.

A suggestion would be to configure the defaults value as config parameters
in the struts-config.xml at the Action Mapping level.  Something like
<actionform-default><property>blah</property><value>somedefault</value></act
ionform-default>

Am I making sense of all this?

Thanks,

Christian
> -----Original Message-----
> From: Craig R. McClanahan [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, February 21, 2001 11:13 PM
> To: [EMAIL PROTECTED]
> Subject: Re: ActionForm.reset()
>
>
> Christian Billen wrote:
>
> > Hi list,
> >
> > Is there a way to prevent the reset() method from being called on the
> > ActionForm when the validate option in struts-config for that
> mapping is set
> > to false?
> >
>
> Doing this would break the recommended approach for dealing with
> checkboxes,
> which rely on reset() being called to reset the corresponding booleans to
> false.  You will want this to occur even if you are not
> validating, so that the
> bean properties correctly reflect what the user last entered.
>
> >
> > My problem is that I have an Action to prepare the data for a
> jsp page and
> > another Action to process the data from that jsp. Both point to the same
> > ActionForm class.
> > In my prep action (/prepare.do), I configured the mapping not
> to validate
> > the form, but still I see that the reset() method is being called, very
> > annoying considering that some properties in my actionform are set to a
> > default in the constructor (like a checkbox set to true) and that I have
> > code in reset of the same form to clear checkboxes.  Shouldn't reset be
> > called by the controller only when validate is true?
> >
>
> The Struts example application faces a similar situation.  In the
> EditSubscriptionAction, it creates a new form bean (initialized
> to defaults in
> the constructor) and *replaces* the one that was created by the controller
> servlet (and on which reset() was called).  You might consider
> using a similar
> technique.
>
> Craig McClanahan
>
>
> >
> > Thanks for your advise,
> >
> > Christian Billen
>
>
>

Reply via email to