public interface RenderingContext
Use RenderingContext.CtxBuilder
to create your context.
When a RenderingContext
is automatically provided from an HttpServletRequest, it contains request parameters,
headers and request attribute.
To get/set parameter values, use:
getParameter(String)
getParameters(String)
getBooleanParameter(String)
getAllParameters()
addParameterValues(String, Object...)
addParameterListValues(String, List)
setParameterValues(String, Object...)
setParameterListValues(String, List)
To manage document properties, entity enrichers or properties fetching, use:
To manage infinite loop when calling a marshaller from another marshaller, use:
Example:// This will control infinite loop in this marshaller try (Closeable resource = ctx.wrap().controlDepth().open()) { // call another marshaller to fetch the desired property here } catch (MaxDepthReachedException mdre) { // do not call the other marshaller }
Modifier and Type | Interface and Description |
---|---|
static class |
RenderingContext.CtxBuilder
RenderingContext builder. |
static class |
RenderingContext.SessionWrapper
Session wrapper that manage the closing of new created session and preserve request scoped or document scoped
session.
|
Modifier and Type | Field and Description |
---|---|
static Locale |
DEFAULT_LOCALE |
static String |
DEFAULT_URL |
static String |
RESPONSE_HEADER_ENTITY_TYPE_KEY |
Modifier and Type | Method and Description |
---|---|
void |
addParameterListValues(String name,
List<Object> values)
Add values in the context with a given name.
|
void |
addParameterValues(String name,
Object... values) |
Map<String,List<Object>> |
getAllParameters()
Get all parameter in this context except wrapped parameters.
|
String |
getBaseUrl()
Gets the current base url.
|
boolean |
getBooleanParameter(String name)
|
Set<String> |
getEnrichers(String entity)
Get all enrichers to activate on the given entity type.
|
Set<String> |
getFetched(String entity)
Get all properties to fetch for a given entity type.
|
Locale |
getLocale()
Gets the requested
Locale . |
<T> T |
getParameter(String name)
Get the casted parameter value for a given name.
|
<T> List<T> |
getParameters(String name)
Get the casted parameter values for a given name.
|
Set<String> |
getProperties()
Get all document properties.
|
RenderingContext.SessionWrapper |
getSession(DocumentModel document)
Gets the current
CoreSession or try to create one. |
Set<String> |
getTranslated(String entity)
Get all properties to translate for a given entity type.
|
void |
setExistingSession(CoreSession session)
Provides a
CoreSession to marshallers. |
void |
setParameterListValues(String name,
List<Object> values)
Push values in the context with a given name.
|
void |
setParameterValues(String name,
Object... values) |
WrappedContext |
wrap()
see
WrappedContext |
static final Locale DEFAULT_LOCALE
static final String DEFAULT_URL
static final String RESPONSE_HEADER_ENTITY_TYPE_KEY
String getBaseUrl()
RenderingContext.SessionWrapper getSession(DocumentModel document) throws MarshallingException
CoreSession
or try to create one.document
- may be null, if present, this method search for a session in the document.CoreSession
if it exists. null otherwise.MarshallingException
- if no session could be created or found.void setExistingSession(CoreSession session)
CoreSession
to marshallers.
For example: a CoreSession
from the request context.
session
- The existing CoreSession
which lifecycle is managed outside the marshalling context.Set<String> getProperties()
Set<String> getFetched(String entity)
entity
- The type of the entity on which you want to fetch properties.Set<String> getTranslated(String entity)
entity
- The type of the entity on which you want to fetch properties.Set<String> getEnrichers(String entity)
entity
- The type of the entity on which you want to activate enrichers.WrappedContext wrap()
WrappedContext
WrappedContext
<T> T getParameter(String name)
name
- The parameter name.boolean getBooleanParameter(String name)
<T> List<T> getParameters(String name)
name
- The parameter name.Map<String,List<Object>> getAllParameters()
void setParameterValues(String name, Object... values)
setParameterListValues(String, List)
void setParameterListValues(String name, List<Object> values)
name
- The parameter name.values
- The parameter values.void addParameterValues(String name, Object... values)
addParameterListValues(String, List)
void addParameterListValues(String name, List<Object> values)
name
- The parameter name.values
- The parameter values.Copyright © 2017 Nuxeo. All rights reserved.