JSF 非空条件
JSF not null condition
使用 JSF 和 EL,我基本上是在尝试检查变量是否为 null(或不是)。
这是一个代码片段:
<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}
始终为假,即使 graphique
不为空。我尝试使用 #{graphique ne null}
和 #{graphique != null}
,但它也是错误的。
当我删除 c:if
语句时,显示图表。因此,graphique
不为空。
我在很多网站上寻找解决方案 - 包括 SO - 但未能找到解决方案。
你知道我的问题是怎么回事以及如何解决吗?
谢谢!
你试过吗...
<p:chart type="line" model="#{graphique}" rendered="#{graphique != null}"/>
有时我在 <c:if>
中遇到 primefaces 标签问题
使用 JSF 和 EL,我基本上是在尝试检查变量是否为 null(或不是)。
这是一个代码片段:
<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}
始终为假,即使 graphique
不为空。我尝试使用 #{graphique ne null}
和 #{graphique != null}
,但它也是错误的。
当我删除 c:if
语句时,显示图表。因此,graphique
不为空。
我在很多网站上寻找解决方案 - 包括 SO - 但未能找到解决方案。
你知道我的问题是怎么回事以及如何解决吗?
谢谢!
你试过吗...
<p:chart type="line" model="#{graphique}" rendered="#{graphique != null}"/>
有时我在 <c:if>