Interface ViewEngine
-
public interface ViewEngineView engines are responsible for processing views and are discovered using Jakarta Contexts and Dependency Injection. Implementations must look up all instances of this interface, and process a view as follows:
- Gather the set of candidate view engines by calling
supports(String)and discarding engines that returnfalse. - Sort the resulting set of candidates using priorities. View engines
can be decorated with
Priorityto indicate their priority; otherwise the priority is assumed to bePRIORITY_APPLICATION. - If more than one candidate is available, choose one in an implementation-defined manner.
- Fire a
BeforeProcessViewEventevent. - Call method
processView(ViewEngineContext)to process view. - Fire a
AfterProcessViewEventevent.
The default view engines for Jakarta Server Pages and Facelets use file extensions to determine support. Namely, the default Jakarta Server Pages view engine supports views with extensions
jspandjspx, and the one for Facelets supports views with extensionxhtml.- Since:
- 1.0
- Author:
- Santiago Pericas-Geertsen, Ivar Grimstad
- See Also:
Priority,BeforeProcessViewEvent
- Gather the set of candidate view engines by calling
-
-
Field Summary
Fields Modifier and Type Field Description static StringDEFAULT_VIEW_FOLDERDefault value for propertyVIEW_FOLDER.static intPRIORITY_APPLICATIONRecommended priority for all application-provided view engines (default).static intPRIORITY_BUILTINPriority for all built-in view engines.static intPRIORITY_FRAMEWORKRecommended priority for all view engines provided by frameworks built on top of MVC implementations.static StringVIEW_FOLDERName of property that can be set to override the root location for views in an archive.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidprocessView(ViewEngineContext context)Process a view given aViewEngineContext.booleansupports(String view)Returnstrueif this engine can process the view orfalseotherwise.
-
-
-
Field Detail
-
VIEW_FOLDER
static final String VIEW_FOLDER
Name of property that can be set to override the root location for views in an archive.- See Also:
Application.getProperties(), Constant Field Values
-
DEFAULT_VIEW_FOLDER
static final String DEFAULT_VIEW_FOLDER
Default value for propertyVIEW_FOLDER.- See Also:
- Constant Field Values
-
PRIORITY_BUILTIN
static final int PRIORITY_BUILTIN
Priority for all built-in view engines.- See Also:
- Constant Field Values
-
PRIORITY_FRAMEWORK
static final int PRIORITY_FRAMEWORK
Recommended priority for all view engines provided by frameworks built on top of MVC implementations.- See Also:
- Constant Field Values
-
PRIORITY_APPLICATION
static final int PRIORITY_APPLICATION
Recommended priority for all application-provided view engines (default).- See Also:
- Constant Field Values
-
-
Method Detail
-
supports
boolean supports(String view)
Returnstrueif this engine can process the view orfalseotherwise.- Parameters:
view- the view.- Returns:
- outcome of supports test.
-
processView
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 Jakarta 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.
- Parameters:
context- the context needed for processing.- Throws:
ViewEngineException- if an error occurs during processing.
-
-