Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JSF not null condition [duplicate]

Tags:

jsf

el

Using JSF & EL, I'm basically trying to check if a variable is null (or not).

Here is a code snippet:

<p:dataGrid value="#{bean.graphiques}"
            var="graphique"
            rows="1" columns="3">
    <c:if test="#{not empty graphique}">
        <p:chart type="line" model="#{graphique}"/>
    </c:if>
    <c:if test="#{empty graphique}">
        <p:outputLabel>
            Add a new chart.
        </p:outputLabel>
    </c:if>
</p:dataGrid>

First check, #{not empty graphique} is always false, even if graphique is not null. I tried with #{graphique ne null} and #{graphique != null}, but it's false, too.

When I remove the c:if statement, the chart is displayed. Thus, graphique is not null.

I looked for a solution on a lot of websites - including SO - but didn't manage to find a solution.

Do you know what's going on and how to solve my problem?

Thanks!

like image 311
Abrikot Avatar asked Jun 13 '17 07:06

Abrikot


Video Answer


1 Answers

Did you try...

<p:chart type="line" model="#{graphique}" rendered="#{graphique != null}"/>

Sometimes I had issues with primefaces tags in <c:if>

like image 149
Raul Cuth Avatar answered Sep 21 '22 00:09

Raul Cuth