MessageSource to
use, current locale, binding errors, etc. Provides easy access to localized
messages and Errors instances.
Suitable for exposition to views, and usage within FreeMarker templates and tag libraries.
Can be instantiated manually or automatically exposed to views as a model attribute via AbstractView's "requestContextAttribute" property.
| Modifier and Type | Field and Description |
|---|---|
| private final RequestDataValueProcessor | |
| private Boolean | |
| private Map | |
| private final ServerWebExchange | |
| private Locale | |
| private final MessageSource | |
| private final Map | |
| private TimeZone |
| Access | Constructor and Description |
|---|---|
| public | |
| public | RequestContext(ServerWebExchange exchange, Map<String, Object> model, MessageSource messageSource, RequestDataValueProcessor dataValueProcessor)
|
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| public void | changeLocale(Locale locale, TimeZone timeZone)
Change the current locale to the specified locale and time zone context. |
| public BindStatus | Returns: the new BindStatus instancethe bean and property path for which values and errors will
be resolved (e.g. "person.age") path)Create a BindStatus for the given bind object using the "defaultHtmlEscape" setting. |
| public BindStatus | Returns: the new BindStatus instancethe bean and property path for which values and errors will
be resolved (e.g. "person.age") path, boolean create a BindStatus with automatic HTML escaping? htmlEscape)Create a BindStatus for the given bind object, using the "defaultHtmlEscape" setting. |
| public String | |
| public String | Returns: a URL that points back to the current web application with an absolute path also URL-encoded accordinglythe relative URL part relativeUrl)Return a context-aware URl for the given relative URL. |
| public String | Returns: a URL that points back to the current web application with an absolute path also URL-encoded accordinglythe relative URL part relativeUrl, Map<String, ?> a map of parameters to insert as placeholders in the url params)Return a context-aware URl for the given relative URL with placeholders --
named keys with braces |
| public Boolean | Returns: whether default HTML escaping is enabled (null = no explicit default)Return the default HTML escape setting, differentiating between no default specified and an explicit value. |
| public Errors | |
| public Errors | |
| protected final ServerWebExchange | |
| public final Locale | |
| public String | Returns: the messagethe code of the message code, String the String to return if the lookup fails defaultMessage)Retrieve the message for the given code, using the "defaultHtmlEscape" setting. |
| public String | Returns: the messagethe code of the message code, Object[] arguments for the message, or args, String null if nonethe String to return if the lookup fails defaultMessage)Retrieve the message for the given code, using the "defaultHtmlEscape" setting. |
| public String | Returns: the messagethe code of the message code, List<?> arguments for the message as a List, or args, String null if nonethe String to return if the lookup fails defaultMessage)Retrieve the message for the given code, using the "defaultHtmlEscape" setting. |
| public String | Returns: the messagethe code of the message code, Object[] arguments for the message, or args, String null if nonethe String to return if the lookup fails defaultMessage, boolean if the message should be HTML-escaped htmlEscape)Retrieve the message for the given code. |
| public String | Returns: the messagethe code of the message code)Retrieve the message for the given code, using the "defaultHtmlEscape" setting. |
| public String | Returns: the messagethe code of the message code, Object[] arguments for the message, or args)null if noneRetrieve the message for the given code, using the "defaultHtmlEscape" setting. |
| public String | Returns: the messagethe code of the message code, List<?> arguments for the message as a List, or args)null if noneRetrieve the message for the given code, using the "defaultHtmlEscape" setting. |
| public String | Returns: the messagethe code of the message code, Object[] arguments for the message, or args, boolean null if noneif the message should be HTML-escaped htmlEscape)Retrieve the message for the given code. |
| public String | Returns: the messagethe MessageSourceResolvable resolvable)Retrieve the given MessageSourceResolvable (e.g. an ObjectError instance), using the "defaultHtmlEscape" setting. |
| public String | Returns: the messagethe MessageSourceResolvable resolvable, boolean if the message should be HTML-escaped htmlEscape)Retrieve the given MessageSourceResolvable (e.g. an ObjectError instance). |
| public MessageSource | |
| public Map | Returns: the populated model Map, ornull if none availableReturn the model Map that this RequestContext encapsulates, if any. |
| protected <T> T | Returns: the model objectthe name of the model object modelName)Retrieve the model object for the given model name, either from the model or from the request attributes. |
| public String | |
| public RequestDataValueProcessor | getRequestDataValueProcessor()
Return the |
| public String | |
| public TimeZone | |
| public boolean | |
| public void | setDefaultHtmlEscape(boolean defaultHtmlEscape)
(De)activate default HTML escaping for messages and errors, for the scope of this RequestContext. |
| dataValueProcessor | back to summary |
|---|---|
| private final RequestDataValueProcessor dataValueProcessor
| |
| defaultHtmlEscape | back to summary |
|---|---|
| private Boolean defaultHtmlEscape
| |
| errorsMap | back to summary |
|---|---|
| private Map<String, Errors> errorsMap
| |
| exchange | back to summary |
|---|---|
| private final ServerWebExchange exchange | |
| locale | back to summary |
|---|---|
| private Locale locale | |
| messageSource | back to summary |
|---|---|
| private final MessageSource messageSource | |
| model | back to summary |
|---|---|
| private final Map<String, Object> model | |
| timeZone | back to summary |
|---|---|
| private TimeZone timeZone | |
| RequestContext | back to summary |
|---|---|
| public RequestContext(ServerWebExchange exchange, Map<String, Object> model, MessageSource messageSource) | |
| RequestContext | back to summary |
|---|---|
| public RequestContext(ServerWebExchange exchange, Map<String, Object> model, MessageSource messageSource, RequestDataValueProcessor dataValueProcessor) | |
| changeLocale | back to summary |
|---|---|
| public void changeLocale(Locale locale) Change the current locale to the specified one. | |
| changeLocale | back to summary |
|---|---|
| public void changeLocale(Locale locale, TimeZone timeZone) Change the current locale to the specified locale and time zone context. | |
| getBindStatus | back to summary |
|---|---|
| public BindStatus getBindStatus(String path) throws IllegalStateException Create a BindStatus for the given bind object using the "defaultHtmlEscape" setting.
| |
| getBindStatus | back to summary |
|---|---|
| public BindStatus getBindStatus(String path, boolean htmlEscape) throws IllegalStateException Create a BindStatus for the given bind object, using the "defaultHtmlEscape" setting.
| |
| getContextPath | back to summary |
|---|---|
| public String getContextPath() Return the context path of the current web application. This is useful for building links to other resources within the application. Delegates to | |
| getContextUrl | back to summary |
|---|---|
| public String getContextUrl(String relativeUrl) Return a context-aware URl for the given relative URL. | |
| getContextUrl | back to summary |
|---|---|
| public String getContextUrl(String relativeUrl, Map<String, ?> params) Return a context-aware URl for the given relative URL with placeholders --
named keys with braces | |
| getDefaultHtmlEscape | back to summary |
|---|---|
| public Boolean getDefaultHtmlEscape() Return the default HTML escape setting, differentiating between no default specified and an explicit value. | |
| getErrors | back to summary |
|---|---|
| public Errors getErrors(String name) Retrieve the Errors instance for the given bind object, using the "defaultHtmlEscape" setting. | |
| getErrors | back to summary |
|---|---|
| public Errors getErrors(String name, boolean htmlEscape) Retrieve the Errors instance for the given bind object. | |
| getExchange | back to summary |
|---|---|
| protected final ServerWebExchange getExchange() | |
| getLocale | back to summary |
|---|---|
| public final Locale getLocale() Return the current Locale. | |
| getMessage | back to summary |
|---|---|
| public String getMessage(String code, String defaultMessage) Retrieve the message for the given code, using the "defaultHtmlEscape" setting. | |
| getMessage | back to summary |
|---|---|
| public String getMessage(String code, Object[] args, String defaultMessage) Retrieve the message for the given code, using the "defaultHtmlEscape" setting. | |
| getMessage | back to summary |
|---|---|
| public String getMessage(String code, List<?> args, String defaultMessage) Retrieve the message for the given code, using the "defaultHtmlEscape" setting. | |
| getMessage | back to summary |
|---|---|
| public String getMessage(String code, Object[] args, String defaultMessage, boolean htmlEscape) Retrieve the message for the given code. | |
| getMessage | back to summary |
|---|---|
| public String getMessage(String code) throws NoSuchMessageException Retrieve the message for the given code, using the "defaultHtmlEscape" setting.
| |
| getMessage | back to summary |
|---|---|
| public String getMessage(String code, Object[] args) throws NoSuchMessageException Retrieve the message for the given code, using the "defaultHtmlEscape" setting.
| |
| getMessage | back to summary |
|---|---|
| public String getMessage(String code, List<?> args) throws NoSuchMessageException Retrieve the message for the given code, using the "defaultHtmlEscape" setting.
| |
| getMessage | back to summary |
|---|---|
| public String getMessage(String code, Object[] args, boolean htmlEscape) throws NoSuchMessageException Retrieve the message for the given code.
| |
| getMessage | back to summary |
|---|---|
| public String getMessage(MessageSourceResolvable resolvable) throws NoSuchMessageException Retrieve the given MessageSourceResolvable (e.g. an ObjectError instance), using the "defaultHtmlEscape" setting.
| |
| getMessage | back to summary |
|---|---|
| public String getMessage(MessageSourceResolvable resolvable, boolean htmlEscape) throws NoSuchMessageException Retrieve the given MessageSourceResolvable (e.g. an ObjectError instance).
| |
| getMessageSource | back to summary |
|---|---|
| public MessageSource getMessageSource() Return the MessageSource in use with this request. | |
| getModel | back to summary |
|---|---|
| public Map Return the model Map that this RequestContext encapsulates, if any. | |
| getModelObject | back to summary |
|---|---|
| protected <T> T getModelObject(String modelName) Retrieve the model object for the given model name, either from the model or from the request attributes.
| |
| getQueryString | back to summary |
|---|---|
| public String getQueryString() Return the query string of the current request. This is useful for building an HTML form action target in combination with the original request path. | |
| getRequestDataValueProcessor | back to summary |
|---|---|
| public RequestDataValueProcessor getRequestDataValueProcessor() Return the
| |
| getRequestPath | back to summary |
|---|---|
| public String getRequestPath() Return the request path of the request. This is useful as HTML form action target, also in combination with the original query string. | |
| getTimeZone | back to summary |
|---|---|
| public TimeZone getTimeZone() Return the current TimeZone. | |
| isDefaultHtmlEscape | back to summary |
|---|---|
| public boolean isDefaultHtmlEscape() Is default HTML escaping active? Falls back to | |
| setDefaultHtmlEscape | back to summary |
|---|---|
| public void setDefaultHtmlEscape(boolean defaultHtmlEscape) (De)activate default HTML escaping for messages and errors, for the scope of this RequestContext. Todo currently no application-wide setting ... | |