Re: What Is The Proper Location To Place Inputs For Creating A Drop-Down Menu
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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: What Is The Proper Location To Place Inputs For Creating A Drop-Down Menu
I'd put it in the database. The value can be the abbreviated state name and the label can be the resource property that you look up. You can do something like what I saw in Struts in Action book. It uses an action in scaffolding contrib project (part of start) that is called ExistsAttribute that will check to see if an attribute exists in a certain scope (I believe specified in the parameter attribute of the action-mapping). If it doesn't it goes one way (forward) or the other. It passes control to another action which will load the stuff up in app scope and then forward to the action that needs the stuff. I guess the only problem with this scheme is that states can be used in many different places. You would probably have different mappings for each of these. Scaffolding also uses a different back-end bean for each mapping (or many of them). So you could load many different beans if you want. You could have a servlet load the stuff in application scope if you liked as well. Lots of different ways of doing this. LabelValueBeans are part of struts and are useful for this type of thing. html:optionsCollections interface directly with LabelValueBeans and are used within an html:select. Another approach is to have a common jsp using a TilesController that loads it up if it isn't there already. I like the scaffolding approach. there are ways to make it dynamically dispatch to the appropriate action after loading up the beans. Scaffolding has a number of built in methods that may work (although I am thinking they may not). One is the BaseForm which has a dispatch parameter and the other is BaseActionMapping which has a parameter (specified in action-mapping). sandeep --- Caroline Jen [EMAIL PROTECTED] wrote: I want to put the label and value pairs of the 51 states of the U.S. in a file, read in the file into an ArrayList, and then create a drop-down menu in a .jsp file. Question 1. Where is the proper place to put those label and value pairs? Create a table in the database? or put those pairs in a properties file? Which directory does this properties file go? Question 2. Do I read those pairs into an ArrayList in the controller servlet? __ Do you Yahoo!? SBC Yahoo! DSL - Now only $29.95 per month! http://sbc.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] __ Do you Yahoo!? SBC Yahoo! DSL - Now only $29.95 per month! http://sbc.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]