7

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!

Abrikot
  • 965
  • 1
  • 9
  • 21

1 Answers1

13

Did you try...

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

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

wittich
  • 2,079
  • 2
  • 27
  • 50
Raul Cuth
  • 2,269
  • 1
  • 12
  • 17