title: Cancel button navigation in JSF
body: <p>I have a cancel button on a page.
  But this page can be opened from different places. I mean the parent page can vary.</p>
  
  <p>Now, by clicking on the cancel button I need to go back to the exact page where I came from - like <code>history.back()</code>.</p>
  
  <p>How can we implement it in JSF?</p>
  
  <p>Can someone please guide me?</p>
  
  <p>And that <code>history.back()</code> directly is not working.</p>
  
  <pre><code>&lt;h:commandButton type="button" id="cancel" image="#{sessionScope.sessionObject.graphicImageFolderName}cancel_btn.gif" accesskey="#{bundle.oscer_command_cancel_accesskey}" value="Cancel" action="#{templatePrescriptionMaintenanceBackingBean.goBack}" /&gt;
  </code></pre>
  
  <p>In case of <code>history.back()</code> I am making the same button as..</p>
  
  <pre><code>&lt;h:commandButton type="button" id="cancel" image="#{sessionScope.sessionObject.graphicImageFolderName}cancel_btn.gif" accesskey="#{bundle.oscer_command_cancel_accesskey}" value="Cancel" onclick="javascript: history.back();"/&gt;
  </code></pre>
  
  <p>Is there anything wrong in both of the cases?</p>