0

Extending Executions class in Java

asked 2009-11-04 17:08:48 +0800

mgolowka gravatar image mgolowka
30 1

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?

delete flag offensive retag edit

5 Replies

Sort by » oldest newest

answered 2009-11-05 12:02:55 +0800

mgolowka gravatar image mgolowka
30 1

Bump.

Thanks in advance to anyone who helps.

link publish delete flag offensive edit

answered 2009-11-05 15:15:09 +0800

YamilBracho gravatar image YamilBracho
1722 2

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

link publish delete flag offensive edit

answered 2009-11-05 17:24:34 +0800

mgolowka gravatar image mgolowka
30 1

updated 2009-11-05 17:25:03 +0800

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.

link publish delete flag offensive edit

answered 2009-11-11 12:53:14 +0800

mgolowka gravatar image mgolowka
30 1

Bump...

link publish delete flag offensive edit

answered 2009-11-17 13:53:05 +0800

mgolowka gravatar image mgolowka
30 1

I hate bumping twice...

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2009-11-04 17:08:48 +0800

Seen: 527 times

Last updated: Nov 17 '09

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More