【问题标题】:JSF not null condition [duplicate]JSF非空条件[重复]
【发布时间】:2017-11-14 20:11:36
【问题描述】:

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

这是一个代码sn-p:

<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 - 但没有设法找到解决方案。

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

谢谢!

【问题讨论】:

  • 感谢@BalusC,我明白我的问题到底是什么。我会尝试修复它,然后发布正确的答案。
  • Abrikot,已经回答了。
  • 好吧,我以为我已经尝试过 Raul Cuth 的回答。但显然没有。对不起!

标签: jsf el


【解决方案1】:

你试过了吗……

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

有时我在&lt;c:if&gt; 中遇到 primefaces 标签问题

【讨论】:

    猜你喜欢
    • 2012-05-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-14
    • 1970-01-01
    • 2013-05-19
    • 2012-06-02
    相关资源
    最近更新 更多