On Feb 8, 2011, at 1:49 AM, ute Hoffmann wrote:
Hallo,
I get sometimes Error Messages containing DirectActions which do not exist.
Some of them happen when a page is not yet fully loaded and a _javascript_ is executed
containing a image, then the image appears in a DirectAction call like this:
FusszeielundImpressumaendern_b-poster.jpgAction()
The image is in the page, but the Action not.
Has someone an explanation for this and perhaps a solution to avoid this?
Can one catch a java.lang.reflect.InvocationTargetException and if yes, where should I do this?
In DirectAction.java? In Application?
I would like to catch all Exceptions originating from non-existing DirectAction Calls if possible.
public WOResponse dispatchRequest(WORequest aRequest) {
try {
String uri = aRequest.uri();
String appURLPrefix = aRequest.applicationURLPrefix();
String reqHandlerKey = aRequest.requestHandlerKey();
if ( uri.startsWith(appURLPrefix+"/"+reqHandlerKey+"/") &&
(uri.endsWith(".gif") || uri.endsWith(".jpg") || uri.endsWith(".png")) ) {
WOResponse imageReplacement = new WOResponse();
imageReplacement.setStatus(WOResponse.HTTP_STATUS_NOT_FOUND);
imageReplacement.disableClientCaching();
return imageReplacement;
}
} catch (Exception e) {
NSLog.err.appendln("Error while checking request for images we don't handle. User likely lost the session.");
}
return super.dispatchRequest(aRequest);
}