Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Use <code>&lt;f:param&gt;</code> and <code>&lt;f:viewParam&gt;</code>:</p> <p><strong>Source page:</strong></p> <pre><code>&lt;p:commandLink styleClass="toolbar" action="/application/customerApplicationManagement.jsf"&gt; &lt;p:graphicImage url="/resources/gfx/search.png" /&gt; &lt;h:outputText value="#{msg.menu_searchApplications}" styleClass="toolbarLink" /&gt; &lt;f:param name="fromPage" value="funding.xhtml" /&gt; &lt;/p:commandLink&gt; </code></pre> <p><strong>Destination page (bound):</strong></p> <pre><code>&lt;f:metadata&gt; &lt;f:viewParam name="fromPage" value="#{destinationBacking.fromPage}" /&gt; &lt;/f:metadata /&gt; &lt;h:link value="Go back!" outcome="#{destinationBacking.fromPage}" /&gt; </code></pre> <p><strong>Destination page (unbound):</strong></p> <pre><code>&lt;f:metadata&gt; &lt;f:viewParam name="fromPage" /&gt; &lt;/f:metadata /&gt; &lt;h:link value="Go back!" outcome="fromPage" /&gt; </code></pre> <p><strong>Backing bean (only if you want to bind the param):</strong></p> <pre><code>@ManagedBean @ViewScoped public class DestinationBacking{ String fromPage; public String getFromPage(){ return fromPage; } public void setFromPage(String frompage){ fromPage = frompage; } } </code></pre> <p>Your view path will be binded to <code>fromPage</code> property from the destination backing bean and after you can use it to return to the original page.</p> <p>Also I want to say that this way is a bit 'hackeable' by the end user, I mean, you're passing the original path through pure url. See also other ways to achieve that, as <a href="http://mkblog.exadel.com/2010/07/learning-jsf2-using-flash-scope/" rel="nofollow">flash scope</a>, which is very useful specially if you're working with <code>@ViewScoped</code> beans.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload