JSF数据表var属性的字段上的空EL表达式始终为false

JSF数据表var属性的字段上的空EL表达式始终为false

本文介绍了JSF数据表var属性的字段上的空EL表达式始终为false的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下EL表达式,该表达式引用了var属性的一个属性:

I have the following EL expression which references a property on the var attribute:

empty _item.addressLine1

addressLine1是Address Bean上的String属性,可通过personBean.person.addresses属性访问该属性,该属性返回Set<Address>.

addressLine1 is a String property on the Address bean, which is accessed via the personBean.person.addresses property which returns a Set<Address>.

以下是上下文中的EL表达式:

Here is the EL expression in context:

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

问题在于,无论addressLine1是否为空字符串,表达式始终返回false.好像要确认这一点,Eclipse中的Facelet Validator会产生以下警告:

The problem is the expression always returns false, regardless of whether addressLine1 is the empty string or not. As if to confirm this, The facelet Validator in Eclipse produces the following warning:

但是我不确定如何解决此问题.我正在运行带有jboss-el-api_2.2_spec-1.0.0.Final的JBoss AS 7.1.

But I'm not sure how to fix this. I'm running JBoss AS 7.1 with jboss-el-api_2.2_spec-1.0.0.Final

推荐答案

到目前为止,代码看起来还不错.此警告无效.如果您不满意,请在Eclipse中关闭EL验证.

The code looks fine so far. This warning is invalid. Turn off EL validation in Eclipse if it bothers you.

对于具体问题,#{_item.addressLine1}本身很可能是真的为空.您需要确保它不为空.

As to the concrete problem, most likely the #{_item.addressLine1} itself is really empty. You need to make sure that this is not empty.

这篇关于JSF数据表var属性的字段上的空EL表达式始终为false的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-21 14:09