org.kuali.rice.krad.uif.modifier
Class ComponentConvertModifier

java.lang.Object
  extended by org.kuali.rice.krad.uif.component.ConfigurableBase
      extended by org.kuali.rice.krad.uif.modifier.ComponentModifierBase
          extended by org.kuali.rice.krad.uif.modifier.ComponentConvertModifier
All Implemented Interfaces:
Serializable, Configurable, ComponentModifier, org.springframework.core.Ordered

public class ComponentConvertModifier
extends ComponentModifierBase

For a given Component instance converts all component properties of a certain type to instances of another configured Component. The conversion is performed recursively down all the component children

Some example uses of this are converting all checkbox controls to radio group controls within a group and replacement of a widget with another

Author:
Kuali Rice Team (rice.collab@kuali.org)
See Also:
Serialized Form

Field Summary
 
Fields inherited from interface org.kuali.rice.krad.uif.component.Ordered
INITIAL_ORDER_VALUE
 
Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
 
Constructor Summary
ComponentConvertModifier()
           
 
Method Summary
protected  void convertToReplacement(Component component, int idSuffix)
          Reads the component properties and looks for types that match the configured type to replace.
 List<Component> getComponentPrototypes()
          List of components that are maintained by the modifier as prototypes for creating other component instances
 Component getComponentReplacementPrototype()
          Prototype for the component replacement
 Class<? extends Component> getComponentTypeToReplace()
          Type of component that should be replaced with an instance of the component prototype
 Set<Class<? extends Component>> getSupportedComponents()
          Set of Component classes that may be sent to the modifier
protected  void performConversion(Component component, String componentProperty, int idSuffix)
          Creates a new instance of the replacement component prototype and sets a the property value for the given property name and component instance
 void performModification(View view, Object model, Component component)
          Invoked within the configured phase of the component lifecycle.
 void setComponentReplacementPrototype(Component componentReplacementPrototype)
          Setter for the replacement component prototype
 void setComponentTypeToReplace(Class<? extends Component> componentTypeToReplace)
          Setter for the component type to replace
 
Methods inherited from class org.kuali.rice.krad.uif.modifier.ComponentModifierBase
getOrder, getRunCondition, getRunPhase, performInitialization, setOrder, setRunCondition, setRunPhase
 
Methods inherited from class org.kuali.rice.krad.uif.component.ConfigurableBase
getPropertyExpression, getPropertyExpressions, setPropertyExpressions
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.kuali.rice.krad.uif.component.Configurable
getPropertyExpression, getPropertyExpressions, setPropertyExpressions
 

Constructor Detail

ComponentConvertModifier

public ComponentConvertModifier()
Method Detail

performModification

public void performModification(View view,
                                Object model,
                                Component component)
Description copied from interface: ComponentModifier
Invoked within the configured phase of the component lifecycle. This is where the ComponentModifier should perform its work against the given Component instance

Parameters:
view - - the view instance to which the component belongs
model - - top level object containing the view data
component - - the component instance to modify
See Also:
ComponentModifier.performModification(org.kuali.rice.krad.uif.view.View, java.lang.Object, org.kuali.rice.krad.uif.component.Component)

convertToReplacement

protected void convertToReplacement(Component component,
                                    int idSuffix)
Reads the component properties and looks for types that match the configured type to replace. If a match is found, a new instance of the replacement component prototype is created and set as the property value. The method is then called for each of the component's children

Parameters:
component - - component instance to inspect properties for
idSuffix - - suffix string to use for any generated component replacements

performConversion

protected void performConversion(Component component,
                                 String componentProperty,
                                 int idSuffix)
Creates a new instance of the replacement component prototype and sets a the property value for the given property name and component instance

Parameters:
component - - component instance to set property on
componentProperty - - property name to set
idSuffix - - suffix string to use for the generated component

getSupportedComponents

public Set<Class<? extends Component>> getSupportedComponents()
Description copied from interface: ComponentModifier
Set of Component classes that may be sent to the modifier

If an empty or null list is returned, it is assumed the modifier supports all components. The returned set will be used by the dictionary validation

Returns:
Set component classes
See Also:
ComponentModifier.getSupportedComponents()

getComponentPrototypes

public List<Component> getComponentPrototypes()
Description copied from interface: ComponentModifier
List of components that are maintained by the modifier as prototypes for creating other component instances

Prototypes are held for configuring how a component should be created during the lifecycle. An example of this are the fields in a collection group that are created for each collection record. They only participate in the initialize phase.

Specified by:
getComponentPrototypes in interface ComponentModifier
Overrides:
getComponentPrototypes in class ComponentModifierBase
Returns:
List child component prototypes
See Also:
ComponentModifierBase.getComponentPrototypes()

getComponentTypeToReplace

public Class<? extends Component> getComponentTypeToReplace()
Type of component that should be replaced with an instance of the component prototype

Returns:
Class component type to replace

setComponentTypeToReplace

public void setComponentTypeToReplace(Class<? extends Component> componentTypeToReplace)
Setter for the component type to replace

Parameters:
componentTypeToReplace -

getComponentReplacementPrototype

public Component getComponentReplacementPrototype()
Prototype for the component replacement

Each time the type to replace if found a new instance of the component prototype will be created and set as the new property value

Returns:

setComponentReplacementPrototype

public void setComponentReplacementPrototype(Component componentReplacementPrototype)
Setter for the replacement component prototype

Parameters:
componentReplacementPrototype -


Copyright © 2005-2013 The Kuali Foundation. All Rights Reserved.