Documentos de Académico
Documentos de Profesional
Documentos de Cultura
PRODUCT
DEMO
download
WHY ZK
COMMUNITY
DOCUMENTATION
SUPPORT
Google Wiki
Search
Documentation
Overview
ZK
ZK Studio
ZK Spring
ZK Spreadsheet
ZK Calendar
ZK JSP
讚 7 人說這讚。成
為你朋友中第一
Here we describe how to handle errors. An error is caused by an exception that is not caught by the
application. An exception might be thrown in two situations: when loading a ZUML document, and when serving an AU request (aka, an Ajax request).
By default, the Web server displays an error page showing the error message and stack trace. For example,
You can customize the error handling by specifying the error page in WEB-INF/web.xml as follows[1] .
Then, when an error occurs in loading a page, the Web server forwards the error page you specified, /error/error.zul. Upon forwarding, the Web server
passes a set of request attributes to the error page to describe what happens. These attributes are as follows.
Then, in the error page, you can display your custom information by use of these attributes. For example,
books.zkoss.org/wiki/…/Error_Handling 1/3
2011/3/7 ZK - ZK Developer's Reference/UI Patter…
1 <window title="Error ${requestScope['javax.servlet.error.status_code']}">
2 Cause: ${requestScope['javax.servlet.error.message']}
3 </window>
Tips:
The error page can be any kind of servlets. In addition to ZUML, you can use JSP or whatever servlet you preferred.
Then, if you click the button, the following error message will be shown.
You can customize the error handling by specifying the error page in WEB-INF/zk.xml as described in ZK Configuration Reference. For example,
Then, when an error occurs in an event listener, the ZK Update Engine creates a dialog by use of the error page you specified, /error/error.zul.
Like error handling in loading a ZUML page, you can specify multiple <error-page> elements. Each of them is associated with a different exception type
(the value of <exception-type> element). When an error occurs, ZK will search the error pages one-by-one until the exception type matches.
In addition, ZK passes a set of request attributes to the error page to describe what happens. These attribute are as follows.
For example, you can specify the following content as the error page.
books.zkoss.org/wiki/…/Error_Handling 2/3
2011/3/7 ZK - ZK Developer's Reference/UI Patter…
Tips:
The error page is created at the same desktop that causes the error, so you can retrieve the relevant information from the desktop.
Version History
Last Update : 2010/12/7
Copyright © Potix Corporation. This article is licensed under GNU Free Documentation License. (http://www.gnu.org/copyleft/fdl.html)
Page |
Discussion |
View source |
History
Disclaimers |
Modified by ZK
books.zkoss.org/wiki/…/Error_Handling 3/3