Suppose we have a page P1.jsp which has a corrosponding form bean,
say, TestForm. If the scope of the bean is request, then whenever we
access P1.jsp, the reset() method will be called.

If the scope is session, reset() method will be called only for the
first time, when the bean is actually loaded. On further access to
P1.jsp, reset() will not be called.

But on submission of P1.jsp, reset() is called for both the scopes.

regards,
vijay.


On 5/29/06, Philihp Busby <[EMAIL PROTECTED]> wrote:
ActionForm objects are reused. A new one may not necessarily be
created every time a form is submitted... Struts will try and reuse
one from a pool of ActionForm objects.

If there's a free one, it calls reset() before populating it in the
controller with form values and hands it to your action.

If there's no free one, it creates a new one, calls reset(), then
populates it with form values and hands it to your Action.

You want to "reset" all of your ActionForm's fields to empty or
nothing, or whatever you want the default value to be if the HTTP
request doesn't include any parameters. It's a best practice to do
every field, even if all of your HTML forms have fields for each of
the attributes... and even if they do, HTTP checkboxes are only
included in parameters if they're checked... if they're unchecked then
your HTTP request won't contain that parameter.

On 5/29/06, Miguel Galves <[EMAIL PROTECTED]> wrote:
> Hi,
>
> can someone tell exactly in which cases the ActionForm.reset() method
> is called ? More specifically, when an action or a erro handler redirects
> the system to a specific DispatchAction method, as showed in the code
> below, dos struts reset the form ?
>
> public class MyExceptionHandler extends ExceptionHandler {
>
>     public ActionForward execute(Exception error,
>                                  ExceptionConfig ec,
>                                  ActionMapping mapping,
>                                  ActionForm form,
>                                  HttpServletRequest request,
>                                  HttpServletResponse response) throws
> ServletException {
>
>
>         // create action forward
>         ActionForward forward = new ActionForward(mapping.getPath() +
> ".do?action=error");
>  ex.printStackTrace();
>
>         if (error instanceof AuthorizationException || error instanceof
> AuthenticationException)
>             return (mapping.findForward("logon"));
>
>         return forward;
>     }
>
> }
>
>
> --
> Miguel Galves - Engenheiro de Computação
> Já leu meus blogs hoje?
> Para geeks http://log4dev.blogspot.com
> Pra pessoas normais
> http://miguelgalves.blogspot.com
>
> "Não sabendo que era impossível, ele foi lá e fez..."
>
>


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

Reply via email to