You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Natalie D Rassmann <na...@lmco.com> on 2003/06/19 13:47:04 UTC
iterating thru a collection
I need to iterate thru a collection and put it in an <html-el:select>
field. How do I go about doing this....
My collection type looks like this....
ArrayList options
int selectedOption
The ArrayList of options is the following type:
String label
int id
Can anyone help me???
Thanks in advance...
Re: iterating thru a collection
Posted by Alen Ribic <al...@mweb.co.za>.
Not to sure what is required here but for populating a select box options
with values and labels
I just create a java.util.List of beans.
e.g. Category bean
public class Category {
protected int id;
protected String name;
// getters/setters
}
Now you just load the List (e.g. categoryList of type java.util.List) into
the <options></options> tag specifying the value and label that will be
pulled out of the beans in the List. (e.g. value=Category.id;
label=Category.name)
something like that...:)
--Alen
----- Original Message -----
From: "Mark Galbreath" <ma...@qat.com>
To: "'Struts Users Mailing List'" <st...@jakarta.apache.org>
Sent: Thursday, June 19, 2003 2:49 PM
Subject: RE: iterating thru a collection
Looks like you need a Map, not a List.
Mark
-----Original Message-----
From: Natalie D Rassmann [mailto:natalie.d.rassmann@lmco.com]
Sent: Thursday, June 19, 2003 7:47 AM
To: Struts Users Mailing List
Subject: iterating thru a collection
I need to iterate thru a collection and put it in an <html-el:select> field.
How do I go about doing this....
My collection type looks like this....
ArrayList options
int selectedOption
The ArrayList of options is the following type:
String label
int id
Can anyone help me???
Thanks in advance...
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
RE: iterating thru a collection
Posted by Mark Galbreath <ma...@qat.com>.
Looks like you need a Map, not a List.
Mark
-----Original Message-----
From: Natalie D Rassmann [mailto:natalie.d.rassmann@lmco.com]
Sent: Thursday, June 19, 2003 7:47 AM
To: Struts Users Mailing List
Subject: iterating thru a collection
I need to iterate thru a collection and put it in an <html-el:select> field.
How do I go about doing this....
My collection type looks like this....
ArrayList options
int selectedOption
The ArrayList of options is the following type:
String label
int id
Can anyone help me???
Thanks in advance...
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org