JSF不为null条件

时间:2017-06-13 07:24:40

标签: jsf el

使用JSF& EL,我基本上试图检查变量是否为空(或不是)。

以下是代码段:

<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>

首先检查,#{not empty graphique}始终为false,即使graphique不为空。我尝试使用#{graphique ne null}#{graphique != null},但它也是假的。

当我删除c:if语句时,会显示图表。因此,graphique不为空。

我在很多网站上寻找解决方案 - 包括SO - 但是没有设法找到解决方案。

你知道发生了什么以及如何解决我的问题吗?

谢谢!

1 个答案:

答案 0 :(得分:6)

你试过......

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

有时我在<c:if>

中遇到过primefaces标签的问题