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