Reputation: 106
I am trying to loop through an Arraylist on my JSP without any luck.
I am able to loop through this successfully but only hit this error while trying to dynamically change the "
I have tried all different approaches by opening and closes the tags, trying different enclosure characters namely: single quotes and double quotes.
The error that I am getting is as follows:
javax.el.MethodNotFoundException: Method not found: class java.util.ArrayList.getChartName()
at javax.el.Util.findWrapper(Util.java:351)
at javax.el.Util.findMethod(Util.java:214)
at javax.el.BeanELResolver.invoke(BeanELResolver.java:174)
This what my JSP looks like:
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@include file="header.jsp" %>
<div id="content_main">
<c:if test="${not empty dashboardDetail}"></c:if>
<c:forEach var="dashboardDetailList" items="${dashboardDetail}">
<div id="${dashboardDetail.getChartName()}" style="width: 100%; height: 400px;"> </div>
</c:forEach>
</div>
<%@include file="footer.jsp" %>
Upvotes: 0
Views: 1939
Reputation: 11579
Try this:
<c:forEach var="dashboardDetailObject" items="${dashboardDetail}">
<div id="${dashboardDetailObject.chartName}"
style="width: 100%; height: 400px;"></div>
</c:forEach>
dashboardDetailList
changed to dashboardDetailObject
Upvotes: 1
Reputation: 195
From the names you've used, you've got them the wrong way around.
<c:forEach var="dashboardDetailList" items="${dashboardDetail}">
items
should be the list and var
the current element. But you've referred to dashboardDetail
correctly inside the loop. Switch the names (for every reference to the list):
<c:forEach var="dashboardDetail" items="${dashboardDetailList}">
The error occurs because as you have it now, you are calling getChartName()
on an ArrayList
, and that method doesn't exist.
Upvotes: 2