title: JSF onevent or js depending on ajax listener result
body: <p>I need ideas to solve next situation.</p>
  
  <p>I have a commandButton with ajax that invokes a listener with a boolean method, something like this:</p>
  
  <pre><code>&lt;h:commandButton value="Add"&gt;
      &lt;f:ajax listener="#{shoppingCartBean.makeReservation(devicesBean.device)}" /&gt;
  &lt;/h:commandButton&gt;
  </code></pre>
  
  <p>If the listener returns true, its because device is correctly reserved, everything works fine and I need to redirect to another url with a location.href js function.</p>
  
  <p>If the listener returns false, I need that a js alert will be shown with a "Sorry, no device stock bla bla bla".</p>
  
  <p>How can I manage that? Thx in advance.</p>