0

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.

user3352615
  • 119
  • 2
  • 5
  • 13

1 Answers1

2

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'}
Makhiel
  • 3,874
  • 1
  • 15
  • 21