我有以下EL表达式,它引用了var属性的属性:
empty _item.addressLine1
addressLine1
是Address bean上的String属性,可通过personBean.person.addresses
属性访问,该属性返回Set<Address>
。
以下是上下文中的EL表达式:
<h:dataTable id="personBeanPersonAddresses" styleClass="data-table" value="#{forgeview:asList(personBean.person.addresses)}" var="_item">
<h:column>
<f:facet name="header">
<h:outputText value="Address Line 1"/>
</f:facet>
<h:link outcome="/address/view">
<f:param name="id" value="#{_item.id}"/>
<h:panelGroup rendered="#{!empty _item.addressLine1}">
<h:outputText id="itemAddressLine1" value="#{_item.addressLine1}"/><br/>
</h:panelGroup>
</h:link>
</h:column>
....
问题是表达式总是返回false,无论addressLine1是否为空字符串。好像要确认这一点,Eclipse中的facelet Validator会产生以下警告:
此空表达式始终计算为false。只有字符串,地图, 数组和集合对空运算符
具有有意义的值
但我不确定如何解决这个问题。我用jboss-el-api_2.2_spec-1.0.0.Final运行JBoss AS 7.1
答案 0 :(得分:4)
到目前为止代码看起来很好。此警告无效。如果它困扰你,请关闭Eclipse中的EL验证。
至于具体问题,#{_item.addressLine1}
本身很可能真的为空。你需要确保这不是空的。
答案 1 :(得分:2)
您也可以忽略此特定警告: 网络 - &gt; JavaServer Faces工具 - &gt;验证