Package jakarta.mvc.engine
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
- Author:
- Santiago Pericas-Geertsen, Christian Kaltepoth, Ivar Grimstad
- See Also:
ViewEngine
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description jakarta.ws.rs.core.Configuration
getConfiguration()
Returns the application's configuration.Locale
getLocale()
Returns the request locale resolved for the current request.jakarta.ws.rs.core.MediaType
getMediaType()
The media type to use for the response.Models
getModels()
Returns the models instance needed to process the view.OutputStream
getOutputStream()
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
getResourceInfo()
Returns theResourceInfo
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>
getResponseHeaders()
Get the mutable response headers multivalued map.jakarta.ws.rs.core.UriInfo
getUriInfo()
Returns theUriInfo
instance containing information about the current request URI.String
getView()
Returns the view.
-
-
-
Method Detail
-
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 theHttpServletRequest
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()
andgetResponseHeaders()
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 fromgetOutputStream()
.- 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 thatViewEngine
implementations should respect the charset parameter of the media type when writing data to the output stream obtained fromgetOutputStream()
.- Returns:
- The media type
-
getUriInfo
jakarta.ws.rs.core.UriInfo getUriInfo()
Returns theUriInfo
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 theResourceInfo
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 asViewEngine.VIEW_FOLDER
, which view engines must use to locate views.- Returns:
- application's configuration.
- See Also:
Configuration
-
-