On Fri, 13 Sep 2002, Xavier Prélat wrote:

> I want to create a dynamic select box using JSTL core and xml tags.
> 
> // setting a variable called 'selector'
> <c:set var="selector"><%= strAction %></c:set>
> 
> // displaying select box...all html tags are not represented...it's not my
> mistake ;-)
> 
> <x:forEach select="$xmlMenu/modules/module" var="mod">
>  <x:if select="$mod/module-load-status = '${selector}'">
>     <option value="<x:out select="$mod/@id"/>">&nbsp;<x:out
> select="$mod/@name"/></option>
>  </x:when>
> </x:forEach>
> 
> This problem is that I can't get a value for ${selector} in the line :
> <x:if select="$mod/module-load-status = '${selector}'">
> 
> Any ideas....I am getting a bit confused about the way to access variables
> from these tags!

Normally, you can use JSTL's expression language to access attributes
dynamically.  However, this is inconsistent with XPath's syntax, so you
cannot use the JSTL EL in an XPath expression.  The rule is simple:  you
can't use the EL in any JSTL <x:*> tag attribute named "select."

Instead, simply refer to 'selector' via an XPath variable:

  $mod/module-load-status = $selector

See the JSTL spec or "JSTL in Action" for a list of what namespace
prefixes can be used within an XPath expression (e.g., "$sessionScope:foo"
and so forth).

-- 
Shawn Bayern
"JSTL in Action"   http://www.jstlbook.com


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

Reply via email to