Interface RenderingContext

All Known Implementing Classes:
RenderingContextImpl, ThreadSafeRenderingContext

public interface RenderingContext
A context used to deliver parameter to marshallers during a marshalling request.

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:

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
 }
 
Since:
7.2.
  • Field Details

  • Method Details

    • getLocale

      Locale getLocale()
      Gets the requested Locale.
      Since:
      7.2
    • getBaseUrl

      String getBaseUrl()
      Gets the current base url.
      Since:
      7.2
    • getSession

      Gets the current CoreSession or try to create one.
      Parameters:
      document - may be null, if present, this method search for a session in the document.
      Returns:
      The current CoreSession if it exists. null otherwise.
      Throws:
      MarshallingException - if no session could be created or found.
      Since:
      7.2
    • setExistingSession

      void setExistingSession(CoreSession session)
      Provides a CoreSession to marshallers.

      For example: a CoreSession from the request context.

      Parameters:
      session - The existing CoreSession which lifecycle is managed outside the marshalling context.
      Since:
      7.2
    • getProperties

      Set<String> getProperties()
      Get all document properties. This will aggregate all values from parameters "properties", "X-NXproperties" and "X-NXDocumentProperties". This supports value separated by comma.
      Returns:
      All document properties.
      Since:
      7.2
    • getFetched

      Set<String> getFetched(String entity)
      Get all properties to fetch for a given entity type. This will aggregate all values from parameters "fetch.entity" and "X-NXfetch.entity". This supports value separated by comma.
      Parameters:
      entity - The type of the entity on which you want to fetch properties.
      Returns:
      All properties to fetch.
      Since:
      7.2
    • getTranslated

      Set<String> getTranslated(String entity)
      Get all properties to translate for a given entity type. This will aggregate all values from parameters "translate.entity" and "X-NXtranslate.entity". This supports value separated by comma.
      Parameters:
      entity - The type of the entity on which you want to fetch properties.
      Returns:
      All properties to fetch.
      Since:
      7.2
    • getEnrichers

      Set<String> getEnrichers(String entity)
      Get all enrichers to activate on the given entity type. This will aggregate all values from parameters "enrichers.entity", "X-NXenrichers.entity" and "X-NXContext-Category". This supports value separated by comma.
      Parameters:
      entity - The type of the entity on which you want to activate enrichers.
      Returns:
      All enrichers to activate.
      Since:
      7.2
    • wrap

      Returns:
      A new WrappedContext
      Since:
      7.2
    • getParameter

      <T> T getParameter(String name)
      Get the casted parameter value for a given name. If multiple are available, the first found is returned.
      Parameters:
      name - The parameter name.
      Returns:
      The first parameter value, null if no parameter are availble.
      Since:
      7.2
    • getBooleanParameter

      boolean getBooleanParameter(String name)
      Returns:
      true is the parameter exists and if it's Boolean.TRUE or "true", false otherwise.
    • getParameters

      <T> List<T> getParameters(String name)
      Get the casted parameter values for a given name.
      Parameters:
      name - The parameter name.
      Returns:
      The parameter values.
      Since:
      7.2
    • getAllParameters

      Map<String,List<Object>> getAllParameters()
      Get all parameter in this context except wrapped parameters.
      Returns:
      All parameter's names and their values.
      Since:
      7.2
    • setParameterValues

      void setParameterValues(String name, Object... values)
      Since:
      7.2
      See Also:
    • setParameterListValues

      void setParameterListValues(String name, List<Object> values)
      Push values in the context with a given name. Please note that this method remove any value for the given name.
      Parameters:
      name - The parameter name.
      values - The parameter values.
      Since:
      7.2
    • addParameterValues

      void addParameterValues(String name, Object... values)
      Since:
      7.2
      See Also:
    • addParameterListValues

      void addParameterListValues(String name, List<?> values)
      Add values in the context with a given name. Please note that this method keep current values for the given name.
      Parameters:
      name - The parameter name.
      values - The parameter values.
      Since:
      7.2