title: p:button with onclick javascript hook
body: <p>I'm using p:button with onclick action. (I can't move to p:commandButton, because of legacy outcome navigation in faces-config.xml and custom navigation history in db):</p>
  
  <pre><code>&lt;p:remoteCommand name="unlock_tt" actionListener="#{ttEntityMBean.unlock()}"/&gt;
  &lt;p:button value="#{msgs['button.ok']}" outcome="#{ttEntityMBean.navigationMenuItemToRedirect.navigationRule}" onclick="unlock_tt()"/&gt;
  </code></pre>
  
  <p>Generated by primefaces javascript looks like</p>
  
  <pre><code>onclick="unlock_tt(); window.open(....)"
  </code></pre>
  
  <p>And after clicking button, unlock_tt() in browser initiated, but immediatly broken by page redirecting, so backed java method didn't execute.
  Should I make unlock_tt() or java call async to be sure it will be executed before browser leaves page?</p>
  
  <p>Upd: I'm thinking to use p:commandButton, if it is possible to get to-view-id programically, like in this question:</p>
  
  <p><a href="https://stackoverflow.com/questions/29011040/programmatically-get-navigation-case-to-view-id-from-faces-config-xml-by-outco">Programmatically get navigation case &lt;to-view-id&gt; from faces-config.xml by outcome</a></p>
  
  <pre><code>&lt;p:commandButton action="#{ttEntityBean.unlock()}"/&gt;
  public String unlock() {
    //some business logic
    return OutcomeResolverHelper.getRuleFor(navigationMenuItemToRedirect.navigationRule)
  }
  </code></pre>
  
  <p>This should reduce number of requests</p>