struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Amleto Di Salle" <disa...@di.univaq.it>
Subject R: DynaValidateForms: how to reset() or initialize()
Date Wed, 13 Oct 2004 12:44:29 GMT
Hi,
Try to extends reset method in DynaActionForm

package custom;
public class CustomDynaActionForm extends DynaActionForm {
	public void reset(ActionMapping mapping, HttpServletRequest
request) {
		initialize(mapping);
	}
}

And in your "struts-config.xml" configure the action form in the
following way:

<form-bean name="UserForm"  type="custom.CustomDynaActionForm ">
    <form-property name="givenName" type="java.lang.String"
initial="John"/>
    <form-property name="familyName" type="java.lang.String"
initial="Smith"/>
</form-bean>

So what do you mean with "reset() method is somewhat discouraged by
Struts after v1.1 (it's not called each time)."?
As I know, Struts always calls the reset method, but in DynaActionForm
the implementation is empty.

BR
Amleto

-----Messaggio originale-----
Da: Ing. Stefano Peruzzi [mailto:s.peruzzi@datapos.it] 
Inviato: mercoledì 13 ottobre 2004 14.09
A: user@struts.apache.org
Oggetto: DynaValidateForms: how to reset() or initialize()


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: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message