[英]jsf 2.0 Expression language brackets not working
I have this attribute in my h:commandButton 我在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 如果它渲染disabled="false"
一切正常,但另一个抛出此异常
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
. #{setupManager.currentTerminals}
显然返回了一个ArrayList
,因此表达式#{not setupManager.currentTerminals}
将失败,因为它不是Boolean
。 Use the not empty
instead of not
. 使用not empty
而not
。 Here's a rewrite (note that empty
covers null
as well, you don't need to do a nullcheck before). 这是一个重写(请注意, empty
覆盖null
,之前不需要进行nullcheck)。
disabled="#{not empty nodeChild.children and not empty setupManager.currentTerminals}"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.