<html:options> tag help
1 posts in topic
Flat View  Flat View

Posted By:   Ashish_Kulkarni
Posted On:   Thursday, August 29, 2002 02:53 PM


I get a result set from a query which has id and description, now I have to show the it in select tag some thing like this,

I think that i can use tag which will do my work, but i m not sure how to use it,

how do to define the bean, and also how to set the properties, does anyone have sample code of the bean and the tag for that bean, it will help me alot..



Re: <html:options> tag help

Posted By:   Paul_Sijpkes  
Posted On:   Thursday, August 29, 2002 05:19 PM

Hi Ashish,

You will need to do something like this.


Notice that the select tag has a "myPreselectedItemBean" bean associated with it, this bean must be in some scope ie. session, request etc..

The same goes for the "myCollection" bean, this is a bit more complex. Took me a while to get my head around...

"myCollection" should be either be an Object extending java.util.Collection or an array of Objects. It can't be a simple type (eg. int[]).

"myCollection" should be made up of other beans, with a getMyValue() and getMyLabelProperty() method.


public class OptionItem


public OptionItem()



String myValue;

String myLabel;

public String getMyValue()


return myValue;


public void setMyValue(String myValue)


this.myValue = myValue;


public String getMyLabel()


return myLabel;


public void setMyLabel(String myLabel)


this.myLabel = myLabel;



I normally create a Vector and then populate it with these sort of beans.

I hope this is helpful to you.


Paul Sijpkes
About | Sitemap | Contact