tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dmk...@earthlink.net (David M. Karr)
Subject Re: Getting values from a Map in JSTL-EL
Date Sat, 23 Nov 2002 06:19:11 GMT
>>>>> "Affan" == Affan Qureshi <quereshi@etilize.com> writes:

    Affan> I have two questions. How to get values if my bean has a method that returns
    Affan> a Map? I have a bean with getValues() method that returns a Map.
    Affan> I have tried
    Affan> <c:out value="${specs.values.paramId}" />

    Affan> <c:out value="${specs.values[paramId]}" />

    Affan> <c:out value="${specs.values.map.paramId}" />

    Affan> But I get the following error:
    Affan> Unable to find a value for "map" in object of class
    Affan> "java.util.HashMap$Values" using operator "."'  (correspondingly)

Did you try all three of these at the same time?  The last one is obviously
broken, which is why you got the error.

The second one and the first one are actually slightly different.  The first
one looks for a key of "paramId" in the map, and the second one looks in the
map with a key that is STORED IN the scoped attribute named "paramId".  If you
wanted to change the second one to do the same thing as the first, change it
to:

  <c:out value='${specs.values["paramId"]}' />

    Affan> Also my bean also has a method that takes a String and returns the value
    Affan> Object from the map. Its signature is:
    Affan> public Object getValue(String key)

    Affan> How do I use this method using EL?

You can't.  This kind of expression (called "mapped properties") is supported
by the Jakarta Commons BeanUtils package, but not with the JSTL.

-- 
===================================================================
David M. Karr          ; Java/J2EE/XML/Unix/C++
dmkarr@earthlink.net   ; SCJP



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


Mime
View raw message