Module jakarta.mvc

Interface ViewEngineContext


public interface ViewEngineContext

Contextual data used by a ViewEngine to process a view. This includes the view name, the models instance and the request and response objects from the container, among other data.

Since:
1.0
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    jakarta.ws.rs.core.Configuration
    Returns the application's configuration.
    Returns the request locale resolved for the current request.
    jakarta.ws.rs.core.MediaType
    The media type to use for the response.
    Returns the models instance needed to process the view.
    The output stream which should be used to write the result of processing a view.
    <T> T
    getRequest(Class<T> type)
    Returns the HTTP request object from the container.
    jakarta.ws.rs.container.ResourceInfo
    Returns the ResourceInfo instance containing information about the controller method matched in the current request.
    <T> T
    getResponse(Class<T> type)
    Returns the HTTP response object from the container.
    jakarta.ws.rs.core.MultivaluedMap<String,Object>
    Get the mutable response headers multivalued map.
    jakarta.ws.rs.core.UriInfo
    Returns the UriInfo instance containing information about the current request URI.
    Returns the view.
  • Method Details

    • getView

      String getView()
      Returns the view.
      Returns:
      the view.
    • getModels

      Models getModels()
      Returns the models instance needed to process the view.
      Returns:
      the models instance.
    • getLocale

      Locale getLocale()
      Returns the request locale resolved for the current request.
      Returns:
      the request locale
    • getRequest

      <T> T getRequest(Class<T> type)
      Returns the HTTP request object from the container. The type of the request object depends on the environment. In a servlet environment you can use this method to get the HttpServletRequest object.
      Type Parameters:
      T - The expected type of the HTTP request object
      Parameters:
      type - The expected type of the HTTP request object.
      Returns:
      HTTP request object.
    • getResponse

      <T> T getResponse(Class<T> type)

      Returns the HTTP response object from the container. The type of the response object depends on the environment. In a servlet environment you can use this method to get the HttpServletResponse object.

      Please note that you should generally prefer using getOutputStream() and getResponseHeaders() to write the result of processing the view, because these methods are guaranteed to work in all supported environments.

      Type Parameters:
      T - The expected type of the HTTP request object
      Parameters:
      type - The expected type of the HTTP response object.
      Returns:
      HTTP response object.
    • getResponseHeaders

      jakarta.ws.rs.core.MultivaluedMap<String,Object> getResponseHeaders()
      Get the mutable response headers multivalued map. This map can be modified to change the HTTP response headers. Please note that changing the map will only have an effect on the headers if modifications are performed before data is written to the output stream obtained from getOutputStream().
      Returns:
      mutable multivalued map of response headers.
    • getOutputStream

      OutputStream getOutputStream()
      The output stream which should be used to write the result of processing a view.
      Returns:
      The output stream
    • getMediaType

      jakarta.ws.rs.core.MediaType getMediaType()
      The media type to use for the response. Please note that ViewEngine implementations should respect the charset parameter of the media type when writing data to the output stream obtained from getOutputStream().
      Returns:
      The media type
    • getUriInfo

      jakarta.ws.rs.core.UriInfo getUriInfo()
      Returns the UriInfo instance containing information about the current request URI.
      Returns:
      the URI info for the current request.
      See Also:
      • UriInfo
    • getResourceInfo

      jakarta.ws.rs.container.ResourceInfo getResourceInfo()
      Returns the ResourceInfo instance containing information about the controller method matched in the current request.
      Returns:
      the resource info for the current request.
      See Also:
      • ResourceInfo
    • getConfiguration

      jakarta.ws.rs.core.Configuration getConfiguration()
      Returns the application's configuration. The configuration provides access to properties such as ViewEngine.VIEW_FOLDER, which view engines must use to locate views.
      Returns:
      application's configuration.
      See Also:
      • Configuration