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..."