Gezza,
It's best to start with an overview of how Struts sets up an ActionForm (this list is quoted from
Programming Jakarta Struts, 2nd Edition):
Check the mapping for the action and see if an ActionForm has been configured.If an ActionForm is configured for the action, use the name attribute from the action element to look up the form bean configuration information.Check to see if an instance of the ActionForm already has been created.If an ActionForm instance is present in the appropriate scope and it's the same type as needed for the new request, reuse it.Otherwise, create a new instance of the required ActionForm and store it in the appropriate scope (set by the scope attribute for the action element).Call the reset() method on the ActionForm instance.Iterate through the request parameters, and populate every parameter name that has a corresponding setter method in the ActionForm with the value for that request parameter.Finally, if the validate attribute is set to "true", invoke the validate() method on the ActionForm instance and return any errors. So if you need to pre-populate your formbean (ActionForm instance), you can do it in the constructor of the ActionForm.
Where I normally do it, however, is in the default action for my Action class (I generally use DispatchAction). For example, our default is a method called "display". When this action is called, the formbean is created, and then the Action.display() is called. I do any work there to get data out of the session, etc.
Once the action method is complete, Struts completes the action by forwarding to whatever path I've configured (e.g., the
jsp for displaying the content).
So Struts provides a very easy way to popluate your form that's part of the standard usage.
[ April 25, 2008: Message edited by: Stevi Deter ]