tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christian Taylor <christian.tay...@acadiau.ca>
Subject Re: <c:forEach> problem
Date Tue, 29 Mar 2005 19:09:52 GMT
Hi Nitin,

Your problem is in your "items" attribute on the forEach tag. You are
passing it a string-- you need to pass it the actual object. Like this:

...
<c:forEach var="directory" items="${CONTEXT_STRUCTURE.directories}">
...

You were not giving it as an expression (ie. the ${ ... }), so c:forEach
was was interpreting it as a string and iterating over the tokens in the
string. Give it a try as an expression and it should fix your problem.

Hope this was able to help.

 -Christian

nitin dubey wrote:

>Hello,
>
>My JSP code looks like this..
>
><c:if test="${! empty CONTEXT_STRUCTURE.directories}">
><c:forEach var="directory"
>items="CONTEXT_STRUCTURE.directories" >
><tr>
><td width="57%"><c:out value="${directory.name}"
>/></td>
><td width="22%">Template</td>
><td width="21%">&nbsp;</td>
></tr>
></c:forEach>
></c:if>
>
>
>CONTEXT_STRUCTURE will return an Object of class
>ContextStructure from the session scope. The sole two
>members in ContextStructure class is ArrayList
>directories, Arraylist files with its setters and
>getters. This ArrayList further has ContextItem class
>instances that has properties like name and path with
>its setters and getters.
>
>I am getting an exception
>
>Unable to find a value for "name" in object of class
>"java.lang.String" using operator "."
>
>when I try to access the name property of the
>ContextItem object as in the JSP code.
>
>Could anyone tell me where I am getting wrong ?
>
>Regards,
>
>
>Nitin Dubey
>
>__________________________________________________
>Do You Yahoo!?
>Tired of spam?  Yahoo! Mail has the best spam protection around 
>http://mail.yahoo.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


Mime
View raw message