I haven't had time to play with tag files much, but here's a quick example that
may help:

map.jsp:
--------
<%@ page contentType="text/plain" %>
<%@ taglib prefix="tags" tagdir="/WEB-INF/tags" %>

selected.client before: '${selected.client}'
<tags:map>
selected.client during: '${selected.client}'
</tags:map>
selected.client after: '${selected.client}'


map.tag:
--------
<%@ variable name-given="selected"
             variable-class="java.util.Map" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<jsp:useBean id="selected" class="java.util.HashMap"/>
<c:set target="${selected}" property="client" value="checked"/>
<jsp:doBody/>

output:
-------
selected.client before: ''

selected.client during: 'checked'

selected.client after: ''

The reason the value is only updated within the body of the tag is because the
default scope for the variable directive is "NESTED". That also means you need
to do something like use the <jsp:doBody> action to actually process the body
in the calling page and update the value.

Quoting Derek Mahar <[EMAIL PROTECTED]>:

> How does one create an associative array variable in a JSP tag file
> using the EL?  I had no luck with the following attempt:
> 
> <%@ variable name-given="selected"
>   variable-class="java.util.Map"%>
> 
> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
> 
> <c:choose>
>   <c:when test="${value == 'Client'}">
>     <c:set var="selected.client" value="checked"/>
>   </c:when>
>   <c:when test="${value == 'Broker'}">
>     <c:set var="selected.broker" value="checked"/>
>   </c:when>
>   <c:when test="${value == 'Both'}">
>     <c:set var="selected.broker" value="checked"/>
>   </c:when>
>   <c:otherwise>
>     <c:set var="selected.client" value="checked"/>
>   </c:otherwise>
> </c:choose>
> 
> Thank you,
> 
> Derek
> 
> -------------------------------------
> Derek Mahar
> Software Developer
> Penson Financial Services Canada
> 360 St-Jacques St West, 12th Floor
> Montreal QC  H2Y 1P5
> 514.841.9665 x212 Phone
> 514.841.3750 Fax

-- 
Kris Schneider <mailto:[EMAIL PROTECTED]>
D.O.Tech       <http://www.dotech.com/>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to