Class ContextUtils

java.lang.Object
org.kuali.rice.krad.uif.util.ContextUtils

public class ContextUtils extends Object
Utility methods related to handling context for components.
Author:
Kuali Rice Team (rice.collab@kuali.org)
  • Method Details

    • pushObjectToContextDeep

      public static void pushObjectToContextDeep(Collection<? extends LifecycleElement> elements, String contextName, Object contextValue)
      places a key, value pair in each context map of a list of components
      Parameters:
      elements - the list of elements
      contextName - a value to be used as a key to retrieve the object
      contextValue - the value to be placed in the context
    • pushObjectToContextDeep

      public static void pushObjectToContextDeep(Component component, String contextName, Object contextValue)
      Pushes object to a component's context so that it is available from Component.getContext()

      The component's nested components that are available via Component#getComponentsForLifecycle are also updated recursively

      Parameters:
      component - the component whose context is to be updated
      contextName - a value to be used as a key to retrieve the object
      contextValue - the value to be placed in the context
    • pushAllToContextDeep

      public static void pushAllToContextDeep(Component component, Map<String,Object> sourceContext)
      Pushes object to a component's context so that it is available from Component.getContext()

      The component's nested components that are available via Component#getComponentsForLifecycle are also updated recursively

      Parameters:
      component - the component whose context is to be updated
      sourceContext - The source context map.
    • pushAllToContextDeep

      public static void pushAllToContextDeep(List<? extends Component> components, Map<String,Object> sourceContext)
      Places a all entries from a map into each context map of a list of components.
      Parameters:
      components - The list components.
      sourceContext - The source context map.
    • updateContextsForLine

      public static void updateContextsForLine(List<? extends Component> components, CollectionGroup collectionGroup, Object collectionLine, int lineIndex, String lineSuffix)
      Update the contexts of the given components.
      Parameters:
      components - the components whose components to update
      collectionGroup - collection group the components are associated with
      collectionLine - an instance of the data object for the line
      lineIndex - the line index
      lineSuffix - id suffix for components in the line to make them unique
    • updateContextForLine

      public static void updateContextForLine(Component component, CollectionGroup collectionGroup, Object collectionLine, int lineIndex, String lineSuffix)
      Update the context map for the given component with the collection context.

      The values of UifConstants.ContextVariableNames.LINE and UifConstants.ContextVariableNames.INDEX are set to collectionLine and lineIndex respectively.

      Parameters:
      component - the component whose context is to be updated
      collectionGroup - collection group the component is associated with
      collectionLine - an instance of the data object for the line
      lineIndex - the line index
      lineSuffix - id suffix for components in the line to make them unique
    • cleanContextDeep

      public static void cleanContextDeep(LifecycleElement lifecycleElement)
      Sets the context of the given lifecycle element to null, then using reflection recursively finds any lifecycle element children and sets their context to null.
      Parameters:
      lifecycleElement - lifecycle element instance to clean