public interface ViewEngine
View engines are responsible for processing views and are discovered using CDI. Implementations must look up all instances of this interface, and process a view as follows:
supports(String)
and discarding engines that return false
.Priority
to indicate
their priority; otherwise the priority is assumed to be PRIORITY_APPLICATION
.BeforeProcessViewEvent
event.processView(ViewEngineContext)
to process view.AfterProcessViewEvent
event.The default view engines for JSPs and Facelets use file extensions to determine
support. Namely, the default JSP view engine supports views with extensions jsp
and jspx
, and the one for Facelets supports views with extension
xhtml
.
Priority
,
BeforeProcessViewEvent
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_VIEW_FOLDER
Default value for property
VIEW_FOLDER . |
static int |
PRIORITY_APPLICATION
Recommended priority for all application-provided view engines (default).
|
static int |
PRIORITY_BUILTIN
Priority for all built-in view engines.
|
static int |
PRIORITY_FRAMEWORK
Recommended priority for all view engines provided by frameworks built
on top of MVC implementations.
|
static String |
VIEW_FOLDER
Name of property that can be set to override the root location for views in an archive.
|
Modifier and Type | Method and Description |
---|---|
void |
processView(ViewEngineContext context)
Process a view given a
ViewEngineContext . |
boolean |
supports(String view)
Returns
true if this engine can process the view or false
otherwise. |
static final String VIEW_FOLDER
Application.getProperties()
,
Constant Field Valuesstatic final String DEFAULT_VIEW_FOLDER
VIEW_FOLDER
.static final int PRIORITY_BUILTIN
static final int PRIORITY_FRAMEWORK
static final int PRIORITY_APPLICATION
boolean supports(String view)
true
if this engine can process the view or false
otherwise.view
- the view.void processView(ViewEngineContext context) throws ViewEngineException
Process a view given a ViewEngineContext
. Processing
a view involves merging the model and template data and writing
the result to an output stream.
Following the Java EE threading model, the underlying view engine implementation must support this method being called by different threads. Any resources allocated during view processing must be released before the method returns.
context
- the context needed for processing.ViewEngineException
- if an error occurs during processing.Copyright © 2019 Ivar Grimstad. All rights reserved.