-
FEATURED COMPONENTS
First time here? Check out the FAQ!
I am writing an application in java using ZK (currently version 3.0.8, though we'll be upgrading that very soon). I've written an error message box that I want to use to catch various exceptions that are thrown from the application that show ugly java stack traces or sql errors to the user.
Is there a way to extend the Executions class so that ZK will use my extended class instead of the standard Executions class? Or an even better solution: is there a way of overriding the default behavior of giving a browser-based modal window showing the error so that I can use my custom error message box in its place?
I don't understood too much what you mean but you can add a error page in your web.xml. For xample:
<error-page>
<exception-type>java.lang.Throwable</exception-type>
<location>/WEB-INF/sys/errorPage.zul</location>
</error-page>
And when you app throws an exception the errorPage.zul is shown. The code in th errorPage.zul is:
<?xml version="1.0" encoding="UTF-8"?>
<zk xmlns="http://www.zkoss.org/2005/zul">
<window title="Operación no Exitosa"
border="normal"
width="50%" height="50%">
<grid>
<rows>
<row>
<hbox>
Error #
<label value="${requestScope['javax.servlet.error.status_code']}" />
</hbox>
</row>
<row>
Causa:
<label value="${requestScope['javax.servlet.error.message']}" />
</row>
<row>
Uri:
<label value="${requestScope['javax.servlet.error.request_uri']}" />
</row>
</rows>
</grid>
</window>
</zk>
HTH
Firstly, I should mention that we are writing all of the GUI components through Java, so none of the ZUL code applies to this application.
The application is running through one page and never changes the URL (and it should be noted that our application was designed specifically this way and won't be changing). The error message occurs in the event of an unexpected error that isn't handled in our code (NullPointerException for instance). Granted, our code should catch these errors for the most part, but occasionally they slip through. When an exception is thrown, a browser-based modal window pops up with the stack trace from the exception. I traced the exceptions being thrown back into the Executions class. The only way to catch all of the exceptions being thrown from the application is to put a try/catch block into the Executions class. Since this class is a part of the ZK library that we are using, I do not want to edit the file directly because when we update to newer versions of ZK, the changes will be overwritten.
I want to know if there is a way of having the application use a different Executions class from the default one similar to how you can do System.setOut(PrintStream) in java. Something like System.setExecutions(MyCustomExecutions). Obviously, it wouldn't be a system call, but hopefully you understand what I am trying to do.
If this isn't possible, is there a way of overriding the code that creates the browser-based popup windows so it will show my custom error box instead?
Example:
The behavior I am observing:
http://www.athemon.com/innoprise/null01.png
The behavior I want:
http://www.athemon.com/innoprise/null02.png
This behavior occurs when the user generates some event (button click, etc.), which means it is going through the Executions class (I can tell through the stack trace).
Hopefully this makes more sense.
Asked: 2009-11-04 17:08:48 +0800
Seen: 527 times
Last updated: Nov 17 '09