Class BlockContext


  • public class BlockContext
    extends java.lang.Object
    This class holds context information used for any Block interactions. This includes a reference to a Renderer that is used to render a Block tree as well as default assignment modes. It is also used to hold data structures that are used by BlockPropertyMacro instances.

    Resolution of the Renderer. If a specific object instance is supplied for the renderer, it is used directly. If not supplied, then renderer to use is based on the evaluation of several properties of this object. Here is the order that BlockContext properties are evaluated in selecting the renderer.

    1. Renderer Instance. If one has been supplied (or computed in a previous invocation) it is used.
    2. Renderer FQCN. If a fully qualified class name is supplied it is used to create an instance of the renderer by reflection.

    Since:
    MicroStrategy Web 9.0.0
    See Also:
    ContentTypes
    • Constructor Detail

      • BlockContext

        public BlockContext()
        No args constructor.
      • BlockContext

        public BlockContext​(BeanContext beanContext)
        Constructor which takes a BeanContext instance. It retrieves values from the supplied BeanContext object to associate with this context. They include:
        • Request Keys
        • Container Services
        • Messages
        Parameters:
        beanContext - An existing BeanContext object.
      • BlockContext

        public BlockContext​(WebBean webBean)
        Constructor which takes a WebBean instance. In addition to retrieving context from the WebBean's BeanContext, it also tries to retrieve the following value:
        • WebIServerSession
        Parameters:
        webBean - An existing WebBean object.
        See Also:
        BlockContext(BeanContext)
    • Method Detail

      • getMessages

        public Messages getMessages()
        Returns the Messages to be used with Blocks.
        Returns:
        The Messages instance.
      • setMessages

        public void setMessages​(Messages messages)
        Sets the Messages to be used with Blocks.
        Parameters:
        messages - The Messages instance.
      • getContainerServices

        public ContainerServices getContainerServices()
        Returns the ContainerServices instance to use for any macro expansion.
        Returns:
        The ContainerServices instance to use for any macro expansion.
      • setContainerServices

        public void setContainerServices​(ContainerServices cs)
        Sets the ContainerServices instance to use for any macro expansion.
        Parameters:
        cs - The ContainerServices instance to use for any macro expansion.
      • getRenderer

        public Renderer getRenderer()
        Returns the Renderer instance to use with Blocks. It returns the instance specified with setRenderer(Renderer) or an instance which can be created from one of the other properties set in this context object
        Returns:
        The Renderer instance to use.
      • setRenderer

        public void setRenderer​(Renderer renderer)
        Sets the Renderer instance to use with Blocks.
        Parameters:
        renderer - The Renderer instance to use.
      • getRendererFQCN

        public java.lang.String getRendererFQCN()
        Returns the Renderer fully qualified class name to use with Blocks.
        Returns:
        The Renderer fully qualified class name to use with Blocks.
      • setRendererFQCN

        public void setRendererFQCN​(java.lang.String fqcn)
        Sets the Renderer fully qualified class name to use with Blocks.
        Parameters:
        fqcn - The fully qualified class name of the Renderer instance to use.
      • getMode

        public java.lang.String getMode()
        Returns the default mode to use for any Block creations.
        Returns:
        The default mode to use for any Block creations.
      • setMode

        public void setMode​(java.lang.String mode)
        Sets the default mode to use for any Block creations.
        Parameters:
        mode - The default mode to use for any Block creations.
      • getUnconditionalContentType

        public java.lang.String getUnconditionalContentType()
        Returns the unconditional content type to use for determining the renderer to use.
        Returns:
        The unconditional content type to use for determining the renderer to use.
      • setUnconditionalContentType

        public void setUnconditionalContentType​(java.lang.String unconditionalContentType)
        Sets the unconditional content type to use for determining the renderer to use.
        Parameters:
        unconditionalContentType - The content type to use for selecting the renderer
      • getDefaultContentType

        public java.lang.String getDefaultContentType()
        Returns the default content type to use if no other properties select the renderer.
        Returns:
        The default content type to use if no other properties select the renderer.
      • setDefaultContentType

        public void setDefaultContentType​(java.lang.String defaultContentType)
        Sets the default content type to use if no other properties select the renderer.
        Parameters:
        defaultContentType - The default content type to use if no other properties select the renderer.
      • getRequestKeys

        public RequestKeys getRequestKeys()
        Returns the RequestKeys instance that may be used to determine desired content type to use.
        Returns:
        The RequestKeys instance that may be used to determine desired content type to use.
      • setRequestKeys

        public void setRequestKeys​(RequestKeys requestKeys)
        Sets the RequestKeys instance that may be used to determine desired content type to use.
        Parameters:
        requestKeys - The RequestKeys instance that may be used to determine desired content type to use.
      • getWebIServerSession

        public WebIServerSession getWebIServerSession()
        Returns the WebIServerSession object associated with this BlockContext.
        Returns:
        The WebIServerSession object associated with this BlockContext.
      • setWebIServerSession

        public void setWebIServerSession​(WebIServerSession wiss)
        Sets the WebIServerSession object associated with this BlockContext.
        Parameters:
        wiss - The WebIServerSession object to associate with this context.
      • getPreferences

        public Preferences getPreferences()
        Returns the Preferences associated with this BlockContext.
        Returns:
        The Preferences object associated with this BlockContext. If none was supplied explicitly, and a WebIServerSession was supplied, a Preferences instance is created.
        See Also:
        setWebIServerSession(WebIServerSession)
      • setPreferences

        public void setPreferences​(Preferences preferences)
        Sets the Preferences object to associate with this BlockContext.
        Parameters:
        preferences - The Preferences object to associate with this BlockContext.
      • setEncoderChain

        public void setEncoderChain​(java.lang.String encoders)
        Specify the list of encoders to be used.
        Parameters:
        encoders - - comma delimited string of encoder names. For e.g. "JSON,HTML".
        Since:
        MicroStrategy Web 9.0.1
      • getEncoderChain

        public ContentEncoderChain getEncoderChain()
        Returns the chain of encoders. It will be null if no encoder has been set on this context.
        Returns:
        the chain of encoders. null may be returned if no encoders has been set on it.