From JSF1.1 Spec section 9.2.8:
 

JSF component custom actions may not be nested inside a custom action that iterates over its body (such as JSTL’s <c:forEach>).

Instead, you should use a Renderer that performs its own iteration (such as the Table renderer used by

<h:dataTable>).

 
**********************************
Michael Burati
Senior Software Engineer
Bowstreet
200 Ames Pond Drive
Tewksbury, MA 01876
T 978-863-1512
F 978-863-1555
www.bowstreet.com

Get the latest information on Bowstreet's events and web seminars.

 


From: Randahl Fink Isaksen [mailto:[EMAIL PROTECTED]
Sent: Monday, June 20, 2005 12:20 PM
To: MyFaces Discussion
Subject: What is the right way to iterate

I have been trying to use c:forEach in my jspx pages but I keep experiencing different kinds of problems. An example:

        <c:forEach items="${treeMenuContractBean.menuItems}" var="menuItem">
            <div style="margin-left: ${menuItem.marginLeft}">
                <c:out value="${menuItem.prelude}"/>
                <h:outputLink title="#{menuItem.name}" value="#{menuItem.uri}">
                    <c:out value="${menuItem.name}"/>
                </h:outputLink>
                <c:out value="${menuItem.postlude}"/>
            </div>
        </c:forEach>

When this is run, I get
<a id="tree-menu-contract:_id1" href=""></a>
<a id="tree-menu-contract:_id2" href=""></a>
<div style="margin-left: 0px">The name of menu item 0</div>
<div style="margin-left: 50px">The name of menu item 1</div>
Now as you can see this result has several problems:
  1. The #{} value bindings have no effect - it is as if the menuItem var is invisible to JSF, thus the href attribute is empty
  2. The div tags do not surround the anchor tags as intended - is it really a requirement to use the x:div tag?
So I have been thinking that maybe using c:forEach is not compatible with JSF - is there an alternative?

Any hints will be highly appreciated.


Randahl

Reply via email to