<2cents>
I think you should check Rick Reumans lessons on struts.
Unfortunately I forgot the link, but you can easily google it out.

In short words, nothing in your classes which has an import to
*.struts or javax.http.* should even know anything about the database
or that there is a database.

You should have a service/business logic class, which can make the
calls to the database and create a VO. You call this service method
from your action or session listener or whatever, (I'd prefer the
action on first request, since its most controllable).

You can cache the VO in the business logic or in the session,
depending on who has best knowledge about the object and the rules.
</2cents>
regards
leon

On 9/24/05, Rob Turknett <[EMAIL PROTECTED]> wrote:
> Thanks for the help. Are you suggesting, in other words, to have a separate
> Action that retrieves the data to populate the select box, that is executed
> prior to the ActionForm?
>
> Rob
>
> > -----Original Message-----
> > From: news [mailto:[EMAIL PROTECTED] On Behalf Of Laurie Harper
> > Sent: Friday, September 23, 2005 8:45 PM
> > To: user@struts.apache.org
> > Subject: Re: Populating a select box from a database
> >
> > Rob Turknett wrote:
> > > I want to populate a select element with items from a database. The
> > items
> > > can be retrieved by making calls to an API that retrieves data from the
> > > database. These API methods may throw exceptions if the database is
> > > inaccessible, or if the user is not logged in. The items only need to be
> > > retrieved once per session, and should therefore be cached in the user's
> > > session.
> > >
> > > What is the best way to do this in Struts? Where should I make the calls
> > to
> > > retrieve the list items? If I do this in the ActionForm, I am not sure
> > what
> > > to do if an exception is thrown (for instance, if the user is not logged
> > in,
> > > how to forward to the login page).
> > >
> > > I've looked around for information about how to do this, but haven't
> > found
> > > much. Any help or pointers to resources would be greatly appreciated.
> >
> > You want to do it in the Action instead of the ActionForm. You can
> > catch/handle any exceptions you want to and forward as appropriate, or
> > let the exception propogate and use declarative exception handling to
> > serve the appropriate page.
> >
> > HTH,
> >
> > L.
> >
> >
> > ---------------------------------------------------------------------
> > 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]
>
>

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

Reply via email to