I want to set a ui:param depending on a bean value and I thought using c:if was a good idea. So I put in my page the following code:
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:wai="http://www.id.ethz.ch/wai/jsf"
template="/view/listView.xhtml">
<c:if test="#{subscriptionListController.model.listViewName eq 'mySubscriptions'}">
<ui:param name="title" value="#{msg.subscriptionTitleMySubscriptions}"/>
</c:if>
<c:if test="#{subscriptionListController.model.listViewName eq 'paidSubscriptions'}">
<ui:param name="title" value="#{msg.subscriptionTitlePaidSubscriptions}"/>
</c:if>
<c:if test="#{subscriptionListController.model.listViewName eq 'allSubscriptions'}">
<ui:param name="title" value="#{msg.subscriptionTitleAllSubscriptions}"/>
</c:if>
....
but the parameter is not set...
If I let print out the value of #{subscriptionListController.model.listViewName eq 'mySubscriptions'}
I get true in the corresponding case and false in the other two cases.
At the beginning I had only 2 possibilities and solved it with the ternary operator:
<ui:param name="title" value="#{subscriptionListController.model.listViewName eq 'mySubscriptions' ? msg.subscriptionTitleMySubscriptions : msg.subscriptionTitlePaidSubscriptions}"/>
and it worked. But now I have more possibilities...
What am I doing wrong?
<c:if>
s look fine, but<c:otherwise>
is completely misplaced. It belongs in a<c:choose>
. Also the code seems to be incomplete, this appears to be a template client, but I'm nowhere seeing an<ui:define>
. You do know that anything outside<ui:define>
and<ui:composition>
is ignored by Facelets? – Sundin<ui:composition>
is there (see the first row of the code) so it shouldn't be ignored. I removed the<c:otherwise>
and added ac:if
instead. but it still doesn't work... As said, with the ternary operator no-problems, but with thec:if
nope... (I edited my code, as the value for the title was wrong) – Arachnid<ui:define>
is defined below. I shifted thec:if
code there and now it works! But can you now explain me why with the tern. op. works although it is outside the<ui:define>
? Besides I have othersui:param
defined outside it (just below thec:if
) and they work... – Arachnid