public class ComponentUtils extends Object
Component
instances.Modifier and Type | Method and Description |
---|---|
static void |
adjustNestedLevelsForTableCollections(Container container,
int currentLevel)
Adjust nestingLevel properties for collections which use RichTable with forceLocalJsonData on and for all of its
potentially additional nested subcollections
|
static <T extends Field> |
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.
|
static boolean |
canBeRefreshed(Component component)
Indicates if the given component has configuration that it allows it to be refreshed.
|
static void |
cleanContextDeap(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 void |
clearAndAssignIds(List<? extends Component> components)
Replace all IDs from a component and its children with new generated ID values.
|
static boolean |
containsPropertyExpression(Component component,
String propertyName,
boolean collectionMatch)
Determines whether the given component contains an expression for the given property name
|
static <T extends Component> |
copy(List<T> components)
Copy a list of components
|
static <T extends Component> |
copy(T component) |
static <T extends Component> |
copy(T component,
String idSuffix) |
static <T extends Component> |
copyComponent(T component,
String addBindingPrefix,
String idSuffix) |
static <T extends Component> |
copyComponentList(List<T> components,
String idSuffix) |
static Component |
findComponentInList(List<Component> components,
String componentId)
Searches for the component with the given id within the given list of components
|
static int |
generateId(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.
|
static List<Component> |
getAllNestedComponents(Component component)
Get all nested children of a given component.
|
static <T> List<T> |
getComponentsOfType(List<? extends Component> items,
Class<T> componentType) |
static <T extends Component> |
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.
|
static <T extends Component> |
getNestedNonCollectionComponents(Container container,
Class<T> componentType) |
static <T extends Component> |
getNestedNonCollectionComponents(List<Component> items,
Class<T> componentType) |
static void |
prefixBindingPath(Component component,
String addBindingPrefix) |
static void |
prefixBindingPath(DataBinding field,
String addBindingPrefix) |
static void |
prefixBindingPath(List<? extends Component> components,
String addBindingPrefix) |
static void |
prefixBindingPathNested(Component component,
String addBindingPrefix) |
static void |
pushAllToContext(Component component,
Map<String,Object> sourceContext)
pushes object to a component's context so that it is available from
Component.getContext() |
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
|
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
|
static void |
pushObjectToContext(Component component,
String contextName,
Object contextValue)
pushes object to a component's context so that it is available from
Component.getContext() |
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.
|
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
|
static <T extends Component> |
setComponentsPropertyDeep(List<T> components,
String propertyPath,
Object propertyValue)
Traverse a component tree, setting a property on all components for which the property is writable.
|
static <T extends Ordered> |
sort(List<T> items,
int defaultOrderSequence)
Performs sorting logic of the given list of
Ordered
instances by its order property |
static void |
updateChildIdsWithSuffixNested(Component component,
String idSuffix) |
static void |
updateContextForLine(Component component,
CollectionGroup collectionGroup,
Object collectionLine,
int lineIndex,
String lineSuffix)
update the context map for the given component
|
static void |
updateContextsForLine(List<? extends Component> components,
CollectionGroup collectionGroup,
Object collectionLine,
int lineIndex,
String lineSuffix)
Update the contexts of the given components.
|
static void |
updateIdsWithSuffixNested(Component component,
String idSuffix) |
static void |
updateIdsWithSuffixNested(List<? extends Component> components,
String idSuffix) |
static void |
updateIdWithSuffix(LifecycleElement element,
String idSuffix)
add a suffix to the id
|
public static <T extends Component> List<T> copy(List<T> components)
T
- component typeT
- component typecomponents
- the list of components to copypublic static <T extends Field> void bindAndIdFieldList(List<T> fields, String addBindingPrefix, String idSuffix)
T
- component typefields
- list of fields to bind and idaddBindingPrefix
- prefix to add to the binding pathidSuffix
- id suffixpublic static <T extends Component> T copyComponent(T component, String addBindingPrefix, String idSuffix)
public static <T extends Component> List<T> copyComponentList(List<T> components, String idSuffix)
public static <T> List<T> getComponentsOfType(List<? extends Component> items, Class<T> componentType)
public static <T extends Component> List<T> getNestedContainerComponents(Container container, Class<T> componentType)
T
- type for component to pullcontainer
- container instance to pull components fromcomponentType
- type for components to pullpublic static <T extends Component> List<T> getNestedNonCollectionComponents(List<Component> items, Class<T> componentType)
public static <T extends Component> List<T> getNestedNonCollectionComponents(Container container, Class<T> componentType)
public static List<Component> getAllNestedComponents(Component component)
component
- The component to search.ViewLifecycleUtils.getElementsForLifecycle(LifecycleElement)
public static Component findComponentInList(List<Component> components, String componentId)
components
- list of components to search throughcomponentId
- id for the component to findpublic static void prefixBindingPath(List<? extends Component> components, String addBindingPrefix)
public static void prefixBindingPath(Component component, String addBindingPrefix)
public static void prefixBindingPath(DataBinding field, String addBindingPrefix)
public static void prefixBindingPathNested(Component component, String addBindingPrefix)
public static void updateIdsWithSuffixNested(List<? extends Component> components, String idSuffix)
public static void updateIdsWithSuffixNested(Component component, String idSuffix)
public static void updateIdWithSuffix(LifecycleElement element, String idSuffix)
element
- the component instance whose id will be changedidSuffix
- the suffix to be appendedpublic static void updateChildIdsWithSuffixNested(Component component, String idSuffix)
public static int generateId(LifecycleElement element, int seed)
This method may only be called during the view lifecycle.
element
- The element to generate a hash code for.seed
- A hash value to use as a seed for the new hash.For a complete description of the algorithm. This method implements a
single step in the algorithm described in that task.
public static void clearAndAssignIds(List<? extends Component> components)
If there are features that depend on a static id of this component, this call may cause errors.
components
- A list of component to clear all IDs from.For a complete description of the algorithm.
public static <T extends Component> void setComponentsPropertyDeep(List<T> components, String propertyPath, Object propertyValue)
T
- component typeT
- component typecomponents
- The components to traverse.propertyPath
- The property path to set.propertyValue
- The property value to set.ObjectPropertyUtils.isWritableProperty(Object, String)
,
ObjectPropertyUtils.setPropertyValue(Object, String, Object)
public static void setComponentPropertyDeep(Component component, String propertyPath, Object propertyValue)
component
- The component to traverse.propertyPath
- The property path to set.propertyValue
- The property value to set.ObjectPropertyUtils.isWritableProperty(Object, String)
,
ObjectPropertyUtils.setPropertyValue(Object, String, Object)
public static void setComponentPropertyFinal(Component component, String propertyName, Object propertyValue)
component
- component instance to set property onpropertyName
- name of property to setpropertyValue
- value to set property topublic static boolean canBeRefreshed(Component component)
component
- instance to checkpublic static void pushObjectToContext(Collection<? extends LifecycleElement> elements, String contextName, Object contextValue)
elements
- the list of elementscontextName
- a value to be used as a key to retrieve the objectcontextValue
- the value to be placed in the contextpublic static void pushObjectToContext(Component component, String contextName, Object contextValue)
Component.getContext()
The component's nested components that are available via Component#getComponentsForLifecycle
are also updated recursively
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 contextpublic static void pushAllToContext(List<? extends Component> components, Map<String,Object> sourceContext)
components
- The list components.sourceContext
- The source context map.public static void pushAllToContext(Component component, Map<String,Object> sourceContext)
Component.getContext()
The component's nested components that are available via Component#getComponentsForLifecycle
are also updated recursively
component
- the component whose context is to be updatedsourceContext
- The source context map.public static void updateContextsForLine(List<? extends Component> components, CollectionGroup collectionGroup, Object collectionLine, int lineIndex, String lineSuffix)
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
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 uniquepublic static void updateContextForLine(Component component, CollectionGroup collectionGroup, Object collectionLine, int lineIndex, String lineSuffix)
The values of UifConstants.ContextVariableNames.LINE
and UifConstants.ContextVariableNames.INDEX
are set to collectionLine
and lineIndex
respectively.
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 entrypublic static void cleanContextDeap(LifecycleElement lifecycleElement)
lifecycleElement
- lifecycle element instance to cleanpublic static <T extends Ordered> List<T> sort(List<T> items, int defaultOrderSequence)
Ordered
instances by its order property
Items 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.
T
- ordered typeT
- ordered typeitems
- defaultOrderSequence
- Component.getOrder()
,
Ordered
public static List<InputField> getAllInputFieldsWithinContainer(Container container)
container
- container to scan for input fieldspublic static boolean containsPropertyExpression(Component component, String propertyName, boolean collectionMatch)
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'])public static void adjustNestedLevelsForTableCollections(Container container, int currentLevel)
container
- container to traverse and update nested levels incurrentLevel
- the current nesting level, the initial call to this method should be 0Copyright © 2005–2016 The Kuali Foundation. All rights reserved.