|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.click.Page net.sf.click.util.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 occured:package com.mycorp.util; import java.sql.Connection; import java.sql.SQLException; import net.sf.click.util.ErrorPage; public class MyCorpErrorPage extends ErrorPage { /** * @see Page#onDestroy() * / public void onDestroy() { Exception errror = 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 |
pageClass
The page class in error. |
Fields inherited from class net.sf.click.Page |
controls, format, forward, headers, headersEdited, messages, model, 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 |
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 pageClass)
Set the page class in error. |
Methods inherited from class net.sf.click.Page |
addControl, addModel, getContentType, getContext, getControls, getFormat, getForward, getHeaders, getHtmlImports, getMessage, getMessage, getMessage, getMessages, getModel, getPageImports, getPath, getRedirect, getTemplate, hasControls, isStateful, onDestroy, onGet, onPost, onRender, onSecurityCheck, removeControl, setFormat, setForward, setForward, setForward, setHeader, setHeaders, setPageImports, setPath, 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 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 getPageClass()
public void setPageClass(Class pageClass)
pageClass
- the page class in error
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |