Class ComponentUtils
Component instances.- Author:
- Kuali Rice Team (rice.collab@kuali.org)
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidadjustNestedLevelsForTableCollections(Container container, int currentLevel) Adjust nestingLevel properties for collections which use RichTable with forceLocalJsonData on and for all of its potentially additional nested subcollectionsstatic <T extends Field>
voidbindAndIdFieldList(List<T> fields, String addBindingPrefix, String idSuffix) Adjusts the ids to contain the given suffix and adds the giving binding prefix for the list of fields.static booleancanBeRefreshed(Component component) Indicates if the given component has configuration that it allows it to be refreshed.static voidcleanContextDeap(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 voidclearAndAssignIds(List<? extends Component> components) Replace all IDs from a component and its children with new generated ID values.static booleancontainsPropertyExpression(Component component, String propertyName, boolean collectionMatch) Determines whether the given component contains an expression for the given property nameCopy a list of componentsstatic <T extends Component>
Tcopy(T component) static <T extends Component>
Tstatic <T extends Component>
TcopyComponent(T component, String addBindingPrefix, String idSuffix) copyComponentList(List<T> components, String idSuffix) static ComponentfindComponentInList(List<Component> components, String componentId) Searches for the component with the given id within the given list of componentsstatic intgenerateId(LifecycleElement element, int seed) Generate a hash code unique within the current view for a single lifecycle element.static List<InputField> getAllInputFieldsWithinContainer(Container container) Gets all the input fields contained in this container, but also in every sub-container that is a child of this container.getAllNestedComponents(Component component) Get all nested children of a given component.static <T> List<T> getComponentsOfType(List<? extends Component> items, Class<T> componentType) getNestedContainerComponents(Container container, Class<T> componentType) Gets all components of the give type that are within the items list of the container, or within a nested container or field group.getNestedNonCollectionComponents(List<Component> items, Class<T> componentType) getNestedNonCollectionComponents(Container container, Class<T> componentType) static voidprefixBindingPath(List<? extends Component> components, String addBindingPrefix) static voidprefixBindingPath(Component component, String addBindingPrefix) static voidprefixBindingPath(DataBinding field, String addBindingPrefix) static voidprefixBindingPathNested(Component component, String addBindingPrefix) static voidplaces a all entries from a map into each context map of a list of componentsstatic voidpushAllToContext(Component component, Map<String, Object> sourceContext) pushes object to a component's context so that it is available fromComponent.getContext()static voidpushObjectToContext(Collection<? extends LifecycleElement> elements, String contextName, Object contextValue) places a key, value pair in each context map of a list of componentsstatic voidpushObjectToContext(Component component, String contextName, Object contextValue) pushes object to a component's context so that it is available fromComponent.getContext()static voidsetComponentPropertyDeep(Component component, String propertyPath, Object propertyValue) Traverse a component tree, setting a property on all components for which the property is writable.static voidsetComponentPropertyFinal(Component component, String propertyName, Object propertyValue) Sets a property on the given component and removes any expressions for that property so the value is not overriddenstatic <T extends Component>
voidsetComponentsPropertyDeep(List<T> components, String propertyPath, Object propertyValue) Traverse a component tree, setting a property on all components for which the property is writable.Performs sorting logic of the given list ofOrderedinstances by its order propertystatic voidupdateChildIdsWithSuffixNested(Component component, String idSuffix) static voidupdateContextForLine(Component component, CollectionGroup collectionGroup, Object collectionLine, int lineIndex, String lineSuffix) update the context map for the given componentstatic voidupdateContextsForLine(List<? extends Component> components, CollectionGroup collectionGroup, Object collectionLine, int lineIndex, String lineSuffix) Update the contexts of the given components.static voidupdateIdsWithSuffixNested(List<? extends Component> components, String idSuffix) static voidupdateIdsWithSuffixNested(Component component, String idSuffix) static voidupdateIdWithSuffix(LifecycleElement element, String idSuffix) add a suffix to the id
-
Method Details
-
copy
-
copy
-
copy
Copy a list of components- Type Parameters:
T- component typeT- component type- Parameters:
components- the list of components to copy- Returns:
- the copied list
-
bindAndIdFieldList
public static <T extends Field> void bindAndIdFieldList(List<T> fields, String addBindingPrefix, String idSuffix) Adjusts the ids to contain the given suffix and adds the giving binding prefix for the list of fields.- Type Parameters:
T- component type- Parameters:
fields- list of fields to bind and idaddBindingPrefix- prefix to add to the binding pathidSuffix- id suffix
-
copyComponent
-
copyComponentList
-
getComponentsOfType
-
getNestedContainerComponents
public static <T extends Component> List<T> getNestedContainerComponents(Container container, Class<T> componentType) Gets all components of the give type that are within the items list of the container, or within a nested container or field group.- Type Parameters:
T- type for component to pull- Parameters:
container- container instance to pull components fromcomponentType- type for components to pull- Returns:
- List of nested components with the given type
-
getNestedNonCollectionComponents
-
getNestedNonCollectionComponents
-
getAllNestedComponents
Get all nested children of a given component.- Parameters:
component- The component to search.- Returns:
- All nested children of the component.
- See Also:
-
findComponentInList
Searches for the component with the given id within the given list of components- Parameters:
components- list of components to search throughcomponentId- id for the component to find- Returns:
- component found in the list or null
-
prefixBindingPath
-
prefixBindingPath
-
prefixBindingPath
-
prefixBindingPathNested
-
updateIdsWithSuffixNested
-
updateIdsWithSuffixNested
-
updateIdWithSuffix
add a suffix to the id- Parameters:
element- the component instance whose id will be changedidSuffix- the suffix to be appended
-
updateChildIdsWithSuffixNested
-
generateId
Generate a hash code unique within the current view for a single lifecycle element. A unique ID value will be assigned to the lifecycle element, replacing the current ID.This method may only be called during the view lifecycle.
- Parameters:
element- The element to generate a hash code for.seed- A hash value to use as a seed for the new hash.- Returns:
- A hash code based on the provided element and seed value.
- See Also:
-
clearAndAssignIds
Replace all IDs from a component and its children with new generated ID values.If there are features that depend on a static id of this component, this call may cause errors.
- Parameters:
components- A list of component to clear all IDs from.- See Also:
-
setComponentsPropertyDeep
public static <T extends Component> void setComponentsPropertyDeep(List<T> components, String propertyPath, Object propertyValue) Traverse a component tree, setting a property on all components for which the property is writable.- Type Parameters:
T- component typeT- component type- Parameters:
components- The components to traverse.propertyPath- The property path to set.propertyValue- The property value to set.- See Also:
-
setComponentPropertyDeep
public static void setComponentPropertyDeep(Component component, String propertyPath, Object propertyValue) Traverse a component tree, setting a property on all components for which the property is writable.- Parameters:
component- The component to traverse.propertyPath- The property path to set.propertyValue- The property value to set.- See Also:
-
setComponentPropertyFinal
public static void setComponentPropertyFinal(Component component, String propertyName, Object propertyValue) Sets a property on the given component and removes any expressions for that property so the value is not overridden- Parameters:
component- component instance to set property onpropertyName- name of property to setpropertyValue- value to set property to
-
canBeRefreshed
Indicates if the given component has configuration that it allows it to be refreshed.- Parameters:
component- instance to check- Returns:
- true if component can be refreshed, false if not
-
pushObjectToContext
public static void pushObjectToContext(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
-
pushObjectToContext
public static void pushObjectToContext(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
-
pushAllToContext
public static void pushAllToContext(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.
-
pushAllToContext
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.
-
updateContextsForLine
public static void updateContextsForLine(List<? extends Component> components, CollectionGroup collectionGroup, Object collectionLine, int lineIndex, String lineSuffix) Update the contexts of the given components.Calls
updateContextForLine(org.kuali.rice.krad.uif.component.Component, org.kuali.rice.krad.uif.container.CollectionGroup, java.lang.Object, int, java.lang.String)for each component- 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 componentThe 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, not if the collection group has a container id suffix it will be appended to the lineSuffix for the final exported context entry
-
cleanContextDeap
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
-
sort
Performs sorting logic of the given list ofOrderedinstances by its order propertyItems list is sorted based on its order property. Lower order values are placed higher in the list. If a item does not have a value assigned for the order (or is equal to the default order of 0), it will be assigned the a value based on the given order sequence integer. If two or more items share the same order value, all but the last item found in the list will be removed.
- Type Parameters:
T- ordered type- Returns:
- List<Ordered> sorted items
- See Also:
-
getAllInputFieldsWithinContainer
Gets all the input fields contained in this container, but also in every sub-container that is a child of this container. When called from the top level View this will be every InputField across all pages.- Parameters:
container- container to scan for input fields- Returns:
- every InputField that is a child at any level of this container
-
containsPropertyExpression
public static boolean containsPropertyExpression(Component component, String propertyName, boolean collectionMatch) Determines whether the given component contains an expression for the given property name- Parameters:
component- component instance to check for expressionspropertyName- name of the property to determine if there is an expression forcollectionMatch- if set to true will find an expressions for properties that start with the given property name (for matching expressions on collections like prop[index] or prop['key'])- Returns:
- true if the component has an expression for the property name, false if not
-
adjustNestedLevelsForTableCollections
Adjust nestingLevel properties for collections which use RichTable with forceLocalJsonData on and for all of its potentially additional nested subcollections- Parameters:
container- container to traverse and update nested levels incurrentLevel- the current nesting level, the initial call to this method should be 0
-