Hi everybody,
I want to use <p:ajaxExceptionHandler> in my application.
Is it possible to get access to the exception of pfExceptionHandler in a backing bean?
I want to send an email in the case of an error.
Thanks for your help.
ExceptionHandler in backing bean
-
- PrimeFaces Core Developer
- Posts: 3979
- Joined: 03 Dec 2010, 14:11
- Location: Bavaria, DE
- Contact:
Code: Select all
ExceptionInfo info = facesContext.getApplication().evaluateExpressionGet(context, "#{pfExceptionHandler}", ExceptionInfo.class)
Code: Select all
FacesContext context = FacesContext.getCurrentInstance();
ExceptionInfo info = (ExceptionInfo) context.getAttributes().get(ExceptionInfo.ATTRIBUTE_NAME);
if (info == null) {
info = (ExceptionInfo) context.getExternalContext().getFlash().get(ExceptionInfo.ATTRIBUTE_NAME);
}
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
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
I'm using ajaxExceptionHandler & org.primefaces.application.exceptionhandler.PrimeExceptionHandlerFactory registered in my faces-config.xml and also have few error-pages defined in web.xml.
When an ajax exception occurs my xhtml page is able to retrieve all the info from pfExceptionHandler, however in case of exception during non-ajax request, the pfExceptionHandler is getting resolved to null in the error.xhtml(which is configured as error-page in web.xml).
I tried to debug the PrimeExceptionHandlerELResolver and found that its trying to get the ExceptionInfo object from Flash scope and eventually returning null.
Could someone please help me on this?
Note: Primefaces version : 5.0 and also I tried to retrieve the request attribute 'javax.servlet.error.exception' in my error.xhtml and even this is returned as empty.
Thanks.
When an ajax exception occurs my xhtml page is able to retrieve all the info from pfExceptionHandler, however in case of exception during non-ajax request, the pfExceptionHandler is getting resolved to null in the error.xhtml(which is configured as error-page in web.xml).
I tried to debug the PrimeExceptionHandlerELResolver and found that its trying to get the ExceptionInfo object from Flash scope and eventually returning null.
Code: Select all
public Object getValue(ELContext elContext, Object base, Object property) {
if (EL_NAME.equals(property)) {
elContext.setPropertyResolved(true);
FacesContext context = FacesContext.getCurrentInstance();
ExceptionInfo info = (ExceptionInfo) context.getAttributes().get(ExceptionInfo.ATTRIBUTE_NAME);
if (info == null) {
info = (ExceptionInfo) context.getExternalContext().getFlash().get(ExceptionInfo.ATTRIBUTE_NAME); // This is coming as null in my case
}
return info;
}
return null;
}
Could someone please help me on this?
Note: Primefaces version : 5.0 and also I tried to retrieve the request attribute 'javax.servlet.error.exception' in my error.xhtml and even this is returned as empty.
Thanks.
-
- Information
-
Who is online
Users browsing this forum: No registered users and 58 guests