Hi everyone,
There is any solution for Ajax Error Handler? the
"org.apache.myfaces.ERROR_HANDLER" seems dont work.
The following is my temp solution:
I hack the code about ajax exception handler. because I try the error handler
extension, it doesnot work for ajax. and I cant find out any extension point
either.
there is my code:
org.apache.myfaces.renderkit.ErrorPageWriter
{
.....
public static void handleThrowable(FacesContext facesContext, Throwable ex)
throws FacesException
{
...
if(!ajaxErrorHandlerInited){
try {
String ajaxErrorHandlerString =
facesContext.getExternalContext().getInitParameter("org.apache.myfaces.AJAX_ERROR_HANDLER");
if(ajaxErrorHandlerString != null){
Class<?> handler =
ErrorPageWriter.class.getClassLoader().loadClass(ajaxErrorHandlerString);
ajaxErrorHandler = handler.newInstance();
ajaxErrorHandlerMethod =
ajaxErrorHandler.getClass().getMethod("handleException", FacesContext.class,
}
} catch (Throwable e) {
e.printStackTrace();
} finally{
ajaxErrorHandlerInited = true;
}
}
if(ajaxErrorHandler != null){
try {
String message = (String)
ajaxErrorHandlerMethod.invoke(ajaxErrorHandler, facesContext, ex);
partialWriter.write(message);
} catch (Throwable e) {
e.printStackTrace();
if(ex.getCause() == null)
partialWriter.write(ex.getCause().toString());
else
partialWriter.write(ex.getMessage());
}
}else{
if (ex.getCause() != null)
{
partialWriter.write(ex.getCause().toString());
}
else
{
partialWriter.write(ex.getMessage());
}
}
...
}
.....
}
you can see I define a new "org.apache.myfaces.AJAX_ERROR_HANDLER" parameter
for myfaces. myfaces or specification should have this feature.
Best Regard
Mark