Class IncludeNotFound
- java.lang.Object
-
- org.apache.velocity.app.event.implement.IncludeNotFound
-
- All Implemented Interfaces:
EventHandler
,IncludeEventHandler
,ContextAware
,RuntimeServicesAware
public class IncludeNotFound extends java.lang.Object implements IncludeEventHandler, RuntimeServicesAware, ContextAware
Simple event handler that checks to see if an included page is available. If not, it includes a designated replacement page instead.By default, the name of the replacement page is "notfound.vm", however this page name can be changed by setting the Velocity property
eventhandler.include.notfound
, for example:eventhandler.include.notfound = error.vm
The name of the missing resource is put into the Velocity context, under the key "missingResource", so that the "notfound" template can report the missing resource with a Velocity reference, like:
$missingResource
- Since:
- 1.5
- Version:
- $Id: IncludeNotFound.java 809816 2009-09-01 05:14:27Z nbubna $
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.velocity.app.event.IncludeEventHandler
IncludeEventHandler.IncludeEventExecutor
-
-
Field Summary
Fields Modifier and Type Field Description (package private) Context
context
private static java.lang.String
DEFAULT_NOT_FOUND
(package private) java.lang.String
notfound
private static java.lang.String
PROPERTY_NOT_FOUND
private RuntimeServices
rs
-
Constructor Summary
Constructors Constructor Description IncludeNotFound()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
includeEvent(java.lang.String includeResourcePath, java.lang.String currentResourcePath, java.lang.String directiveName)
Chseck to see if included file exists, and display "not found" page if it doesn't.void
setContext(Context context)
Initialize the EventHandler.void
setRuntimeServices(RuntimeServices rs)
Called automatically when event cartridge is initialized.
-
-
-
Field Detail
-
DEFAULT_NOT_FOUND
private static final java.lang.String DEFAULT_NOT_FOUND
- See Also:
- Constant Field Values
-
PROPERTY_NOT_FOUND
private static final java.lang.String PROPERTY_NOT_FOUND
- See Also:
- Constant Field Values
-
rs
private RuntimeServices rs
-
notfound
java.lang.String notfound
-
context
Context context
-
-
Method Detail
-
includeEvent
public java.lang.String includeEvent(java.lang.String includeResourcePath, java.lang.String currentResourcePath, java.lang.String directiveName)
Chseck to see if included file exists, and display "not found" page if it doesn't. If "not found" page does not exist, log an error and return null.- Specified by:
includeEvent
in interfaceIncludeEventHandler
- Parameters:
includeResourcePath
-currentResourcePath
-directiveName
-- Returns:
- message.
-
setRuntimeServices
public void setRuntimeServices(RuntimeServices rs)
Description copied from interface:RuntimeServicesAware
Called automatically when event cartridge is initialized.- Specified by:
setRuntimeServices
in interfaceRuntimeServicesAware
- Parameters:
rs
- RuntimeServices object assigned during initialization- See Also:
RuntimeServicesAware.setRuntimeServices(org.apache.velocity.runtime.RuntimeServices)
-
setContext
public void setContext(Context context)
Description copied from interface:ContextAware
Initialize the EventHandler.- Specified by:
setContext
in interfaceContextAware
- See Also:
ContextAware.setContext(org.apache.velocity.context.Context)
-
-