struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Lars Bergström <>
Subject RE: TreeMap vs html:optionsCollection
Date Tue, 16 Sep 2003 05:47:28 GMT
Thanks for the help Jason
Maybe that's the thing. I am still puzzled about the text from Jakarta's
own javadoc for the OptionsCollectionTag class which goes:
"The collection may be an array of objects, a Collection, an
Enumeration, an Iterator, or a Map."

In that case the javadoc isn't quit right, right?

Best regards


	-----Original Message----- 
	From: Jason Lea 
	Sent: må 2003-09-15 23:04 
	To: Struts Users Mailing List 
	Subject: Re: TreeMap vs html:optionsCollection

	I haven't used maps with <html:optionsCollection> so I don't
know if I
	can give you a definite answer on this.
	The optionsCollection tag is expecting a collection of objects
that it
	can call .getLabel() and .getValue() on (by default but it can
	changed with parameters).  To get a list of objects from a map
	normally call object.entrySet which you can then iterate over.
	entry set is a set of Map.Entry objects (they have getKey and
	So it looks like the tag is trying to do a .getLabel() on the
	object.  If the tag does accept maps I would have expected that
it knows
	about Map.Entry objects.
	I normally use List objects with pull-downs instead, like this:
	List eventGroups = new ArrayList();
	eventGroups.add(new LabelValueBean("Label 1","Value 1"));
	eventGroups.add(new LabelValueBean("Label 2","Value 2"));
	eventGroups.add(new LabelValueBean("Label 3","Value 3"));
	((EventGroupBean)form).setEventGroups( eventGroups );
	Lars Bergström wrote:
	> Dear Struts users,
	> I am trying to get my html:optionsCollection to work with a
TreeMap. I
	> don't
	> know if this is possible but on the Struts API page for the
	> OptionsCollectionTag I read the following:
	> "The collection may be an array of objects, a Collection, an
	> Enumeration, an
	> Iterator, or a Map."
	> (
	> onsCollectionTag.html)
	> Since TreeMap implements SortedMap which is a subinterface of
	> TreeMap
	> should work fine, right?
	> However, when the page is loaded I get the folloing error
	> "HTTP ERROR: 500 No getter method available for property label
for bean
	> under
	> name 1=LabelValueBean[Label 1, Value 1]"
	> Can anyone explain this error message? This seems strange to
	> The returntype in my ActionFormBean is TreeMap and the code
	> where I
	> build up the TreeMap is like this:
	> eventGroups = new TreeMap();
	> eventGroups.put( new String( "1" ),
	>                  new LabelValueBean( "Label 1",
	>                                      "Value 1" ) );
	> eventGroups.put( new String( "2" ),
	>                  new LabelValueBean( "Label 2",
	>                                      "Value 2" ) );
	> eventGroups.put( new String( "3" ),
	>                  new LabelValueBean( "Label 3",
	>                                      "Value 3" ) );
	> ((EventGroupBean)form).setEventGroups( eventGroups );
	> (
	> Best regards
	> Lasse
	Jason Lea
	To unsubscribe, e-mail:
	For additional commands, e-mail:

View raw message