org.apache.tiles.core.impl

## Class BasicTilesContainer

- java.lang.Object
- - org.apache.tiles.core.impl.BasicTilesContainer

- All Implemented Interfaces:
    TilesContainer, AttributeEvaluatorFactoryAware

      public class BasicTilesContainer
      extends Object
      implements TilesContainer, AttributeEvaluatorFactoryAware

  Basic implementation of the tiles container interface. In most cases, this container will be customized by injecting customized services, not necessarily by override the container
  Since:
    2.0

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `BasicTilesContainer()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `endContext(Request request)` Ends a context, where attribute values are stored independently of others. It must be called after a `TilesContainer.startContext(Request)` call.
    `Object` | `evaluate(Attribute attribute, Request request)` Evaluates the given attribute.
    `ApplicationContext` | `getApplicationContext()` Returns the Tiles application context used by this container.
    `AttributeContext` | `getAttributeContext(Request request)` Retrieve the attribute context of the current request.
    `protected AttributeContext` | `getContext(Request tilesContext)` Get attribute context from request.
    `protected Deque<AttributeContext>` | `getContextStack(Request tilesContext)` Returns the context stack.
    `Definition` | `getDefinition(String definitionName, Request request)` Returns a definition specifying its name.
    `boolean` | `isValidDefinition(String definitionName, Request request)` Determine whether the definition exists.
    `protected AttributeContext` | `popContext(Request tilesContext)` Pops a context object out of the stack.
    `void` | `prepare(String preparer, Request request)` Executes a preparer.
    `protected void` | `pushContext(AttributeContext context, Request tilesContext)` Pushes a context object in the stack.
    `void` | `render(Attribute attr, Request request)` Render the given Attribute.
    `void` | `render(Definition definition, Request request)` Renders the specified definition.
    `protected void` | `render(Request request, AttributeContext attributeContext)` Renders the specified attribute context.
    `void` | `render(String definitionName, Request request)` Render the given tiles request.
    `void` | `renderContext(Request request)` Renders the current context, as it is.
    `void` | `setApplicationContext(ApplicationContext context)` Sets the Tiles application context to use.
    `void` | `setAttributeEvaluatorFactory(AttributeEvaluatorFactory attributeEvaluatorFactory)` Sets the attribute evaluator factory.
    `void` | `setDefinitionsFactory(DefinitionsFactory definitionsFactory)` Set the definitions factory.
    `void` | `setPreparerFactory(PreparerFactory preparerFactory)` Set the preparerInstance factory.
    `void` | `setRendererFactory(RendererFactory rendererFactory)` Sets the renderer instance factory.
    `AttributeContext` | `startContext(Request request)` Starts a new context, where attribute values are stored independently of others. When the use of the contexts is finished, call`TilesContainer.endContext(Request)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### BasicTilesContainer

          public BasicTilesContainer()

  - ### Method Detail

    - #### startContext

          public AttributeContext startContext(Request request)

      Starts a new context, where attribute values are stored independently of others.
      When the use of the contexts is finished, call`TilesContainer.endContext(Request)`
      Specified by:
        `startContext` in interface `TilesContainer`
      Parameters:
        `request` - The request.
      Returns:
        The newly created context.

    - #### endContext

          public void endContext(Request request)

      Ends a context, where attribute values are stored independently of others.
      It must be called after a `TilesContainer.startContext(Request)` call.
      Specified by:
        `endContext` in interface `TilesContainer`
      Parameters:
        `request` - The request.

    - #### renderContext

          public void renderContext(Request request)

      Renders the current context, as it is.
      Specified by:
        `renderContext` in interface `TilesContainer`
      Parameters:
        `request` - The request.

    - #### getApplicationContext

          public ApplicationContext getApplicationContext()

      Returns the Tiles application context used by this container.
      Specified by:
        `getApplicationContext` in interface `TilesContainer`
      Returns:
        the application context for this container.

    - #### setApplicationContext

          public void setApplicationContext(ApplicationContext context)

      Sets the Tiles application context to use.
      Parameters:
        `context` - The Tiles application context.

    - #### getAttributeContext

          public AttributeContext getAttributeContext(Request request)

      Retrieve the attribute context of the current request.
      Specified by:
        `getAttributeContext` in interface `TilesContainer`
      Parameters:
        `request` - The request.
      Returns:
        map of the attributes in the current attribute context.

    - #### setDefinitionsFactory

          public void setDefinitionsFactory(DefinitionsFactory definitionsFactory)

      Set the definitions factory. This method first ensures that the container has not yet been initialized.
      Parameters:
        `definitionsFactory` - the definitions factory for this instance.

    - #### setPreparerFactory

          public void setPreparerFactory(PreparerFactory preparerFactory)

      Set the preparerInstance factory. This method first ensures that the container has not yet been initialized.
      Parameters:
        `preparerFactory` - the preparerInstance factory for this conainer.

    - #### setRendererFactory

          public void setRendererFactory(RendererFactory rendererFactory)

      Sets the renderer instance factory.
      Parameters:
        `rendererFactory` - the renderer instance factory for this container.
      Since:
        2.1.0

    - #### setAttributeEvaluatorFactory

          public void setAttributeEvaluatorFactory(AttributeEvaluatorFactory attributeEvaluatorFactory)

      Sets the attribute evaluator factory.
      Specified by:
        `setAttributeEvaluatorFactory` in interface `AttributeEvaluatorFactoryAware`
      Parameters:
        `attributeEvaluatorFactory` - The attribute evaluator factory to use.

    - #### prepare

          public void prepare(String preparer,
                              Request request)

      Executes a preparer.
      Specified by:
        `prepare` in interface `TilesContainer`
      Parameters:
        `preparer` - The name of the preparer to execute.
        `request` - The request.

    - #### render

          public void render(String definitionName,
                             Request request)

      Render the given tiles request.
      Specified by:
        `render` in interface `TilesContainer`
      Parameters:
        `definitionName` - the current definition.
        `request` - The request.

    - #### render

          public void render(Definition definition,
                             Request request)

      Renders the specified definition.
      Specified by:
        `render` in interface `TilesContainer`
      Parameters:
        `definition` - The definition to render.
        `request` - The request context.
      Since:
        2.1.3

    - #### render

          public void render(Attribute attr,
                             Request request)
                      throws IOException

      Render the given Attribute.
      Specified by:
        `render` in interface `TilesContainer`
      Parameters:
        `attr` - The attribute to render.
        `request` - The request.
      Throws:
        `IOException` - If something goes wrong during writing to the output.

    - #### evaluate

          public Object evaluate(Attribute attribute,
                                 Request request)

      Evaluates the given attribute.
      Specified by:
        `evaluate` in interface `TilesContainer`
      Parameters:
        `attribute` - The attribute to evaluate.
        `request` - The request.
      Returns:
        The evaluated object.

    - #### isValidDefinition

          public boolean isValidDefinition(String definitionName,
                                           Request request)

      Determine whether the definition exists.
      Specified by:
        `isValidDefinition` in interface `TilesContainer`
      Parameters:
        `definitionName` - the name of the definition.
        `request` - The request.
      Returns:
        true if the definition is found.

    - #### getDefinition

          public Definition getDefinition(String definitionName,
                                          Request request)

      Returns a definition specifying its name.
      Specified by:
        `getDefinition` in interface `TilesContainer`
      Parameters:
        `definitionName` - The name of the definition to find.
        `request` - The request context.
      Returns:
        The definition, if found.

    - #### getContextStack

          protected Deque<AttributeContext> getContextStack(Request tilesContext)

      Returns the context stack.
      Parameters:
        `tilesContext` - The Tiles context object to use.
      Returns:
        The needed stack of contexts.
      Since:
        2.0.6

    - #### pushContext

          protected void pushContext(AttributeContext context,
                                     Request tilesContext)

      Pushes a context object in the stack.
      Parameters:
        `context` - The context to push.
        `tilesContext` - The Tiles context object to use.
      Since:
        2.0.6

    - #### popContext

          protected AttributeContext popContext(Request tilesContext)

      Pops a context object out of the stack.
      Parameters:
        `tilesContext` - The Tiles context object to use.
      Returns:
        The popped context object.
      Since:
        2.0.6

    - #### getContext

          protected AttributeContext getContext(Request tilesContext)

      Get attribute context from request.
      Parameters:
        `tilesContext` - current Tiles application context.
      Returns:
        BasicAttributeContext or null if context is not found.
      Since:
        2.0.6

    - #### render

          protected void render(Request request,
                                AttributeContext attributeContext)

      Renders the specified attribute context.
      Parameters:
        `request` - The request context.
        `attributeContext` - The context to render.
      Throws:
        `InvalidTemplateException` - If the template is not valid.
        `CannotRenderException` - If something goes wrong during rendering.
      Since:
        2.1.3

Copyright © 2000–2023 Apache Software Foundation. All rights reserved.