2

I would like to know how can I combine multiple boolean coniditions in EL. I have following example and it is not working.

<x:someComponent rendered="#{bean.condition1} or #{bean.condition2}">

How can I use "OR" and "AND" logical operators in EL?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Rehman
  • 3,908
  • 6
  • 28
  • 29

2 Answers2

7

The operator has to go inside the EL expression, not outside. You should see the #{...} as one big scope wherein various variables/conditions interact with each other.

<x:someComponent rendered="#{bean.condition1 or bean.condition2}">

See also:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • Thanks.. it work. But i am getting validation error "cannot coerce first boolean argument". – Rehman Jun 16 '12 at 15:46
  • Apparently it's `null`. You need either to make sure that it's never `null`, or to add a `not empty` or `!= null` check. – BalusC Jun 16 '12 at 18:34
1

The operator OR in an expression EL is ||.

Try this:

<ice:panelCollapsible  rendered ="#{mySessionBean.buttonVisibilities['myButton1'] || mySessionBean.buttonVisibilities['myButton2']}">

See this tutorial http://docs.oracle.com/javaee/1.4/tutorial/doc/JSPIntro7.html

Regards

esmoreno
  • 658
  • 5
  • 12