title: JSF 2 - which ways exist to find back to the calling page?
body: <p>My web application has two search pages - search1.jsf and search2.jsf - which share the same bean which in turn calls a result page - result.jsf. </p>
  
  <p>So both search pages have a commandButton</p>
  
  <pre><code> &lt;h:commandButton value="Commit" action="#{search.commit}" /&gt;
  </code></pre>
  
  <p>The "search" bean then processes the search and forwards to the result page using </p>
  
  <pre><code>target = "result?faces-redirect=true";
  </code></pre>
  
  <p>Now the result.jsf doesn't know which search page has been used. How can I pass the calling page so that the called page is able to render a link back to the calling page?</p>
  
  <p>Using the browser back button (or Javascript code) to go back in the history has the disadvantage that the user, after browsing through the results, only would go back one page in the results instead of going 'up' to the search parameter form.</p>
  
  <p>Options I see so far are: </p>
  
  <ul>
  <li><p>pass the caller page name through the chain to the result page, using <code>&lt;f:param&gt;</code> or action="#{search.commit(name_of_calling_page)}</p></li>
  <li><p>put all 'search parameter' forms in one JSF page and conditionally switch the content</p></li>
  </ul>
  
  <p>Or is there a JSF functions which returns the name of the calling JSF page?</p>