I want to update an ui:param value or use something similar in ui:repeat loops with a condition. The idea is something as follows (is just an aprox, not the final implementation but I guess is understandable):
<ui:param name="marginLeftNode" value="#{myBean.initialMarginValue}" />
<ui:repeat value="#{myBean.viewWrapper.linkMap.entrySet().toArray()}" var="map">
<ui:repeat var="link" value="#{map.value}" varStatus="status">
<li style="margin-left: #{marginLeftNode}%" class="ico-#{link.getStyleCss()}-ayuda">
<a href="#{link.getUrlLink()}">#{link.getTitle()}</a>
</li>
<!-- Code conditions that doesn't works in any way as I've readed in the links after code -->
<c:if test="#{marginLeftNode gt 4}">
<ui:param name="marginLeftNode" value="#{myBean.viewWrapper.nodeList.get(status.index).depth}" />
</c:if>
<ui:fragment rendered="#{marginLeftNode gt 4}">
<ui:param name="marginLeftNode" value="#{myBean.viewWrapper.nodeList.get(status.index).depth}" />
</ui:fragment>
<!-- End code conditions: these are the two solutions c:if and ui:fragmen I tried -->
</ui:repeat>
</ui:repeat>
I can't use c:if inside ui:repeat because doesn't works (Specify conditional rendering of element inside <ui:repeat>? The <c:if> does not seem to work) and I can't use ui:fragment with ui:param because it doesn't works too (Conditional variable definition in JSF)
So, any idea how to solve that?
Changing the
ui:param
inside the loop has no real value. The real purpose of aui:param
is to pass runtime variables into a template client or included file. By the time your parameter has been passed in, there's little value in changing it. If all you want is to conditionally alter the value of the variable after it's been passed, you could just use JSTL'sc:set
to set a page-scoped variable that you could then useYou could then access your set variable as
#{marginLeftNode}
anywhere within that view