org.kuali.rice.krad.uif.component
Class PropertyReplacer

java.lang.Object
  extended by org.kuali.rice.krad.datadictionary.DictionaryBeanBase
      extended by org.kuali.rice.krad.datadictionary.uif.UifDictionaryBeanBase
          extended by org.kuali.rice.krad.uif.component.PropertyReplacer
All Implemented Interfaces:
Serializable, DictionaryBean, UifDictionaryBean

public class PropertyReplacer
extends UifDictionaryBeanBase
implements Serializable

Configuration for replacing a property value based on a condition

A Component may be configured with one or more PropertyReplacer instances. Each defines a condition to evaluate during the apply model phase, and if that condition succeeds the property on the component given by getPropertyName(), will be replaced with the value given by getReplacement(). Conditions are defined using an expression language and may reference any variables available in the component's context.

Property replacers can be used to change out an entire Component or List/Map of Components. For example, based on a condition you might want to display a TextControl or RadioControl for an InputField. You can define the field with a text control, then include a property replacer as follows:

 

 
Note Component contains a List or property replacers which will be evaluated in the order contained within the list. So in the above example if we wanted to now add a further condition which sets the control to a checkbox, we would just add another property replacer bean.
   
 
 
 
     
   
 
Property replacers may be used to substitute primitive properties as well, such as Strings

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

Constructor Summary
PropertyReplacer()
           
 
Method Summary
 void completeValidation(ValidationTrace tracer)
          Validates different requirements of component compiling a series of reports detailing information on errors found in the component.
 String getCondition()
          Gives the expression that should be evaluated to determine whether or not the property replacement should be made
 List<Component> getNestedComponents()
          Returns a list of nested components
 String getPropertyName()
          Name of the property on the Component the property replacer is associated with that will be set when the condition for the replacer succeeds
 Object getReplacement()
          Gives the Object that should be used to set the property value if the replacers condition evaluates to true
 void setCondition(String condition)
          Setter for the replacement condition
 void setPropertyName(String propertyName)
          Setter for the property name that will be set
 void setReplacement(Object replacement)
          Setter for the replacement Object
 
Methods inherited from class org.kuali.rice.krad.datadictionary.uif.UifDictionaryBeanBase
getExpressionGraph, getPropertyExpression, getPropertyExpressions, getRefreshExpressionGraph, setExpressionGraph, setPropertyExpressions, setRefreshExpressionGraph
 
Methods inherited from class org.kuali.rice.krad.datadictionary.DictionaryBeanBase
getComponentCode, getNamespaceCode, setComponentCode, setNamespaceCode
 
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.datadictionary.DictionaryBean
getComponentCode, getNamespaceCode
 

Constructor Detail

PropertyReplacer

public PropertyReplacer()
Method Detail

getNestedComponents

public List<Component> getNestedComponents()
Returns a list of nested components

All nested components will be returned in the list. Current assumption is that PropertyReplacer can only contain a Component, List or Map for nested components

Returns:
nested components

getPropertyName

public String getPropertyName()
Name of the property on the Component the property replacer is associated with that will be set when the condition for the replacer succeeds

Note the property name must be readable/writable on the component. The property name may be nested, and include Map or List references.

Returns:
property name to set

setPropertyName

public void setPropertyName(String propertyName)
Setter for the property name that will be set

Parameters:
propertyName -

getCondition

public String getCondition()
Gives the expression that should be evaluated to determine whether or not the property replacement should be made

Expression follows SPEL and may access any model data along with any variables available in the context for the Component. The expression should evaluate to a boolean. If the resulting boolean is true, the object given by getReplacement() will be set as the value for the associated property on the component. If the resulting boolean is false, no action will take place

Note the value does not need to contain the expression placeholder @{}

Returns:
expression that should be evaluated
See Also:
ExpressionEvaluatorService, UifConstants.ContextVariableNames

setCondition

public void setCondition(String condition)
Setter for the replacement condition

Parameters:
condition -

getReplacement

public Object getReplacement()
Gives the Object that should be used to set the property value if the replacers condition evaluates to true

Note the configured Object must be valid for the type given by the property on the Component. Standard property editors will be used for setting the property value

Returns:
instance to set

setReplacement

public void setReplacement(Object replacement)
Setter for the replacement Object

Parameters:
replacement -

completeValidation

public void completeValidation(ValidationTrace tracer)
Validates different requirements of component compiling a series of reports detailing information on errors found in the component. Used by the RiceDictionaryValidator.

Parameters:
tracer - record of component's location


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