Package org.kuali.rice.krad.uif.util
Class ContextUtils
java.lang.Object
org.kuali.rice.krad.uif.util.ContextUtils
Utility methods related to handling context for components.
- Author:
- Kuali Rice Team (rice.collab@kuali.org)
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidcleanContextDeep(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.static voidPlaces a all entries from a map into each context map of a list of components.static voidpushAllToContextDeep(Component component, Map<String, Object> sourceContext) Pushes object to a component's context so that it is available fromComponent.getContext()static voidpushObjectToContextDeep(Collection<? extends LifecycleElement> elements, String contextName, Object contextValue) places a key, value pair in each context map of a list of componentsstatic voidpushObjectToContextDeep(Component component, String contextName, Object contextValue) Pushes object to a component's context so that it is available fromComponent.getContext()static voidupdateContextForLine(Component component, CollectionGroup collectionGroup, Object collectionLine, int lineIndex, String lineSuffix) Update the context map for the given component with the collection context.static voidupdateContextsForLine(List<? extends Component> components, CollectionGroup collectionGroup, Object collectionLine, int lineIndex, String lineSuffix) Update the contexts of the given components.
-
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 elementscontextName- a value to be used as a key to retrieve the objectcontextValue- 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 fromComponent.getContext()The component's nested components that are available via
Component#getComponentsForLifecycleare also updated recursively- Parameters:
component- the component whose context is to be updatedcontextName- a value to be used as a key to retrieve the objectcontextValue- the value to be placed in the context
-
pushAllToContextDeep
Pushes object to a component's context so that it is available fromComponent.getContext()The component's nested components that are available via
Component#getComponentsForLifecycleare also updated recursively- Parameters:
component- the component whose context is to be updatedsourceContext- 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 updatecollectionGroup- collection group the components are associated withcollectionLine- an instance of the data object for the linelineIndex- the line indexlineSuffix- 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.LINEandUifConstants.ContextVariableNames.INDEXare set tocollectionLineandlineIndexrespectively.- Parameters:
component- the component whose context is to be updatedcollectionGroup- collection group the component is associated withcollectionLine- an instance of the data object for the linelineIndex- the line indexlineSuffix- id suffix for components in the line to make them unique
-
cleanContextDeep
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
-