Class PropertyReplacer
- All Implemented Interfaces:
Serializable,Cloneable,Copyable,DictionaryBean,UifDictionaryBean
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:
invalid input: '<'bean parent="PropertyReplacer" p:propertyName="control"
p:condition="field1 eq '10985'" p:replacement-ref="RadioControl"/>
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 name="propertyReplacers">
<list>
<bean parent="PropertyReplacer" p:propertyName="control"
p:condition="field1 eq '10985'" p:replacement-ref="RadioControl"/>
<bean parent="PropertyReplacer" p:propertyName="control"
p:condition="field1 eq '11456'" p:replacement-ref="CheckboxControl"/>
</list>
</property>
</pre>
Property replacers may be used to substitute primitive properties as well, such as Strings
- Author:
- Kuali Rice Team (rice.collab@kuali.org)
- See Also:
-
Field Summary
Fields inherited from class org.kuali.rice.krad.datadictionary.DictionaryBeanBase
componentCode, namespaceCode -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcompleteValidation(ValidationTrace tracer) Validates different requirements of component compiling a series of reports detailing information on errors found in the component.Gives the expression that should be evaluated to determine whether or not the property replacement should be madeReturns a list of nested componentsName of the property on the Component the property replacer is associated with that will be set when the condition for the replacer succeedsGives the Object that should be used to set the property value if the replacers condition evaluates to truevoidsetCondition(String condition) Setter for the replacement conditionvoidsetPropertyName(String propertyName) Setter for the property name that will be setvoidsetReplacement(Object replacement) Setter for the replacement ObjectMethods inherited from class org.kuali.rice.krad.datadictionary.uif.UifDictionaryBeanBase
getExpressionGraph, getPropertyExpression, getPropertyExpressions, setExpressionGraph, setPropertyExpressionsMethods inherited from class org.kuali.rice.krad.datadictionary.DictionaryBeanBase
clone, copy, dataDictionaryPostProcessing, getComponentCode, getNamespaceCode, setComponentCode, setNamespaceCodeMethods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.kuali.rice.krad.datadictionary.DictionaryBean
dataDictionaryPostProcessing, getComponentCode, getNamespaceCode
-
Constructor Details
-
PropertyReplacer
public PropertyReplacer()
-
-
Method Details
-
getNestedComponents
Returns a list of nested componentsAll nested components will be returned in the list. Current assumption is that
PropertyReplacercan only contain aComponent,ListorMapfor nested components- Returns:
- nested components
-
getPropertyName
Name of the property on the Component the property replacer is associated with that will be set when the condition for the replacer succeedsNote 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
Setter for the property name that will be set- Parameters:
propertyName-
-
getCondition
Gives the expression that should be evaluated to determine whether or not the property replacement should be madeExpression 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 placeNote the value does not need to contain the expression placeholder @{}
- Returns:
- expression that should be evaluated
- See Also:
-
setCondition
Setter for the replacement condition- Parameters:
condition-
-
getReplacement
Gives the Object that should be used to set the property value if the replacers condition evaluates to trueNote 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
Setter for the replacement Object- Parameters:
replacement-
-
completeValidation
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
-