Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Indeed, JSF as being a form based application targeted MVC framework submits the POST form to the very same URL as where the page with the <code>&lt;h:form&gt;</code> is been requested form. You can confirm it by looking at the <code>&lt;form action&gt;</code> URL of the generated HTML output. This is in web development terms characterized as <em>postback</em>. A navigation on a postback does by default not cause a new request to the new URL, but instead loads the target page as content of the response. This is indeed confusing when you merely want page-to-page navigation.</p> <p>Generally, the right approach as to navigation/redirection depends on the business requirements and the <a href="http://en.wikipedia.org/wiki/Idempotence" rel="noreferrer">idempotence</a> (read: "bookmarkability") of the request.</p> <ul> <li><p>If the request is idempotent, just use a GET form/link instead of POST form (i.e. use <code>&lt;form&gt;</code>, <code>&lt;h:link&gt;</code> or <code>&lt;h:button&gt;</code> instead of <code>&lt;h:form&gt;</code> and <code>&lt;h:commandXxx&gt;</code>).<br> For example, page-to-page navigation, Google-like search form, etc.</p></li> <li><p>If the request is non-idempotent, just show results conditionally in the same view (i.e. return <code>null</code> or <code>void</code> and make use of e.g. <code>&lt;h:message(s)&gt;</code> and/or <code>rendered</code>).<br> For example, data entry/edit, multi-step wizard, modal dialog, confirmation form, etc.</p></li> <li><p>If the request is non-idempotent, but the target page is idempotent, just send a redirect after POST (i.e. return outcome with <code>?faces-redirect=true</code> or <code>&lt;redirect/&gt;</code>).<br> For example, showing list of all data after successful editing, redirect after login, etc.</p></li> </ul> <p>Note that pure page-to-page navigation is usually idempotent and this is where many JSF starters fail by abusing command links/buttons for that and then complain afterwards that URLs don't change. Also note that navigation cases are very rarely used in real world applications which are developed with respect to SEO/UX and this is where many JSF tutorials fail by letting the readers believe otherwise.</p> <p>Also note that using POST is absolutely not "more secure" than GET because the request parameters aren't immediately visible in URL. They are still visible in HTTP request body and still manipulatable. So there's absolutely no reason to prefer POST for idempotent requests for the sake of "security". The real security is in using HTTPS instead of HTTP and checking in business service methods if currently logged-in user is allowed to query entity X, or to manipulate entity X, etc. A decent security framework offers annotations for this. </p> <h3>See also:</h3> <ul> <li><a href="https://stackoverflow.com/questions/11277366">What is the difference between redirect and navigation/forward and when to use what?</a></li> <li><a href="https://stackoverflow.com/questions/18037884">JSF implicit vs. explicit navigation</a></li> <li><a href="https://stackoverflow.com/questions/13249844">Bookmarkability via View Parameters feature</a></li> <li><a href="https://stackoverflow.com/questions/6377798">What can &lt;f:metadata&gt;, &lt;f:viewParam&gt; and &lt;f:viewAction&gt; be used for?</a></li> <li><a href="https://stackoverflow.com/questions/4317684">When should I use h:outputLink instead of h:commandLink?</a></li> <li><a href="https://stackoverflow.com/questions/8459903">Creating master-detail pages for entities, how to link them and which bean scope to choose</a></li> <li><a href="https://stackoverflow.com/questions/17734230">Retaining GET request query string parameters on JSF form submit</a></li> <li><a href="https://stackoverflow.com/questions/25694423">Pass an object between @ViewScoped beans without using GET params</a></li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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