Say I have the following for each in a stripes layout definition
<c:foreach items="${foo}" var="bar" >
<s:layout-component name="whatever" />
</c:foreach>
Then when I render I do something like this
<s:layout-component name="whatever">
//Do something with bar
</s:layout-component>
The whatever component is rendered before being placed in the layout so bar is null and it fails. Is there a way I can build a whole page before the jsp is parsed?
Seeing the absence of any answer and the question looking fairly trivial, I don’t think there are many Stripes users out here. so here are my two cents:
This is definitely a scoping problem. the
<s:layout-component>doesn’t have access to the page/loop scope of the parent page. Similar problem exist in JSP/JSTL when you do a<jsp:include>inside a<c:forEach>. The loop variable is inaccessible in the code snippet included by<jsp:include>. But in JSP/JSTL that could be solved by passing a<jsp:param>along the<jsp:include>. I took a quick look in the Stripes documentation and I discovered a<stripes:param>. See if that helps. At least here’s a JSP/JSTL based SSCCE to get the idea:main.jsp
include.jsp
output: