0

I am watching this answer or this answer which describes how to make actionListener for example being reusable in case of facelets as :

<my:tag ... bean="#{myBean}" actionMethod="preFillData" />

...

<h:commandButton ... action="#{bean[actionMethod]}" />

It is good. The thing is I am confused about what if the values are null for example? Something like this but I am not sure is it workable in case jsf syntax (see next snippet) :

not tested

<h:commandButton ... action="#{(bean==null||actionMethod==null?myBeanB[myMethodB]:bean[actionMethod])}" />

The alike expression is causes Illegal Syntax for Set Operation exception being thrown... so I am not sure about the syntax :(*

So my question is... how to analyze the attribute(s) have values on client side?

Community
  • 1
  • 1
cbhogf
  • 91
  • 13
  • I am really confused about el expression in case of complicated boolean expression so any tip would be very helpful :S – cbhogf Oct 13 '16 at 18:05

1 Answers1

0

I tried to use if...else as :

<c:if test="#{bean!=null and actionMethod!=null}">
    <c:set var="variableAction" value="#{bean[actionMethod]}"/>
    </c:if>
    <c:if test="#{bean==null or actionMethod==null}">
    <c:set var="variableAction" value="#{somedefaultbean.method}"/>
    </c:if>

...

<h:commandButton ... actionListener="#{variableAction}" />

p.s.The solution is working fine but I am still looking for a shorter one so please feel free to add comments and helpful tips :)

Cheers

cbhogf
  • 91
  • 13