简体   繁体   中英

jsf 2.0 Expression language brackets not working

I have this attribute in my h:commandButton

disabled="#{ not ( ( nodeChild.children == null or empty nodeChild.children ) and ( not setupManager.currentTerminals ) ) }"

If it renders disabled="false" everything works but the other throws this exception

SEVERE: javax.faces.FacesException: java.lang.IllegalArgumentException: Cannot convert [] of type class java.util.ArrayList to class java.lang.Boolean

What is the best way of writing the above condition? Can I use the brackets?

The #{setupManager.currentTerminals} is apparently returning an ArrayList and thus the expression #{not setupManager.currentTerminals} will fail because it's not a Boolean . Use the not empty instead of not . Here's a rewrite (note that empty covers null as well, you don't need to do a nullcheck before).

disabled="#{not empty nodeChild.children and not empty setupManager.currentTerminals}"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM