Q: When exactly this method has to be used and when does this get called?

A: The reset method is called for each new request, for both request
and session scoped ActionForms, before the ActionForm is populated
from the request.  Here's the sequence of events:

1. Request received by controller.
2. Create or recycle ActionForm (create request-scoped, recycle session-scoped)
3. Call reset() method on ActionForm.
4. Store ActionForm in scope as defined in stuts-config.xml
5. Populate ActionForm from request.
6. Validate the ActionForm if defined in struts-config.xml.
Assuming no validation errors:
7a. Call execute() method of the Action passing ActionForm
With validation errors:
7b. Go back to input with ActionForm in proper scope.

Q: Why do the checkboxes have to be reset?

A: The reset() method was originally designed to reset boolean
variables that represent checkbox values in the HTML form.  When an
HTML form contains checkboxes, only the values for the checkboxes that
are chedked are sent in the request (see HTTP spec).  The reset()
method was designed to reset the boolean properties in the ActionForm
that represent checkboxes to false.  This is necessary because false
values aren't sent in the request, only true ones.  If you have a
session-scoped ActionForm, the boolean values for the checkboxes could
be set to true from a previous request.  Without resetting them they
would always stay true.

With a request-scoped ActionForm you don't have to implement the reset
method unless you need your ActionForm properties to default to some
value other than the default or that of which you defined when you
declared the property on the ActionForm.

Basically, the reset method is called before the request reaches the Action.

Hope that answers your questions.


On 1/3/06, fea jabi <[EMAIL PROTECTED]> wrote:
> When exactly this method has to be used and when does this get called?
>
> Why do the checkboxes have to be reset?
>
> Prepopulating the formbean is done in Action class. hence, it's not clear to
> me the exact use of using the reset method.
>
> Thanks.
>
> _________________________________________________________________
> Is your PC infected? Get a FREE online computer virus scan from McAfee(r)
> Security. http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>



--
Virtually,
Andre Van Klaveren
Architect III, SCP
Global Public Sector
Unisys Corporation

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to