title: OnComplete in JSF
body: <p>I have some confusion on the <code>Oncomplete</code> event in JSF. I am using primefaces.</p>
  
  <p>Here is what I have in the XHTML :-</p>
  
  <pre><code>&lt;p:commandButton id="createFruitBag" value="Create Fruit Bag" styleClass="ui-priority-primary create-fruit-button" rendered="#{(fruitShoppingEvent.fruitBean.Status eq 'Shopped') and  authenticatedUser.UserType() ne 'guest'}"
                      actionListener="#{OrderShopEvent.returnBag}"  oncomplete="if (args &amp;amp;&amp;amp; args.validationFailed) { resultDlg(status,args); } "
                       tabindex="520"                     
                       /&gt;
  </code></pre>
  
  <p>The actionListener is triggered and the code goes into the function - returnBag()</p>
  
  <p>But in the same Oncomplete if I have an else clause , that is, if validation is true (returned from the actionListener) the code should go to the checkOut page, and if it is false then it should call the javascript function. But when the else is set, the code never goes into the actionListener, it goes directly to the checkOut page.</p>
  
  <p>My else is something like this -</p>
  
  <pre><code>oncomplete="if (args &amp;amp;&amp;amp; args.validationFailed) { resultDlg(status,args); }  else { #{OrderShopEvent.redirectToCO()} } "
  </code></pre>
  
  <p>My question is :-
  1 - Is the onComplete firing for the render, or for the click?
  2 - If I want it to fire only for the click how do I handle it?</p>
  
  <p>I have gone through detailed examples @BaluC and others, but I cannot understand this clearly.</p>
  
  <p>Thank you very much.</p>
  
  <p>.</p>