struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Skip Hollowell <s...@skipdaddy.com>
Subject Re: {S2}doublselect How to create the doubleList
Date Tue, 25 Sep 2007 12:33:12 GMT
I think I have it...and I wanted to make sure I got this archived 
somewhere in case I or anyone else was ever looking for an example.

The first list is a list of Course objects, made up of an id, name and 
Foods (a Set of Food objects)
Food has an id and a name field.

List<Course> listCourse = new ArrayList<Course>();  // make sure you 
have a getter for this

Course c1 = new Course(1, "Appetizer");
Food f1 = new Food("1", "Cheese Stick");
Food f2 = new Food("2", "Nachos");
Set<Food> setFood1 = new HashSet<Food>();
setFood1.add(f1);
setFood1.add(f2);
c1.setFoods(setFood1);

Course c2 = new Course(2, "Main Course");
Food f1 = new Food("3", "Chicken Sandwich");
Food f2 = new Food("4", "Veggie Wrap");
Set<Food> setFood2 = new HashSet<Food>();
setFood2.add(f3);
setFood2.add(f4);
c2.setFoods(setFood2);

etc etc ad nauseum


and in the JSP then:
<s:doubleselect label="Meal"
name="course" list="listCourse" listKey="id" listValue="name"
doubleName="food" doubleList="foods"
doubleListKey="id" doubleListValue="name" />
>



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


Mime
View raw message