Top Description Fields Methods
jakarta.mvc.engine

public Interface ViewEngine

Annotations
@SuppressWarnings:unused

View 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:

  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 jakarta.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 jakarta.mvc.event.BeforeProcessViewEvent event.
  5. Call method processView(ViewEngineContext) to process view.
  6. Fire a jakarta.mvc.event.AfterProcessViewEvent event.

The default view engine for Jakarta Server Pages uses file extensions to determine support. Namely, the default Jakarta Server Pages view engine supports views with extensions jsp and jspx.

Authors
Santiago Pericas-Geertsen, Ivar Grimstad
Since
1.0
See Also
jakarta.annotation.Priority, jakarta.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_EXTENSION

The default view file extension that is used to fetch templates.

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 jakarta.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_EXTENSIONback to summary
public static final String VIEW_EXTENSION

The default view file extension that is used to fetch templates. For example, if this setting is set to .jsp, instead of returning index.jsp only index is required.

See Also
jakarta.ws.rs.core.Application#getProperties()
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
jakarta.ws.rs.core.Application#getProperties()

Method Detail

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

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