I searched the archives and couldn't find anything relevent.
I'm trying to use the Iterate.java tag in some code I have. I pass the collection but the nested usebean tag cannot find the object in page scope.
500 Internal Server Error
java.lang.InstantiationException: Could not find the bean named 'product1'
in the page scope
at /product_demo.jsp._jspService(/product_demo.jsp.java:171)
at com.evermind.server.http.EvermindHttpJspPage.service(JAX)
at com.evermind.server.http.HttpApplication.r4(JAX)
at com.evermind.server.http.JSPServlet.service(JAX)
at com.evermind.server.http.c9.oh(JAX)
at com.evermind.server.http.c9.forward(JAX)
at com.evermind.server.http.dg.b8(JAX)
at com.evermind.util.e.run(JAX)
If I put an object in scope of the correct type it iterates through
the list and prints everything out so I know the collection is fine.
<% pageContext.setAttribute("product1", product);
<ts:iterate name="product1" collection="<%= products %>">
<jsp:useBean id="product1" scope="page" type="com.ratex.db.Product"/>
<!-- Product: <%=product1 %> -->
<tr>
<td>
<jsp:getProperty name="product1"
property="productId"/>
</td>
<td> <%=product1.getCategory() %> </td>
<td> <%=product1.getName() %> </td>
<td> <%=product1.getDescription() %> </td>
</tr>
</ts:iterate>
I haven't quite figured out the code but it seems it should work correctly.
Seems like the
setAttribute(...) is not getting called.
public int doStartTag() {
if(iterator == null) { //Make sure we have a Iterator
return SKIP_BODY;
}
if(iterator.hasNext()) { //check if we got more
elements
// add the Bean to the pageContext using
the given name
pageContext.setAttribute(name, iterator.next(),
PageContext.PAGE_SCOPE);
return EVAL_BODY_TAG;
}
else {
return SKIP_BODY;
}
}
Any help would be appreciated.
Eric :-)