Thanks for the responses, Bill & Niall. 
 
This is what I finally found out, and thought would be useful sharing. 
 
Struts 1.1  calls the 'initialize(ActionMapping)' method as part of
RequestUtils.createActionForm() . 
Struts 1.2.4 does NOT seem to call the
DynaActionForm.initialize(ActionMapping )   or the other
DynaActionForm.initialize(FormBeanConfig  ) . 
 
The initial values that get loaded from the struts-config.xml  is because of
the RequestUtils class invoking the corresponding FormBeanConfig object which
reads up the initial values from struts-config.xml. 
So, in my case where I had coded an initialize() method calculating the two
date fields (checkin date / checkout date)  to be 21 days from today, was
never getting called. 
 
Bill's advice of using making reset() invoke 'initialize()' works for all
simple usages of Struts if we use only the HTML Form tag to load the form. 
That's because the the Form Taglib ends up invoking a
'RequestProcessor.process()' method which explicitly calls the 'reset' on the
FormBean. 
 
I had cases where I was switching form beans, copying values from alternate
forms, etc. In those situations, I had used RequestUtils.createActionForm(). 
Here, I had to add an extra invocation to 'reset' just like the
RequestProcessor is doing. 
 
To sum it all up: 
1.      Put in a reset that calls the 'initialize()'  OR put the
'initialize()' code in 'reset'. Like the documentation. 
2.      Wherever you are using the RequestUtils.createActionForm(), make sure
to call the 'reset' or 'initialize' immediately after. 
 
 
Thanks for the help, 
Natraj 
 
 
-----Original Message-----
From: Natraj Gujran 
Sent: Thursday, November 18, 2004 4:44 PM
To: '[EMAIL PROTECTED]'
Subject: Struts 1.2.4 - DynaActionForm.initialize(ActionMapping) no longer
called ?
 
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 
 

Reply via email to