Top Description Fields Methods
javax.mvc.engine

public Interface ViewEngine

Annotations
@SuppressWarnings:unused

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:

  1. Gather the set of candidate view engines by calling supports(String) and discarding engines that return false.
  2. Sort the resulting set of candidates using priorities. View engines can be decorated with javax.annotation.Priority to indicate their priority; otherwise the priority is assumed to be ViewEngine#PRIORITY_APPLICATION.
  3. If more than one candidate is available, choose one in an implementation-defined manner.
  4. Fire a javax.mvc.event.BeforeProcessViewEvent event.
  5. Call method processView(ViewEngineContext) to process view.
  6. Fire a javax.mvc.event.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.

Author
Santiago Pericas-Geertsen
Since
1.0
See Also
javax.annotation.Priority, javax.mvc.event.BeforeProcessViewEvent

Field Summary

Modifier and TypeField and Description
public static final String
DEFAULT_VIEW_FOLDER

Default value for property VIEW_FOLDER.

public static final int
PRIORITY_APPLICATION

Recommended priority for all application-provided view engines (default).

public static final int
PRIORITY_BUILTIN

Priority for all built-in view engines.

public static final int
PRIORITY_FRAMEWORK

Recommended priority for all view engines provided by frameworks built on top of MVC implementations.

public static final String
VIEW_FOLDER

Name of property that can be set to override the root location for views in an archive.

Method Summary

Modifier and TypeMethod and Description
public void
processView(ViewEngineContext
the context needed for processing.
context
)

Process a view given a javax.mvc.engine.ViewEngineContext.

public boolean

Returns:

outcome of supports test.
supports
(String
the view.
view
)

Returns true if this engine can process the view or false otherwise.

Field Detail

DEFAULT_VIEW_FOLDERback to summary
public static final String DEFAULT_VIEW_FOLDER

Default value for property VIEW_FOLDER.

PRIORITY_APPLICATIONback to summary
public static final int PRIORITY_APPLICATION

Recommended priority for all application-provided view engines (default).

PRIORITY_BUILTINback to summary
public static final int PRIORITY_BUILTIN

Priority for all built-in view engines.

PRIORITY_FRAMEWORKback to summary
public static final int PRIORITY_FRAMEWORK

Recommended priority for all view engines provided by frameworks built on top of MVC implementations.

VIEW_FOLDERback to summary
public static final String VIEW_FOLDER

Name of property that can be set to override the root location for views in an archive.

See Also
javax.ws.rs.core.Application#getProperties()

Method Detail

processViewback to summary
public void processView(ViewEngineContext context) throws ViewEngineException

Process a view given a javax.mvc.engine.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.

Parameters
context:ViewEngineContext

the context needed for processing.

Exceptions
ViewEngineException:
if an error occurs during processing.
supportsback to summary
public boolean supports(String view)

Returns true if this engine can process the view or false otherwise.

Parameters
view:String

the view.

Returns:boolean

outcome of supports test.