jsf - Can we write like SQL IN clause (contains) in an EL expression -


i've below code find verbose:

#{bean.value eq 's' || bean.value eq 'c'} 

can simplify using sql in clause? fictive example below:

#{bean.value in ('s','c')} 

if you're using el 3.0 (java ee 7), can construct collection using #{[x,y,z]} syntax , perform contains() on it. provided desired bean property returns string (and not char or enum), should do:

#{['s','c'].contains(bean.value)} 

or if you're on el 2.2 (java ee 6), you've got hold values in collection (e.g. hashset) bean property , perform contains() on it:

#{bean.allowedvalues.contains(bean.value)} 

or if you're not on el 2.2 yet, then, well, stick initial approach, or create custom el function below:

#{f:contains(bean.value, bean.allowedvalues)} 

see also:


Comments

Popular posts from this blog

Java 3D LWJGL collision -

spring - SubProtocolWebSocketHandler - No handlers -

methods - python can't use function in submodule -