struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Naskovski <mnask...@san.rr.com>
Subject Re: What Is The Proper Location To Place Inputs For Creating A Drop-Down Menu
Date Fri, 18 Jul 2003 07:33:20 GMT
Thursday, July 17, 2003, 11:30:03 PM, you wrote:

CJ> I want to put the "label and value" pairs of the 51
CJ> states of the U.S. in a file, read in the file into an
CJ> ArrayList, and then create a drop-down menu in a .jsp
CJ> file.

The United States has 50 states. :)

CJ> Question 1.  Where is the proper place to put those
CJ> "label and value" pairs?  Create a table in the
CJ> database? or put those pairs in a properties file? 
CJ> Which directory does this properties file go?

You can put them anywhere. The way I store the U.S. states is in a
static String[], which I then convert to an ArrayList of
LabelValueBeans. These are all defined in a Constants.java file.
Unless we annex Canada or Mexico, this will remain pretty
constant :), so I felt ok to hardcode it in a file, versus putting it
in a flat file or a db table.

CJ> Question 2.  Do I read those pairs into an ArrayList
CJ> in the controller servlet?

No. You put the arraylist of LVB's on some scope (request or session),
and inside your JSP you iterate over it by using the struts-logic
tags, or even better, the JSTL tags, as they are even more expressive
than some of the struts-logic tags.

HTH,

Martin


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


Mime
View raw message