You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Scott Vickery <sc...@virtual-systems.com> on 2005/12/06 18:04:10 UTC
nested c:forEach tag question
I am having a tough time getting my head around using tags in some
situations.
This works (the forms tag is part of common controls, and is not part of
the problem):
<logic:iterate name="configuration" id="ftr" indexId="ftrIdx">
<forms:row>
<forms:select width="100%">
<forms:label>
<c:out value="${ftr.key.ftrCode}"/>
</forms:label>
<c:forEach var="opt" items="${ftr.value}"><br>
<base:option key="${opt.optID}">
<c:out value="${opt.optCode}"/>
</base:option>
</c:forEach>
</forms:select>
</forms:row>
</logic:iterate>
But, if I replace the <c:forEach> with a <logic:iterate> like this:
<logic:iterate name="configuration" id="ftr" indexId="ftrIdx">
<forms:row>
<forms:select width="100%">
<forms:label>
<c:out value="${ftr.key.ftrCode}"/>
</forms:label>
<logic:iterate id="opt" property="${ftr.value}"><br>
<base:option key="${opt.optID}">
<c:out value="${opt.optCode}"/>
</base:option>
</logic:iterate>
</forms:select>
</forms:row>
</logic:iterate>
I get the error "Cannot find bean: "${ftr.value}" in any scope". Why?
In the inner iterate, I changed 'property' to 'collection' thinking that
would solve the problem, but, it did not. BTW, the reason I am using
the logic:iterate in the outer loop is for the indexId attribute.
Thanks,
Scott
Virtual Systems International, Inc.
1400 Crescent Green / ste. 215
Cary, NC 27511
Phone: (919) 319-0888
Fax: (919) 319-0884
scottv@virtual-systems.com
www.virtual-systems.com <http://www.virtual-systems.com/>
Re: nested c:forEach tag question
Posted by Laurie Harper <la...@holoweb.net>.
Scott Vickery wrote:
> I am having a tough time getting my head around using tags in some
> situations.
>
> This works (the forms tag is part of common controls, and is not part of
> the problem):
>
> <logic:iterate name="configuration" id="ftr" indexId="ftrIdx">
> <forms:row>
> <forms:select width="100%">
> <forms:label>
> <c:out value="${ftr.key.ftrCode}"/>
> </forms:label>
> <c:forEach var="opt" items="${ftr.value}"><br>
> <base:option key="${opt.optID}">
> <c:out value="${opt.optCode}"/>
> </base:option>
> </c:forEach>
> </forms:select>
> </forms:row>
> </logic:iterate>
>
> But, if I replace the <c:forEach> with a <logic:iterate> like this:
>
> <logic:iterate name="configuration" id="ftr" indexId="ftrIdx">
> <forms:row>
> <forms:select width="100%">
> <forms:label>
> <c:out value="${ftr.key.ftrCode}"/>
> </forms:label>
> <logic:iterate id="opt" property="${ftr.value}"><br>
> <base:option key="${opt.optID}">
> <c:out value="${opt.optCode}"/>
> </base:option>
> </logic:iterate>
> </forms:select>
> </forms:row>
> </logic:iterate>
>
> I get the error "Cannot find bean: "${ftr.value}" in any scope". Why?
> In the inner iterate, I changed 'property' to 'collection' thinking that
> would solve the problem, but, it did not. BTW, the reason I am using
> the logic:iterate in the outer loop is for the indexId attribute.
What servlet container are you using -- or, more specifically, what
version of the servlet specification? It looks like the JSTL expression
isn't getting evaluated, which suggests you're using Servlet 2.3 or
earlier (I think). If you're using Servlet 2.4 check your web.xml has
the right preamble.
Also, for logic:iterate, you need to either use 'name' in conjunction
with 'property', or use 'collection'. You can't use 'property' alone.
Finally, c:forEach has equivalent functionality to the indexId
attribute; see c:forEach's varStatus attribute. So you probably don't
need to switch tags anyway.
L.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: nested c:forEach tag question
Posted by Yujun Liang <yu...@acm.org>.
The problem is <logic:iterate id="opt" property="${ftr.value}">
The logic tag doesn't support JSTL ${ftr.value} as a property.
Regards
On 12/7/05, Scott Vickery <sc...@virtual-systems.com> wrote:
>
> I am having a tough time getting my head around using tags in some
> situations.
>
>
>
> This works (the forms tag is part of common controls, and is not part of
> the problem):
>
> <logic:iterate name="configuration" id="ftr" indexId="ftrIdx">
>
> <forms:row>
>
> <forms:select width="100%">
>
> <forms:label>
>
> <c:out value="${ftr.key.ftrCode}"/>
>
> </forms:label>
>
> <c:forEach var="opt" items="${ftr.value}"><br>
>
> <base:option key="${opt.optID}">
>
> <c:out value="${opt.optCode}"/>
>
> </base:option>
>
> </c:forEach>
>
> </forms:select>
>
> </forms:row>
>
> </logic:iterate>
>
>
>
> But, if I replace the <c:forEach> with a <logic:iterate> like this:
>
> <logic:iterate name="configuration" id="ftr" indexId="ftrIdx">
>
> <forms:row>
>
> <forms:select width="100%">
>
>
>
> <forms:label>
>
> <c:out value="${ftr.key.ftrCode}"/>
>
> </forms:label>
>
>
>
> <logic:iterate id="opt" property="${ftr.value}"><br>
>
> <base:option key="${opt.optID}">
>
> <c:out value="${opt.optCode}"/>
>
> </base:option>
>
> </logic:iterate>
>
>
>
> </forms:select>
>
> </forms:row>
>
> </logic:iterate>
>
>
>
> I get the error "Cannot find bean: "${ftr.value}" in any scope". Why?
> In the inner iterate, I changed 'property' to 'collection' thinking that
> would solve the problem, but, it did not. BTW, the reason I am using
> the logic:iterate in the outer loop is for the indexId attribute.
>
>
>
> Thanks,
>
> Scott
>
>
>
> Virtual Systems International, Inc.
> 1400 Crescent Green / ste. 215
> Cary, NC 27511
>
> Phone: (919) 319-0888
> Fax: (919) 319-0884
> scottv@virtual-systems.com
> www.virtual-systems.com <http://www.virtual-systems.com/>
>
>
>
>
>
--
Yujun Liang
yujun.liang@acm.org