0

Possible Duplicate:
How to pass parameters to ui:include that inside of c:forEach tag

This one ( How do I set Managed Bean field to the value of a ui:param? ) is working well. If I'm looping the ui:include with the help of a JST c:forEach the Facelet Attributes (ui:param) always resolves to null.

<c:forEach items="#{myList} var="myItem">
    <ui:include src="#{myItem.myPage}">
        <ui:param name="myVar" value="#{myItem.myData}"/>
    </ui:include>   
</c:forEach>

And I'm trying to resolve the Facelet Attribute within a JSF Managed Bean (which is exclusively for exact one ui:include per JSF view)

FacesContext facesCtx = FacesContext.getCurrentInstance();
FaceletContext faceletCtx = (FaceletContext) facesCtx.getAttributes().get(FaceletContext.FACELET_CONTEXT_KEY);
Object myVar = faceletCtx.getAttribute("myVar");

As long as I'm not looping the (no c:forEach) this approach works well. But after introducing the c:forEach myVar is always null.

What is JSTL c:forEach changing at the facelet attributes (names)? How can I still access them in my Backing Bean?

Unfortunately FaceletContext does not expose any methods to list all facelet attributes, so I might "find" them on my own ... :S

Community
  • 1
  • 1
Panda
  • 26
  • 4

1 Answers1

1

Thing is that c:forEachis not ment to use with JSF. So that's why we have <ui:repeat> which does basically the same but it's part of the JSF component tree. Further explanation for example here

Roger Keays
  • 3,117
  • 1
  • 31
  • 23
Petr Mensik
  • 26,874
  • 17
  • 90
  • 115
  • Unfortunately I have to according to [this](http://stackoverflow.com/questions/3362487/dynamic-uiinclude-inside-uirepeat-is-there-a-simple-solution#3362534) and [belonging description](http://www.ninthavenue.com.au/blog/c:foreach-vs-ui:repeat-in-facelets) ... I thought JSF (2.X) got native support for selected JSTL Tags (incl. forEach), so it should work, shouldn't it? – Panda Jul 02 '12 at 08:54
  • @Panda updated link: https://rogerkeays.com/jsf-c-foreach-vs-ui-repeat – Roger Keays Feb 26 '21 at 15:43