First and foremost: JSTL tags runs during view build time, not during view render time.
Your concrete problem suggests that #{projectPageBean}
is been set during view render time, such as would happen when definied as <ui:repeat var>
, <h:dataTable var>
, <p:tabView var>
, etc. It's thus null
during view build time.
In that case, you should not be using a view build time tag to conditionally render HTML. You should instead use a view render time component to conditionally render HTML. As first choice, use <ui:fragment>
:
<p>#{projectPageBean.availableMethods}</p>
<ui:fragment rendered="#{projectPageBean.availableMethods}">
<p>Abc</p>
</ui:fragment>
<ui:fragment rendered="#{not projectPageBean.availableMethods}">
<p>Xyz</p>
</ui:fragment>
By the way, there's in Facelets no need to switch between #{}
and ${}
. In contrary to JSP, in Facelets the ${}
behaves exactly the same as #{}
. To avoid potential confusion and maintenance trouble, I recommend to stick to #{}
all the time.
See also: