title: How to use action return value in javascript(oncomplete)?
body: <p>I have a commandButton and I want to call a javascript function when it is completed. the problem is I have to use the return of the action method in the oncomplete function. I assumed that I can use an attribute like this:</p>
  
  <pre><code>&lt;p:commandButton value="پیش نمایش گزارش" ajax="true" id="showReport" update=":panel 
  showReport" action="#{reportUIBean.showReport()}" oncomplete=
  "if(#{reportUIBean.successful}){dialog.show();}" process="@this" /&gt;
  </code></pre>
  
  <p>The problem with this is although the update runs before the oncomplete function but it wont work properly. I think it is because the function is already in command stack.
  I tried another way by using onsuccess but will always call the function because I have to catch the exceptions. is there any way to call a javascript function and use a JSF value in it?</p>