Well, your suggestion almost worked. I got the keys and values printed out but
the "test" wouldn't work!
Here is what I tried to do:
<c:forEach items="${fRoles}" var="item">
<c:if test="${item.key} == 'manager'">
Found manager
</c:if>
</c:forEach>
Is the syntax right? Anyway the above code doesn't find the key manager while
I can print it out using your suggestion.
I also tried this and it didn't work...
<c:choose>
<c:when test="${ not empty fRoles['manager']}" >
Found formRoles manager
</c:when>
<c:otherwise>
NOT Found
</c:otherwise>
</c:choose>
Do you have any other suggestions?
Thanks for your help
NK
-----Original Message-----
From: Jarnot Voytek Contr AU/SC [mailto:[EMAIL PROTECTED]
Sent: Thursday, December 02, 2004 12:18 PM
To: 'Struts Users Mailing List'
Subject: RE: JSTL when...test won't work.
What happens when you try:
<c:forEach var="element" items="${fRoles}">
<c:out value="Key=${element.key}, Value=${element.value}"/>
</c:forEach>
instead of logic:iterate
> Nadia Kunkov wrote:
>
> > Hello,
> >
> > This is my first try with JSTL and somewhere I'm getting
> the syntax wrong. Could you please help me?
> > I have a bean called user in the session. One of this
> bean's properties is a hash map called frmRoles. I need to
> go over the hashmap's keys and test if a particular key
> exists. I'm not getting an error when I run the jsp, it
> just tells me that this key is not found. But I can print
> all the keys so its my c:choose test syntax. The code that
> gives me a problem is in bold face. I also would like to ask
> you to point me to the documentation on the syntax used
> within c:when test. Is it regular expressions or JSTL syntax?
> >
> > I'd appreciate any help.
> >
> > Thanks in advance.
> >
> > NK
> >
> > <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
> > <%@ taglib prefix="c_rt" uri="http://java.sun.com/jstl/core_rt" %>
> > <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
> > <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
> > <%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
> >
> > <html>
> > <head>
> > <title>Welcome World!</title>
> > <html:base/>
> > </head>
> > <body bgcolor="white">
> > <logic:present scope="session" name="user">
> > <h3>Welcome <bean:write name="user" property="userId"/>!</h3>
> > <br>
> > <bean:write name="user" property="userFName"/>
> > <bean:write name="user" property="userLName"/>
> > </logic:present>
> > <logic:notPresent scope="session" name="user">
> > <h3>Welcome World!</h3>
> > </logic:notPresent>
> > <html:errors/>
> > <ul>
> > <li><html:link forward="logon">Sign in</html:link></li>
> > <logic:present scope="session" name="user">
> > <li><html:link forward="logoff">Sign out</html:link></li>
> > <br>
> > <br>
> > <bean:define id="fRoles" name="user" property="frmRoles"/>
> > <logic:iterate id="element" name="fRoles">
> > Key is <bean:write name="element" property="key"/> <br>
> > Value is <bean:write name="element" property="value"/> <br>
> > </logic:iterate>
> > <c:choose>
> > <c:when test="${fRoles['manager'] != null}">
> > Found formRoles manager
> > </c:when>
> > <c:otherwise>
> > NOT Found
> > </c:otherwise>
> > </c:choose>
> >
> > </logic:present>
> > </ul>
> > <img src='struts-power.gif' alt='Powered by Struts'>
> >
> > </body>
> > </html>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]