Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>JSF 1.x doesn't provide any implicit error handling of this type, though you can redirect to an error page using navigation rules (assuming a form post)...</p> <pre><code>&lt;navigation-case&gt; &lt;description&gt; Handle a generic error outcome that might be returned by any application Action. &lt;/description&gt; &lt;display-name&gt;Generic Error Outcome&lt;/display-name&gt; &lt;from-outcome&gt;loginRequired&lt;/from-outcome&gt; &lt;to-view-id&gt;/must-login-first.jsp&lt;/to-view-id&gt; &lt;/navigation-case&gt; </code></pre> <p>...or using a redirect...</p> <pre><code>FacesContext context = FacesContext.getCurrentInstance(); ExternalContext extContext = context.getExternalContext(); String url = extContext.encodeActionURL(extContext .getRequestContextPath() + "/messages.faces"); extContext.redirect(url); </code></pre> <p>I recommend looking at the <a href="http://java.sun.com/javaee/javaserverfaces/reference/api/" rel="nofollow noreferrer">JSF specification</a> for more details.</p> <p>Error messages can be placed on the request scope/session scope/url parameters, as you like.</p> <hr> <p>Assuming a Servlet container, you can use the usual <a href="http://java.sun.com/javaee/5/docs/tutorial/doc/bnaeo.html#bnaet" rel="nofollow noreferrer">web.xml error page configuration</a>.</p> <pre><code>&lt;error-page&gt; &lt;exception-type&gt;java.lang.Exception&lt;/exception-type&gt; &lt;location&gt;/errorPage.faces&lt;/location&gt; &lt;/error-page&gt; </code></pre> <p>In your backing bean, you can wrap and throw your checked exceptions in <a href="http://java.sun.com/javase/6/docs/api/java/lang/RuntimeException.html#RuntimeException(java.lang.Throwable)" rel="nofollow noreferrer">RuntimeException</a>s.</p> <p>Some JSF implementations/frameworks will catch these errors (Apache MyFaces/Facelets), so you'll have to <a href="http://wiki.apache.org/myfaces/Handling_Server_Errors" rel="nofollow noreferrer">configure them not to</a>.</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