Class ComponentConvertModifier

All Implemented Interfaces:
Serializable, Cloneable, Copyable, DictionaryBean, UifDictionaryBean, Ordered, 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:
  • Constructor Details

    • ComponentConvertModifier

      public ComponentConvertModifier()
  • Method Details

    • performModification

      public void performModification(Object model, Component component)
      Invoked within the configured phase of the component lifecycle. This is where the ComponentModifier should perform its work against the given Component instance
      Parameters:
      model - - top level object containing the view data
      component - - the component instance to modify
      See Also:
    • 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()
      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
    • 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<Component> child component prototypes
      See Also:
    • getComponentTypeToReplace

      public Class<? extends Component> getComponentTypeToReplace()
      Type of component that should be replaced with an instance of the component prototype
      Returns:
      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:
      Component
    • setComponentReplacementPrototype

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