Error handling not working

UI Components for JSF
Post Reply
dur0
Posts: 5
Joined: 01 Sep 2011, 10:56

12 Dec 2011, 11:32

Hi, its actually a JSF thing, but maybe it has something to do with primefaces too. I use standard error handling in web.xml like this:
<error-page>
<exception-type>java.lang.Throwable</exception-type>
<location>/pages/error.jsp</location>
</error-page>
I made a test, but its not working this way. E.g. i have a button:
<p:commandButton value="Copy" action="#{qaTool.copyJobs}"
styleClass="jobs" update="messages" />
and in the method copyJobs() i intentionally throw an uncaught exception. I'd expect to navigate to error.jsp, but instead nothing happens :-(
thanks for ideas!

tandraschko
PrimeFaces Core Developer
Posts: 3979
Joined: 03 Dec 2010, 14:11
Location: Bavaria, DE
Contact:

12 Dec 2011, 11:51

The problem is the ajaxrequest. If a exception would occur on a normal request, your container error-page would work.
You could fix this with a custom JSF ExceptionHandler which redirects via

Code: Select all

facesContext.getExternalContext().redirect(...);
Also you must register then your own ExceptionHandlerFactory via your faces-config:

Code: Select all

....
	<factory>
		<exception-handler-factory>xxx.MyExceptionHandlerFactory</exception-handler-factory>
	</factory>
</faces-config>
Thomas Andraschko

PrimeFaces | PrimeFaces Extensions

Apache Member | OpenWebBeans, DeltaSpike, MyFaces, BVal, TomEE

Sponsor me: https://github.com/sponsors/tandraschko
Blog: http://tandraschko.blogspot.de/
Twitter: https://twitter.com/TAndraschko

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 22 guests