An empty EL expression in the var datatable var JSF attribute field is always false

I have the following EL expression that references the var attribute property:

empty _item.addressLine1

addressLine1 is the String property in the bean address accessed by the personBean.person.addresses property, which returns Set<Address> .

Here is an 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> .... 

The problem is that the expression always returns false, regardless of whether addressLine1 is an empty string or not. As if to confirm this, the front-end validator in Eclipse issues the following warning:

This empty expression always evaluates to false. Only row, maps, arrays and collection have significant values ​​for an empty statement

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

+4
source share
2 answers

The code still looks. This warning is not valid. Turn off EL checking in Eclipse if it bothers you.

As for the specific problem, most likely #{_item.addressLine1} will be really empty. You must make sure that it is not empty.

+4
source

You can also ignore this specific warning: Web -> JavaServer Faces Tools -> Validator

  • Permanent folding and unused code (section). An empty statement always allows false for type (Ignore).
+2
source

Source: https://habr.com/ru/post/1441434/


All Articles