Class ErrorPage
- java.lang.Object
-
- org.openidentityplatform.openam.click.Page
-
- org.openidentityplatform.openam.click.util.ErrorPage
-
- All Implemented Interfaces:
Serializable
public class ErrorPage extends org.openidentityplatform.openam.click.PageProvides 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:- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected ThrowableerrorThe error causing exception.protected StringmodeThe application mode: ["production", "profile", "development", "debug", "trace"].protected static intNUMB_LINESThe number of lines to display.protected Class<? extends org.openidentityplatform.openam.click.Page>pageClassThe page class in error.
-
Constructor Summary
Constructors Constructor Description ErrorPage()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ThrowablegetError()Return the causing error.StringgetMode()Return the application mode:["production", "profile", "development", debug", "trace"].Class<? extends org.openidentityplatform.openam.click.Page>getPageClass()Return the page class in error.voidonInit()This method initializes the ErrorPage, populating the model with error diagnostic information.voidsetError(Throwable cause)Set the causing error.voidsetMode(String value)Set the application mode:["production", "profile", "development", debug", "trace"]voidsetPageClass(Class<? extends org.openidentityplatform.openam.click.Page> pageClass)Set the page class in error.-
Methods inherited from class org.openidentityplatform.openam.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
-
-
-
-
Field Detail
-
NUMB_LINES
protected static final int NUMB_LINES
The number of lines to display.- See Also:
- Constant Field Values
-
error
protected Throwable error
The error causing exception.
-
mode
protected String mode
The application mode: ["production", "profile", "development", "debug", "trace"].
-
pageClass
protected Class<? extends org.openidentityplatform.openam.click.Page> pageClass
The page class in error.
-
-
Method Detail
-
onInit
public void onInit()
This method initializes the ErrorPage, populating the model with error diagnostic information.The following values are added to ErrorPage model for rendering by the error page template:
errorReport- the detailed error report <div> element, with an id of 'errorReport'mode- the application mode
- Overrides:
onInitin classorg.openidentityplatform.openam.click.Page- See Also:
Page.onInit()
-
getError
public Throwable getError()
Return the causing error.- Returns:
- the causing error
-
setError
public void setError(Throwable cause)
Set the causing error.- Parameters:
cause- the causing error
-
getMode
public String getMode()
Return the application mode:["production", "profile", "development", debug", "trace"].- Returns:
- the application mode
-
setMode
public 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. 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".- Parameters:
value- the application mode.
-
getPageClass
public Class<? extends org.openidentityplatform.openam.click.Page> getPageClass()
Return the page class in error.- Returns:
- the page class in error
-
setPageClass
public void setPageClass(Class<? extends org.openidentityplatform.openam.click.Page> pageClass)
Set the page class in error.- Parameters:
pageClass- the page class in error
-
-