|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.click.Page org.apache.click.util.ErrorPage
public class ErrorPage
Provides the base error handling Page. The ErrorPage handles any unexpected Exceptions. When the application is not in "production" mode the ErrorPage will provide diagnostic information.
The ErrorPage template "click/error.htm" can be customized to your needs. Applications which require additional error handling logic must subclass the ErrorPage. For example to rollback a Connection if an SQLException occurred:package com.mycorp.util; import java.sql.Connection; import java.sql.SQLException; import org.apache.click.util.ErrorPage; public class MyCorpErrorPage extends ErrorPage { /** * @see Page#onDestroy() * / public void onDestroy() { Exception error = getError(); if (error instanceof SQLException || error.getCause() instanceof SQLException) { Connection connection = ConnectionProviderThreadLocal.getConnection(); if (connection != null) { try { connection.rollback(); } catch (SQLException sqle) { } finally { try { connection.close(); } catch (SQLException sqle) { } } } } } }The ClickServlet sets the following ErrorPage properties in addition to the normal Page properties:
error
- the error causing exceptionmode
- the Click application modepageClass
- the Page class which cause the error
Field Summary | |
---|---|
protected Throwable |
error
The error causing exception. |
protected String |
mode
The application mode: ["production", "profile", "development", "debug", "trace"]. |
protected static int |
NUMB_LINES
The number of lines to display. |
protected Class<? extends Page> |
pageClass
The page class in error. |
Fields inherited from class org.apache.click.Page |
---|
controls, format, forward, headElements, headers, includeControlHeadElements, messages, model, PAGE_ACTION, PAGE_MESSAGES, pageImports, path, redirect, stateful, template |
Constructor Summary | |
---|---|
ErrorPage()
|
Method Summary | |
---|---|
Throwable |
getError()
Return the causing error. |
String |
getMode()
Return the application mode: ["production", "profile", "development", debug", "trace"]. |
Class<? extends Page> |
getPageClass()
Return the page class in error. |
void |
onInit()
This method initializes the ErrorPage, populating the model with error diagnostic information. |
void |
setError(Throwable cause)
Set the causing error. |
void |
setMode(String value)
Set the application mode: ["production", "profile", "development", debug", "trace"] The application mode is added to the model by the onInit() method. |
void |
setPageClass(Class<? extends Page> pageClass)
Set the page class in error. |
Methods inherited from class org.apache.click.Page |
---|
addControl, addModel, getContentType, getContext, getControls, getFormat, getForward, getHeadElements, getHeaders, getHtmlImports, getMessage, getMessage, getMessages, getModel, getPageImports, getPath, getRedirect, getTemplate, hasControls, hasHeaders, isIncludeControlHeadElements, isStateful, onDestroy, onGet, onPost, onRender, onSecurityCheck, removeControl, setFormat, setForward, setForward, setForward, setHeader, setHeaders, setIncludeControlHeadElements, setPageImports, setPath, setRedirect, setRedirect, setRedirect, setRedirect, setStateful, setTemplate |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final int NUMB_LINES
protected Throwable error
protected String mode
protected Class<? extends Page> pageClass
Constructor Detail |
---|
public ErrorPage()
Method Detail |
---|
public void onInit()
onInit
in class Page
Page.onInit()
public Throwable getError()
public void setError(Throwable cause)
cause
- the causing errorpublic String getMode()
public void setMode(String value)
onInit()
method.
This property is used to determines whether the error page template
should display error diagnostic information. The default "error.htm" will
display error diagnostic information so long as the application mode is
not "production".
value
- the application mode.public Class<? extends Page> getPageClass()
public void setPageClass(Class<? extends Page> pageClass)
pageClass
- the page class in error
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |