Ah ok, sorry it was a tad late...
I personally agree, such a parameter would make sense,
it definitely would be nice to route the errors thrown into an error tag
in case of ajax instead of just pushing it up the server,
you might drop a note in the devs list for that or even provide a patch
in the issue tracker.
I am not even sure if we need such a parameter it might be even better
just to default it to <changes><error> in the case of being in a ppr
request, I am going to forward this to the devs list.
Werner
Am 24.06.10 07:42, schrieb Mark Li:
Hi werner, i know the<error> protocol, but i mean i want to handle the error in the
server side, Like converter the specific exception to a certain message or convert to other
exception. Then the message will be transferred via<error> to client side.
this is a littler difference with the other topic about "How can I notice if there
are facesmessages via ajax".
On Jun 24, 2010, at 5:10 AM, Werner Punz wrote:
Hia mark since you are directly on the response writer anyway, look at the ajax
protocol it has an<error> part where you can drag in errors which are pushed
into the ajax error listener queue automatically:
<partial-response>
<error>
<error-name>...</error-name>
<error-message>...</error-message>
</error>
</partial-response>
thats how it looks the error then is issued and an error listener is triggered.
The partialResponseWriter should have a startError element afair.
Werner
Am 23.06.10 18:56, schrieb Mark Li:
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