tarka
tarka

Reputation: 5587

JSF EL and + or condition

What would be the best way to format the following condition as in EL?

#{bean.booleanValue and (bean.stringValue ne 'MYCLOSED' or bean.stringValue ne 'ALLCLOSED')}"

The brackets don't seem to be recognised as a valid expression but it is a requirement that the statement logically render as follows:

bean.booleanValue && (bean.stringValue != 'MYCLOSED' || bean.stringValue != 'ALLCLOSED')

Upvotes: 1

Views: 4513

Answers (1)

darthbinamira
darthbinamira

Reputation: 544

You can use a ternary operator for the first expression and if it evaluates to true then you evaluate the rest of the expression, else you return false.

e.g. bean.booleanValue ? bean.stringValue ne 'MYCLOSED' or bean.stringValue ne 'ALLCLOSED' : false;

This is what we currently use when dealing with multiple conditions in a single expression.

Upvotes: 2

Related Questions