I've the below code which I find verbose:
#{bean.value eq 'S' || bean.value eq 'C'}
Can we simplify this using something like the SQL IN
clause? Fictive example below:
#{bean.value in ('S','C')}
I've the below code which I find verbose:
#{bean.value eq 'S' || bean.value eq 'C'}
Can we simplify this using something like the SQL IN
clause? Fictive example below:
#{bean.value in ('S','C')}
If you're using EL 3.0 (Java EE 7), then you can simply construct a Collection
using #{[x,y,z]}
syntax and perform a contains()
on it. Provided that the desired bean property returns a String
(and thus not char
or enum
), then this should do:
#{['S','C'].contains(bean.value)}
Or if you're only on EL 2.2 (Java EE 6), then you've got to hold the values in some Collection
(e.g. HashSet
) as a bean property and perform contains()
on it:
#{bean.allowedValues.contains(bean.value)}
Or if you're even not on EL 2.2 yet, then, well, stick to your initial approach, or create a custom EL function something like below:
#{f:contains(bean.value, bean.allowedValues)}
AFAIK You can't . But you can hold values to be checked against in a HashMap . And you can then check as
#{pageFlowScope.beanName.mapVar[bindings.Dept.attributeValue] == null}
You can check whether the value returned is null/empty or not.
Sid