I have the following defined in web.xml:
<error-page>
<exception-type>java.lang.Throwable</exception-type>
<location>/shared/errors/DefaultErrorPage.xhtml</location>
</error-page>
<error-page>
<exception-type>javax.faces.application.ViewExpiredException</exception-type>
<location>/shared/errors/ViewExpired.xhtml</location>
</error-page>
I'm also using the FullAjaxExceptionHandler from Omnifaces in faces-config.xml:
<factory>
<exception-handler-factory>
org.omnifaces.exceptionhandler.FullAjaxExceptionHandlerFactory
</exception-handler-factory>
</factory>
The FullAjaxExceptionHandler is working fine for ajax calls, but when I hit a page directly and there is an error, it starts rendering the page I was trying to go to, but it doesn't finish, and then the error page defined in web.xml is rendered, which results in the error page being embedded after a partially rendered page.
(I'm using Glassfish 3.1.1 which has Mojarra JSF 2.1.3) Edit: now using Glassfish 3.1.2.2 and JSF 2.1.11
Edit: Discovered the following:
The page where the error is happening is using templates (<ui:composition template="/shared/shared/commonLayout.xhtml">
) If I change it so that the page is no longer using the template, and then just add in all of the code from the template then it works fine.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…