struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael Lee" <mle...@hotmail.com>
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.
Mike

----- Original Message -----
From: "Joe Barefoot" <Joe.Barefoot@motiva.com>
To: "Struts Users Mailing List" <struts-user@jakarta.apache.org>
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
that.

http://java.sun.com/j2se/1.3/docs/api/index.html


Struts javadocs are quite verbose:

http://jakarta.apache.org/struts/doc-1.0.2/api/index.html

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.

peace,
Joe



> -----Original Message-----
> From: Michael Lee [mailto:mleejr@hotmail.com]
> 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(PropertyUtils.java:4
> 53)
>         at
> org.apache.struts.taglib.html.OptionsTag.doEndTag(OptionsTag.java:230
> )
>         at
> jsp_servlet.__create_user._jspService(__create_user.java:395)
>         at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
>

--
To unsubscribe, e-mail:
<mailto:struts-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail:
<mailto:struts-user-help@jakarta.apache.org>


--
To unsubscribe, e-mail:   <mailto:struts-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:struts-user-help@jakarta.apache.org>


Mime
View raw message