a4j:commandButton ternary operator is not working oncomplete

235 Views Asked by At

I am using a4j:commandButton it's not picking up the ternary operator.

Here is the code:

<a4j:commandButton styleClass="btn large" execute="@this phone-field phone-cc-field"  render="mobilemessage-overlay"
                                    value="Send" action="#{successBean.sendMobileMessage}" oncomplete="#{successBean.clearMessage} ? #{rich:component('mobilemessage-overlay')}.show(); : return false;">
                                </a4j:commandButton>

My expectation is once successBean.clearMessage=true it should populate the modal(mobilemessage-overlay) otherwise not.

Currently its not populating the modal in any scenario.

Any help would be really appreciated.

1

There are 1 best solutions below

0
On

You can just use "if", oncomplete doesn't need to return anything.

Anyway, you should be seeing an error in the console. The problem is that true ? someFunction() : return false is not valid JavaScript because return false is not an expression.

Now if for some reason you needed the return you could do it like this:

#{bean.isValid ? 'someFunction()' : 'return false'}