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 "Canning, Chuck" <ch...@zilliant.com> on 2003/07/31 20:40:04 UTC
problem with forEach
Hi,
I am using JSTL and struts-el in a form, but the foreach is not returning my
values. If I use a scriplet, I see them. Here is a snippet of code in same
JSP. I added the scriptlet just to test that I wasn't working to late and
doing something stupid ;)
<%
List alist;
Iterator iterator;
MessageHeader mHeader;
alist = (List)request.getAttribute("headerList");
//get the iterator
iterator = alist.iterator();
//step through
while (iterator.hasNext() == true) {
mHeader = (MessageHeader)iterator.next();
%>
sender <%=mHeader.getSender()%><br>
subject <%=mHeader.getSubject()%><br>
messageId <%=mHeader.getMessageId()%>
<%
}
%>
<c:forEach items="${headerList}" var="header">
<c:choose>
<c:when test="${index} % 2 == 0">
<TR bgcolor="FFEDED">
</c:when>
<c:otherwise>
<TR bgcolor="FFD8D8">
</c:otherwise>
</c:choose>
<td>
<c:out value="${header.sender}"/>
<c:out value="${header.subject}"/>
<c:out value="${header.messageId}"/>
<html-el:multibox property="values" value="${header.messageId}"/>
</td>
<td align="left" width="25%" class="subtext">
<c:out value="${header.sender}"/>
</td>
<td align="left" width="50%">
<c:out value="${header.subject}"/>
</td>
<td align="right" width="25%">
<fmt:formatDate value="${header.date}" type="BOTH" dateStyle="LONG"
timeStyle="MEDIUM"/>
</td>
</tr>
</c:forEach>
The scriplet shows all the fields, the JSTL/el tags show no values, but it
does have do the correct number of iterations through the list.
Any help would be greatly appreciated.
Chuck
---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
Re: problem with forEach
Posted by Chris Winters <cw...@optiron.com>.
Canning, Chuck wrote:
> I am using JSTL and struts-el in a form, but the foreach is not returning my
> values. If I use a scriplet, I see them. Here is a snippet of code in same
> JSP. I added the scriptlet just to test that I wasn't working to late and
> doing something stupid ;)
I'm pretty sure 'header' is a reserved variable. Try assigning the
list members to a variable of another name and see what happens.
Chris
--
Chris Winters (cwinters@optiron.com)
Senior Software Architect
---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org