Mr. Peruzzi,

Here's one way using reset() to call initialize() -- this will set the values back to their "initial" values as set on the form-property elements:

=========================================================================
import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.DynaActionForm;

public class ResettingDynaActionForm extends DynaActionForm {

public void reset(ActionMapping mapping, HttpServletRequest request)
{
initialize(mapping);
}
}
=========================================================================
-Bill Siggelkow


Ing. Stefano Peruzzi wrote:
Hi everybody,

I decided to post here, after I searched a solution for three hours or so.

Can you post an URL (or an advice, or an example) in which is explained how to 
override initialize() or reset() DynaActionForm methods?

The problem: to set properties of my form, I have to put it in session scope. With this setting, property' values "survive" to the next form invocation. I need to clear or empty form properties each time I create the new form.

I tried this:

public class MyDynaForm extends DynaActionForm {

  public void initialize(ActionMapping mapping) {
    System.out.println("--- INITIALIZE CALLED");
    super.initialize(mapping);
  }

But initialize() is never called by Struts!
reset() method is somewhat discouraged by Struts after v1.1 (it's not called each 
time).

Last thing: to clear all properties, do I have to set them null one by one? I hope 
there's a better solution (there should be!), since this is a tipical error-prone task.

Thanks in advance,
S.Peruzzi

PS: If you're in early stages of development, try to AVOID DynaActionForms, read this: http://jroller.com/page/javajoe/20040325?catname=Java


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



Reply via email to