Class UIContextHolder


  • public final class UIContextHolder
    extends Object

    This class holds the current (active) UIContext.

    WComponents store user (session) component models within the UIContext, and the UIContextHolder provides a central location for components to read from. It is the responsibility of the WComponent container (e.g. Servlet) to initialise the holder at the start of each WComponent lifecycle, and clean it up afterwards.

    Applications should not normally need to use this class directly. If application code needs access to the UIContext, it must only call getCurrent(). Do not call any other method within this class.

    The UIContextHolder uses a stack internally, to allow for components which utilise "SubUIContexts", for repeated data.

    Since:
    1.0.0
    Author:
    Yiannis Paschalidis
    • Method Detail

      • pushContext

        public static void pushContext​(UIContext uic)
        Pushes a context onto the top of stack. This method is called by internal WComponent containers (e.g. WServlet) at the start of processing a request. and by components which repeat content.
        Parameters:
        uic - the UIContext to push.
      • popContext

        public static UIContext popContext()
        Removes a context from the top of the stack. This method is only called by components which repeat content.
        Returns:
        the UIContext which was removed.
      • getCurrent

        public static UIContext getCurrent()
        Retrieves the current effective UIContext. Note that this method will return null if called from outside normal request processing, for example during the intial application UI construction.
        Returns:
        the current effective UIContext.
      • getCurrentPrimaryUIContext

        public static UIContext getCurrentPrimaryUIContext()
        Returns:
        the primary context for the current context
      • getPrimaryUIContext

        public static UIContext getPrimaryUIContext​(UIContext uic)
        A utility function to iterate to the primary (top most) context and return it.
        Parameters:
        uic - the UIContext to retrieve the primary context for.
        Returns:
        the primary context for the given context.
      • reset

        public static void reset()
        Clears the UIContext stack. This method is called by internal WComponent containers (e.g. WServlet) after a request has been processed.