How to use && in EL boolean expressions in Facelets?

Facelets is a XML based view technology. The & is a special character in XML representing the start of an entity like & which ends with the ; character. You’d need to either escape it, which is ugly:

rendered="#{beanA.prompt == true && beanB.currentBase != null}"

or to use the and keyword instead, which is preferred as to readability and maintainability:

rendered="#{beanA.prompt == true and beanB.currentBase != null}"

See also:

  • Java EE 6 tutorial – Operators in EL

Unrelated to the concrete problem, comparing booleans with booleans makes little sense when the expression expects a boolean outcome already. I’d get rid of == true:

rendered="#{beanA.prompt and beanB.currentBase != null}"

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)