You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Sinclair, Mark" <ms...@eds.com> on 2003/06/10 14:30:00 UTC

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: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: Populating Drop-down

Posted by Sandeep Takhar <sa...@yahoo.com>.
someone else has replied, but just some more hints.

You can look at html:optionsCollection which as
support for labelValueBeans.

The idea about using using the tiles:controller is an
excellent one, but I have not done this.

You will probably want it in application context and
not load them all the time from the session bean.

Some criteria: If someone modified them or adds to
them, you don't want to make any front-end changes.

Maybe you want to pass to the front-end as a DTO both
the supplier and the link to the department (as domain
objects).  Or you can alternatively send a custom DTO
with supplier info and department name and primary
key.

When you go to the department page you can fill in the
primary key of the supplier so you can pass it as part
of the session bean call to change the department.

sandeep


--- "Sinclair, Mark" <ms...@eds.com> wrote:
> 
> 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:
> struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> struts-user-help@jakarta.apache.org
> 


__________________________________
Do you Yahoo!?
Yahoo! Calendar - Free online calendar with sync to Outlook(TM).
http://calendar.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org