This is what I have found works best. On the form have a ArrayList of the dropDown elements you want. And in the action, when preparing the data, get THE list from DB and populate it in form.There is something called LabelValueBean in stuts or Scaffold packaage if you want to use label value approach.
And still better approach is use Tiles Controller clas if you are using tiles.Because as you said, the same list will be used on multiple jsps.And you may forward to same jsp(input attribute) in case of validation errors.So when user goes back to same jsp due to error, then as he is not going through the action, the jsp will have empty list.But if you defined a controller which does the prepopulation of lists for the tile, then you dont have this problem. HTH. shirish -----Original Message----- From: Sinclair, Mark [mailto:[EMAIL PROTECTED] Sent: Tuesday, June 10, 2003 2:30 PM To: [EMAIL PROTECTED] Subject: Populating Drop-down I am a newbie to struts. This is a simple question and is not totally specific to Struts but is related to the best way to use struts. I am trying to find out what is the recommended approach for populate drop-downs, lists etc? For example say from a simple Logon page I forward to a Supplier List screen displaying all the current suppliers that are stored in the DB. Each supplier in turn is responsible for a certain department (field in department table in DB and departments stored in another DB table). In the supplier list I display the actual department name that they correspond to. Now from selected supplier on list if I go to an editSupplier.jsp I want to give the user the ability to pick a different department from populated list. My question is what is the best way to pass the list of departments to the View (editSupplier.jsp). Should my SupplierForm Bean contain a property eg departments that is an ArrayList or collection of departments in the DB then populate into view using the <html:options> tag? Or if Departments list is used in multiple screens should it be loaded into the session (/request) on logon (or whenever relevant) and use logic:iterate to populate the drop down. I may have a number of these types of drop-down lists, should I just prepopulate them into collections in my "user" session object? How do other people handle this? All examples I have seen just use hard-coded drop-down values in the jsp without retrieval from DB. Any help or pointers much appreciated! --------------------------------------------------------------------- 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]