Yes, that's the 'standard' pattern.

L.

Rob Turknett 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]

Reply via email to