You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Daniel PC Leung <pc...@gmail.com> on 2005/01/26 07:16:13 UTC
How to get the item of ArrayList?
The error message looks like this.
[ServletException in:/layout/tabsLayout.jsp] java.util.ArrayList'
The tabsLayout.jsp file looks like this.
(How can I solve it? Thanls)
<logic:iterate id="tab" name="tabList"
type="org.apache.struts.tiles.beans.MenuItem" >
<%
String href = request.getRequestURI() + "?"+parameterName + "=" + index;
String color = notSelectedColor;
if( index == selectedIndex )
{
selectedBody = tab.getLink();
color = selectedColor;
}
index++;
%>
<td bgcolor="<%=color%>">
<c:set var="tab" value="${tabList}"></c:set>
<c:set var="suffix" value="${fn:substringAfter(tab, '.')}"></c:set>
<c:choose>
<c:when test="${(suffix == 'gif') or (suffix == 'jpeg')}">
<a href="<%=href%>"> <%=tab.getValue()%> </a>
</c:when>
<c:otherwise>
<a href="<%=href%>"> <%=tab.getValue()%> </a>
</c:otherwise>
</c:choose>
</td>
<td width="1" >
</td>
</logic:iterate>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: How to get the item of ArrayList?
Posted by Kishore Senji <ks...@gmail.com>.
On Wed, 26 Jan 2005 14:16:13 +0800, Daniel PC Leung <pc...@gmail.com> wrote:
> The error message looks like this.
>
> [ServletException in:/layout/tabsLayout.jsp] java.util.ArrayList'
>
> The tabsLayout.jsp file looks like this.
> (How can I solve it? Thanls)
>
> <logic:iterate id="tab" name="tabList"
> type="org.apache.struts.tiles.beans.MenuItem" >
> <%
> String href = request.getRequestURI() + "?"+parameterName + "=" + index;
> String color = notSelectedColor;
> if( index == selectedIndex )
> {
> selectedBody = tab.getLink();
> color = selectedColor;
> }
> index++;
> %>
> <td bgcolor="<%=color%>">
> <c:set var="tab" value="${tabList}"></c:set>
I guess the exception is thrown in the subsequent lines and it's
because you over wrote "tab" to the collection (tabList) in the above
line from it's initial assignment to each "item" in the collection
(tabList) exposed through the "id" attribute of the <logic:iterate/>.
Removing the above <c:set/> line should get rid of the exception;
> <c:set var="suffix" value="${fn:substringAfter(tab, '.')}"></c:set>
> <c:choose>
> <c:when test="${(suffix == 'gif') or (suffix == 'jpeg')}">
> <a href="<%=href%>"> <%=tab.getValue()%> </a>
> </c:when>
> <c:otherwise>
> <a href="<%=href%>"> <%=tab.getValue()%> </a>
> </c:otherwise>
> </c:choose>
> </td>
> <td width="1" >
> </td>
>
> </logic:iterate>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org