Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jsf 2.0 Expression language brackets not working

Tags:

java

jsf

jstl

el

jsf-2

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?

like image 642
Farouk Alhassan Avatar asked Dec 06 '25 03:12

Farouk Alhassan


1 Answers

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}"
like image 104
BalusC Avatar answered Dec 08 '25 16:12

BalusC