Consider the following jstl choose:
<c:choose>
<c:when test="#{AuthMsgBean.rw['2'] ne null}">
Display Text
</c:when>
<c:otherwise>
<ph:outputText id="pan" value="Component pan could not be created." />
</c:otherwise>
</c:choose>
AuthMsgBean = Bean
rw = Map
'2' = Key
Question:
When I simply display the #{AuthMsgBean.rw['2'] ne null}
value it displays fine (true), but once I try to parse the value to the <c:when test=""/>
the when tag re-acts as if the test is always false.
If I put true in the test (test="true"
) the Display Text is displayed.
Could it be that the <c:when>
tag is evaluated before the #{AuthMsgBean.rw['2'] ne null}
expression?
If so, is there a workaround?
JSTL and JSF do not run in sync as you'd expect from coding. During JSF view build time, it's JSTL which runs from top to bottom first to produce a view with only JSF tags. During JSF view render time, it's JSF which runs from top to bottom again to produce a bunch of HTML.
Apparently the #{AuthMsgBean}
is not present in the scope when it's JSTL's turn to run. That can happen when the tags are placed inside a JSF iterating component such as <h:dataTable>
.
Regardless, you do not want to use JSTL here. Make use of the JSF rendered
attribtue.
<h:panelGroup rendered="#{not empty AuthMsgBean.rw['2']}">
Display Text
</h:panelGroup>
<h:outputText id="pan" value="Component pan could not be created." rendered="#{empty AuthMsgBean.rw['2']}" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With