D...">

JSTL c: select c: if you are not working on the JSF page

Consider the following jstl:

<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 just show the value #{AuthMsgBean.rw['2'] ne null} , it displays "fine", but as soon as I try to parse the value into <c:when test=""/> when the tag will act as if the test was always false.

If I return in the test ( test="true" ), the displayed text will be displayed.

Could it be that the <c:when> is evaluated before the expression #{AuthMsgBean.rw['2'] ne null} ?

If so, is there a workaround?

+3
source share
1 answer

JSTL and JSF do not sync as you expected from encoding. During JSF build, the time it takes to create the JSTL is from top to bottom to get an idea with only JSF tags. During the JSF view time view, the JSF starts up again to create a bunch of HTML.

Apparently, #{AuthMsgBean} missing in the area when it is launched by JSTL. This can happen when tags are placed inside an iterative JSF component, for example, <h:dataTable> .

Regardless, you do not want to use JSTL here. Use the JSF rendered attribute.

 <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']}" /> 

See also:

+8
source

Source: https://habr.com/ru/post/945916/


All Articles