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

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

public class CompareFieldCreateModifier
extends ComponentModifierBase

Generates Field instances to produce a comparison view among objects of the same type

Modifier is initialized with a List of ComparableInfo instances. For each comparable info, a copy of the configured group field is made and adjusted to the binding object path for the comparable. The comparison fields are ordered based on the configured order property of the comparable. In addition, a HeaderField can be generated to label each group of comparison fields.

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

Field Summary
private  List<ComparableInfo> comparables
           
private  int defaultOrderSequence
           
private  boolean generateCompareHeaders
           
private  HeaderField headerFieldPrototype
           
private static org.apache.log4j.Logger LOG
           
private static long serialVersionUID
           
 
Fields inherited from interface org.kuali.rice.krad.uif.core.Ordered
INITIAL_ORDER_VALUE
 
Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
 
Constructor Summary
CompareFieldCreateModifier()
           
 
Method Summary
 List<ComparableInfo> getComparables()
          List of ComparableInfo instances the compare fields should be generated for
 int getDefaultOrderSequence()
          Indicates the starting integer sequence value to use for ComparableInfo instances that do not have the order property set
 HeaderField getHeaderFieldPrototype()
          Prototype instance to use for creating the HeaderField for each group of comparison fields (if generateCompareHeaders is true)
protected  String getIdSuffix(ComparableInfo comparable, int index)
          Generates an id suffix for the comparable item
 Set<Class<? extends Component>> getSupportedComponents()
          Set of Component classes that may be sent to the modifier
 boolean isGenerateCompareHeaders()
          Indicates whether a HeaderField should be created for each group of comparison fields
 void performModification(View view, Object model, Component component)
          Generates the comparison fields
protected  void performValueComparison(Group group, Component compareItem, Object model, String compareValueObjectBindingPath)
          For each attribute field in the compare item, retrieves the field value and compares against the value for the main comparable.
 void setComparables(List<ComparableInfo> comparables)
          Setter for the list of comparable info instances
 void setDefaultOrderSequence(int defaultOrderSequence)
          Setter for the default sequence starting value
 void setGenerateCompareHeaders(boolean generateCompareHeaders)
          Setter for the generate comparison headers indicator
 void setHeaderFieldPrototype(HeaderField headerFieldPrototype)
          Setter for the header field prototype
 
Methods inherited from class org.kuali.rice.krad.uif.modifier.ComponentModifierBase
getOrder, getRunCondition, getRunPhase, performModification, setOrder, setRunCondition, setRunPhase
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG

private static final org.apache.log4j.Logger LOG

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

defaultOrderSequence

private int defaultOrderSequence

generateCompareHeaders

private boolean generateCompareHeaders

headerFieldPrototype

private HeaderField headerFieldPrototype

comparables

private List<ComparableInfo> comparables
Constructor Detail

CompareFieldCreateModifier

public CompareFieldCreateModifier()
Method Detail

performModification

public void performModification(View view,
                                Object model,
                                Component component)
Generates the comparison fields

First the configured List of ComparableInfo instances are sorted based on their order property. Then if generateCompareHeaders is set to true, a HeaderField is created for each comparable using the headerFieldPrototype and the headerText given by the comparable. Finally for each field configured on the Group, a corresponding comparison field is generated for each comparable and adjusted to the binding object path given by the comparable in addition to suffixing the id and setting the readOnly property

Specified by:
performModification in interface ComponentModifier
Overrides:
performModification in class ComponentModifierBase
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.container.View, java.lang.Object, org.kuali.rice.krad.uif.core.Component)

performValueComparison

protected void performValueComparison(Group group,
                                      Component compareItem,
                                      Object model,
                                      String compareValueObjectBindingPath)
For each attribute field in the compare item, retrieves the field value and compares against the value for the main comparable. If the value is different, adds script to the field on ready event to add the change icon to the field and the containing group header

Parameters:
group - - group that contains the item and whose header will be highlighted for changes
compareItem - - the compare item being generated and to pull attribute fields from
model - - object containing the data
compareValueObjectBindingPath - - object path for the comparison item

getIdSuffix

protected String getIdSuffix(ComparableInfo comparable,
                             int index)
Generates an id suffix for the comparable item

If the idSuffix to use if configured on the ComparableInfo it will be used, else the given integer index will be used with an underscore

Parameters:
comparable - - comparable info to check for id suffix
index - - sequence integer
Returns:
String id suffix
See Also:
org.kuali.rice.krad.uif.modifier.ComparableInfo.getIdSuffix()

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()

getDefaultOrderSequence

public int getDefaultOrderSequence()
Indicates the starting integer sequence value to use for ComparableInfo instances that do not have the order property set

Returns:
int default sequence starting value

setDefaultOrderSequence

public void setDefaultOrderSequence(int defaultOrderSequence)
Setter for the default sequence starting value

Parameters:
defaultOrderSequence -

isGenerateCompareHeaders

public boolean isGenerateCompareHeaders()
Indicates whether a HeaderField should be created for each group of comparison fields

If set to true, for each group of comparison fields a header field will be created using the headerFieldPrototype configured on the modifier with the headerText property of the comparable

Returns:
boolean true if the headers should be created, false if no headers should be created

setGenerateCompareHeaders

public void setGenerateCompareHeaders(boolean generateCompareHeaders)
Setter for the generate comparison headers indicator

Parameters:
generateCompareHeaders -

getHeaderFieldPrototype

public HeaderField getHeaderFieldPrototype()
Prototype instance to use for creating the HeaderField for each group of comparison fields (if generateCompareHeaders is true)

Returns:
HeaderField header field prototype

setHeaderFieldPrototype

public void setHeaderFieldPrototype(HeaderField headerFieldPrototype)
Setter for the header field prototype

Parameters:
headerFieldPrototype -

getComparables

public List<ComparableInfo> getComparables()
List of ComparableInfo instances the compare fields should be generated for

For each comparable, a copy of the fields configured for the Group will be created for the comparison view

Returns:
List comparables to generate fields for

setComparables

public void setComparables(List<ComparableInfo> comparables)
Setter for the list of comparable info instances

Parameters:
comparables -


Copyright © 2004-2011 The Kuali Foundation. All Rights Reserved.