I would like to declare a conditional method expression in EL like below:
<p:dataTable id="#{cc.attrs.datatableId}" var="overview"
rowSelectListener="#{cc.attrs.detailsMode == 'single' ? cc.attrs.bean.onRowSelect : cc.attrs.bean.onRowUrlSelect}">
However, it throws an EL exception:
javax.el.ELException: Not a Valid Method Expression: #{ cc.attrs.detailsMode == 'single' ? cc.attrs.bean.onRowSelect : cc.attrs.bean.onRowUrlSelect}
How I can declare a conditional EL method expression?
You can try with
For further reference, you can refer to https://docs.oracle.com/javaee/6/tutorial/doc/bnahu.html#bnahz
Unfortunately, method expressions does not accept value expressions. Your best bet is to have a single method entry point which in turn delegates further to the desired action methods based on the
detailsMode
which you also pass/set to the bean.E.g.
Given that you're actually using a composite component, you can if necessary hide it away in the backing component to reduce boilerplate in backing bean: