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 |
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 extends Component> |
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(DataBinding field,
String addBindingPrefix) |
static void |
prefixBindingPath(List<? extends Component> components,
String addBindingPrefix) |
static void |
prefixBindingPathNested(Component component,
String addBindingPrefix) |
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 |
updateIdsWithSuffixNested(Component component,
String idSuffix) |
static void |
updateIdsWithSuffixNested(List<? extends Component> components,
String idSuffix) |
static void |
updateIdWithSuffix(Component component,
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 extends Component> 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 prefixBindingPathNested(Component component, String addBindingPrefix)
public static void prefixBindingPath(DataBinding field, String addBindingPrefix)
public static void updateIdsWithSuffixNested(List<? extends Component> components, String idSuffix)
public static void updateIdsWithSuffixNested(Component component, String idSuffix)
public 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 void updateIdWithSuffix(Component component, String idSuffix)
component
- the component instance whose id will be changedidSuffix
- the suffix to be appendedpublic 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 <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–2014 The Kuali Foundation. All rights reserved.