Well, Struts 1.2.4 *does* call the initialize() method when an instance of the form is created; but not when the form is reset. I verified this using the Struts-example logon form:

<form-bean  name="LogonForm"
            type="org.apache.struts.validator.DynaValidatorForm">
    <form-property name="username" type="java.lang.String"
                initial="george"/>
    <form-property name="password" type="java.lang.String"/>
</form-bean>

The logon page correctly displayed 'george'.

If you really want the initial values to be used when the form is reset you can create a DynaActionForm extension like the following:

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

Natraj Gujran wrote:

Hi, This has come up during migration of our Struts 1.1 app to 1.2.4. It doesn't look like the 'initialize()' method of DynaActionForm is called
anymore ? In our application, we cannot initialize form values by using static values
in struts-config.xml. Eg: if a date is to be initialized 21 days from today, AFAIK , we had to put
that code in the initialize() method.
Right now, I'm at a loss about what next to do - any tips will be greatly
appreciated. Thanks, Natraj




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



Reply via email to