struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brad Balmer <bbal...@peapod.com>
Subject Re: <html:options> tag usage?
Date Tue, 28 Jun 2005 18:21:13 GMT
Try adding the org.apache.strtuts.util.LabelValueBean into your 
Collection instead of DataBean and use the html:optionsCollection tag to 
render them.

--Notice the name/value pairs switched parameters.

class MyUtilBean {
    private Collection c;
    public Collection getC() {
        c = new ArrayList();
        c.add(new LabelValueBean ("name", "value"));
        c.add(new LabelValueBean ("name1", "value1"));
        c.add(new LabelValueBean ("name2", "value2"));
        return c;
    }

	//setting the value in some scope
	//request.setAttribute("COLLECTION", getC());
}

Then in your jsp:

<html:select property="">
    <html:optionsCollections name="COLLECTION"/>
</html:select>

Thai Dang Vu wrote:

>Hello everybody,
> 
>This is a part of my input.jsp file:
> 
><jsp:useBean id="myUtilBean" class="MyUtilBean"/>
>.......
> 
> 
>class MyUtilBean {
>    private Collection c;
>    public Collection getC() {
>        c = new ArrayList();
>        c.add(new DataBean("value", "name"));
>        c.add(new DataBean("value1", "name1"));
>        c.add(new DataBean("value2", "name2"));
>        return c;
>    }
>}
>.........................
>
>class DataBean {
>    private String name;
>    private String value;
>    // getter and setter methods
>....
>}
>
>How could I write the <html:options> tag in the input.jsp file so that the jsp file
produces
>
><select name="...">
>   <option value="name">value</option>
>   <option value="name1">value1</option>
>   <option value="name2">value2</option>
></select>
>
>Thanks so much.
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>For additional commands, e-mail: user-help@struts.apache.org
>
>  
>


Mime
View raw message