You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-user@tomcat.apache.org by Helios Alonso <ha...@atg.com.uy> on 2004/10/12 16:45:15 UTC

RE: [JSTL] Retrieving the key from a LinkedMap for a known value?

Can't you change the whole thing to work always with the key, and only do 
the key->value mapping?  Or maybe you can have a bean with both mappings:

UsersBean
+ idByUserName: Map
+ userNameById: Map

if you really need it (it is, in case both key and value are valid "codes" 
and not only final results).

At 04:33 10/10/2004 +1000, you wrote:
>G'day,
>
>Ummmmmm, this returns the value associated with the key... I need to do the
>opposite whereby I have the value and I need it's key.
>
>Thanks.
>AB
>
>-----Original Message-----
>From: Tim Troy [mailto:ttroy@nycap.rr.com]
>Sent: Saturday, 9 October 2004 10:33 PM
>To: taglibs-user@jakarta.apache.org
>Subject: FW: [JSTL] Retrieving the key from a LinkedMap for a known value?
>
>
>I have a bean with a HashMap named errorCodes.  To access a key using jstl,
>I do the following:
>
><c:out value="${bean.errorCodes['categoryId']}"></c:out>
>
>-----Original Message-----
>From: Adrian Beech [mailto:a.beech@bigpond.net.au]
>Sent: Saturday, October 09, 2004 1:59 AM
>To: 'Tag Libraries Users List'
>Subject: [JSTL] Retrieving the key from a LinkedMap for a known value?
>
>
>G'day all,
>
>Is it possible to retrieve the key from a LinkedMap for a known value using
>the expression language syntax under JSTL 1.0?
>
>For example, I have a LinkedMap object which is being used to generate a
>drop down with the <input:select .../> tag from the Input taglib.  Apart
>from needing the value selected by the user from the drop down I need to
>pull the corresponding key for display purposes on the next page along in
>the food chain.  As I've already got the key/value pairs in a LinkedMap
>within the session context I was hoping to merely say "well here is the
>value from the drop down now give me the key which was used as the display
>text for that drop down".
>
>Does this sort of make sense?
>
>AB
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
>
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
>
>
>__________ NOD32 1.889 (20041008) Information __________
>
>This message was checked by NOD32 antivirus system. http://www.nod32.com
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: taglibs-user-help@jakarta.apache.org


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


RE: [JSTL] Retrieving the key from a LinkedMap for a known value?

Posted by Kris Schneider <kr...@dotech.com>.
How about adding some JavaScript to update the value of a hidden input to
contain the key? That way you get both the key and the value submitted as
request params.

Quoting Helios Alonso <ha...@atg.com.uy>:

> Can't you change the whole thing to work always with the key, and only do 
> the key->value mapping?  Or maybe you can have a bean with both mappings:
> 
> UsersBean
> + idByUserName: Map
> + userNameById: Map
> 
> if you really need it (it is, in case both key and value are valid "codes" 
> and not only final results).
> 
> At 04:33 10/10/2004 +1000, you wrote:
> >G'day,
> >
> >Ummmmmm, this returns the value associated with the key... I need to do the
> >opposite whereby I have the value and I need it's key.
> >
> >Thanks.
> >AB
> >
> >-----Original Message-----
> >From: Tim Troy [mailto:ttroy@nycap.rr.com]
> >Sent: Saturday, 9 October 2004 10:33 PM
> >To: taglibs-user@jakarta.apache.org
> >Subject: FW: [JSTL] Retrieving the key from a LinkedMap for a known value?
> >
> >
> >I have a bean with a HashMap named errorCodes.  To access a key using jstl,
> >I do the following:
> >
> ><c:out value="${bean.errorCodes['categoryId']}"></c:out>
> >
> >-----Original Message-----
> >From: Adrian Beech [mailto:a.beech@bigpond.net.au]
> >Sent: Saturday, October 09, 2004 1:59 AM
> >To: 'Tag Libraries Users List'
> >Subject: [JSTL] Retrieving the key from a LinkedMap for a known value?
> >
> >
> >G'day all,
> >
> >Is it possible to retrieve the key from a LinkedMap for a known value using
> >the expression language syntax under JSTL 1.0?
> >
> >For example, I have a LinkedMap object which is being used to generate a
> >drop down with the <input:select .../> tag from the Input taglib.  Apart
> >from needing the value selected by the user from the drop down I need to
> >pull the corresponding key for display purposes on the next page along in
> >the food chain.  As I've already got the key/value pairs in a LinkedMap
> >within the session context I was hoping to merely say "well here is the
> >value from the drop down now give me the key which was used as the display
> >text for that drop down".
> >
> >Does this sort of make sense?
> >
> >AB

-- 
Kris Schneider <ma...@dotech.com>
D.O.Tech       <http://www.dotech.com/>

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