Sorry - left out the return statement public Collection getCountryList(){ ArrayList list = new ArrayList(); for(int i=0;i<countryList.length; i++){ LabelValueBean bean = new LabelValueBean(countryList[i][0],countrList[i][1]); list.add(bean); } return list; }
-----Original Message----- From: Rob Parker [mailto:[EMAIL PROTECTED]] Sent: Wednesday, December 19, 2001 2:37 PM To: Struts Users Mailing List; [EMAIL PROTECTED] Subject: RE: Country List how about something like this - you could do a lot to improve this, but here is the basic idea. Better yet, use a properties file or a database to specify the country list. Then use the Collection returned from this method from the <html:options> tag to create the option list for the select. import java.util.ArrayList; import java.util.Collection; import .../.../LabelValueBean; public class ListHelper{ public String[][] countryList = {{"United States", "US"},{"Canada", "CA"}... public Collection getCountryList(){ ArrayList list = new ArrayList(); for(int i=0;i<countryList.length; i++){ LabelValueBean bean = new LabelValueBean(countryList[i][0], countrList[i][1]); list.add(bean); } } } -----Original Message----- From: Kevin J. Turner [mailto:[EMAIL PROTECTED]] Sent: Wednesday, December 19, 2001 2:14 PM To: Struts Users Mailing List Subject: Country List I am involved in converting a large Active Server Pages (ASP) application to a JSP/Servlets solution, using the Struts framework. I am new to Struts and I have a relatively okay grasp of JSP/Servlets/Struts. A few of the pages in the current project use an ASP include file that creates an HTML SELECT object of Country names and their corresponding 2-digit ISO codes.. The code is encapsulated in a function call, with the country code to be selected passed in as a parameter, as follows: --- snip --- <% Call CountryList("country", "CA") %> --- snip --- which produces HTML similar to the following: --- snip --- <select name="country"> <option value="CA" selected>Canada</option> <option value="US">United States</option> <option value="FR">France</option> <option value="FJ">Fiji</option> <option value="FI">Finland</option> ... etc </select> --- snip --- I would like to duplicate this functionality using JSP/Struts/JavaBeans.. whatever.. but I'm not sure the best way to do it. Could some offer advice on what the most elegant approach to this would be? The obvious goal would be to have a reusable component/module that produces the necessary HTML based on a static list of country names and codes, and to be able to pre-select a country. Any advice is appreciated. Regards, Kevin J. Turner -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>