struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael Lee" <>
Subject Re: HELP! html:options with a hashmap
Date Thu, 12 Sep 2002 20:14:07 GMT
Hmm, that's the way I'm trying/having to do it now, it just seems logical
that it would use the keys as the html option value and the map values as
labels by default. Oh well.
Ok, kinda depressing (We have to do this A LOT). Thanks for your help Joe.

----- Original Message -----
From: "Joe Barefoot" <>
To: "Struts Users Mailing List" <>
Sent: Thursday, September 12, 2002 3:51 PM
Subject: RE: HELP! html:options with a hashmap

You don't see an example because html:options expects a *Collection*, not a
Map.  I have no idea if the tag works with a Map, but it probably doesn't
because it expects a Collection object.  If you want to use a Map
implementation (like HashMap), then your property getter should return
myHashMap.entrySet() and you should set these attributes in the
<html:options tag>: property="value" labelProperty="key".  Something like

Struts javadocs are quite verbose:

Click on any of the taglib packages in the top left frame, then the package
name in the bottom left frame, then the "Description" link that comes up in
the right frame.  Gets you descriptions of any tag.  You can reach these
throught the Struts site as well.


> -----Original Message-----
> From: Michael Lee []
> Sent: Thursday, September 12, 2002 10:53 AM
> To: Struts Users Mailing List
> Subject: HELP! html:options with a hashmap
> I posted this before but haven't heard anything. Thought I
> would put up the error message too. What name do I put for
> name? The examples don't use a hashmap (seems logical for
> 'options'). When I put name it does the name and value. I
> want it to put the name under name and value under value, not
> both in the drop down.
> I want to populate an <html:select> with data from a Map
> (HashMap). I have
> ...
> <% pageContext.setAttribute("allUserRoles",
> Lookup.getData(Constant.USER.USER_ROLES)); %>
> ...
>     <bean:message key="prompt.user.role"/>
>     <html:select property="userRole" size="1">
>       <html:options collection="allUserRoles"/>
>     </html:select>
> I don't see an example in the struts-exercise-taglib.war
> under html:select
> It is vector or Object[].
> Ideas?
> thanks,
> Mike
> <Sep 12, 2002 1:48:29 PM EDT> <Error> <HTTP>
> <[WebAppServletContext(2285117,rece
> iptsplus,/receiptsplus)] Servlet failed with Exception
> java.lang.IllegalArgumentException: No name specified
>         at
> org.apache.struts.util.PropertyUtils.getNestedProperty(PropertyUtils.
> java:405)
>         at
> org.apache.struts.util.PropertyUtils.getProperty(
> 53)
>         at
> org.apache.struts.taglib.html.OptionsTag.doEndTag(
> )
>         at
> jsp_servlet.__create_user._jspService(
>         at weblogic.servlet.jsp.JspBase.service(

To unsubscribe, e-mail:
For additional commands, e-mail:

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message