Class ViewElementBuilderContextHolder

java.lang.Object
com.foreach.across.modules.web.ui.ViewElementBuilderContextHolder

public abstract class ViewElementBuilderContextHolder extends Object
Holder class that associates a ViewElementBuilderContext with the current thread. Used by block tag processors where nested blocks would build on top of the parent context. This is different than the request scoped bean: the thread local render context is the one actually being used by the current thread for the rendering, whereas the request scoped bean represents the global context for the request (the root of the render context hierarchy).

The attached context is not inherited by child threads.

Since:
2.0.0
Author:
Arne Vandamme
See Also:
  • Constructor Details

    • ViewElementBuilderContextHolder

      public ViewElementBuilderContextHolder()
  • Method Details

    • setViewElementBuilderContext

      public static Optional<ViewElementBuilderContext> setViewElementBuilderContext(ViewElementBuilderContext ViewElementBuilderContext)
      Associate the given context with the current thread. Will replace any previously configured context. If the context parameter is null, the attached context will be removed.
      Parameters:
      ViewElementBuilderContext - instance
      Returns:
      the context that has been removed
    • setViewElementBuilderContext

      public static Optional<ViewElementBuilderContext> setViewElementBuilderContext(Optional<ViewElementBuilderContext> ViewElementBuilderContext)
      Associate the given context with the current thread. Will replace any previously configured context. If the context parameter is empty, the attached context will be removed.

      Convenience method for easy resetting of previously retrieved context.

      Parameters:
      ViewElementBuilderContext - instance
      Returns:
      the context that has been removed
    • getViewElementBuilderContext

      public static Optional<ViewElementBuilderContext> getViewElementBuilderContext()
      Returns:
      the context attached to the current thread
    • clearViewElementBuilderContext

      public static Optional<ViewElementBuilderContext> clearViewElementBuilderContext()
      Removes the (optional) context attached to the current thread.
      Returns:
      the context that has been removed