Yes, it is typical to write Action.execute() methods that contact the
persistent store to populate an ActionForm so that the data can later be
rendered by a JSP.

Specify what ActionForm (bean) your action uses in struts-config.xml.
When you do this, Struts will create/find an instance of that ActionForm
for you and stash a reference to it in the scope you have specified.
Just use the instance that Struts creates for you (and passes to you via
execute an method argument) -- don't create a new one. And don't call
request.setAttribute("aBean", actionForm) -- Struts already does that
for you (specify the scope in struts-config.xml).

My advice in general is to study what Struts does to handle an HTTP
request, including the alternate path of handling a validation error.
Grasping the basic Struts request handling cycle (even just vaguely,
with the good sense to look deeper if you need to at a later date) would
help to avoid or solve the majority of Struts-related application bugs
or problems that I have experienced. A solid (yet basic) understanding
of how HTTP in general works is a fantastic but unfortunately
not-so-common thing to have, too.

-Max

On Mon, 2005-03-07 at 17:51 -0800, Jonathan M Z wrote:
> suppose I am using a form-bean to populate an html
> form,  I need to retrieve the values of this form-bean
> from persistent storage.  Do I do this from the Action
> that eventually forwards to this jsp page?
> Should I create the form-bean from persistent storage
> in action.execute(), then forwards the view to the jsp
> page?
> for example if the form-bean's name is aBean, in
> action.execute I create the aBean, populate it, and
> then set it as an attribute into the request(or
> whatever scope I see fit)
> is this a standard approach for reading data into
> form-bean from the persistent data layer?
> 
> thanks
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around 
> http://mail.yahoo.com 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 


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

Reply via email to