public interface ExpressionEvaluator
Used within the UI framework to allow conditional logic to be configured through the XML which can alter the values of component properties
Modifier and Type | Field and Description |
---|---|
static String |
EMBEDDED_PROPERTY_NAME_ADD_INDICATOR
Indicator that can be added to a property name to indicate the expression result should be added to the
property (assumed to be a collection) instead of replaced
|
Modifier and Type | Method and Description |
---|---|
boolean |
containsElPlaceholder(String value)
Indicates whether or not the given string contains the el placeholder
(begin and end delimiters)
|
Object |
evaluateExpression(Map<String,Object> evaluationParameters,
String expression)
Evaluates the given el expression against the content object and
parameters, and returns the result of the evaluation
|
void |
evaluateExpressionsOnConfigurable(View view,
UifDictionaryBean expressionConfigurable,
Map<String,Object> evaluationParameters)
Evaluates any el expressions that are found as a string property value
for the object
|
String |
evaluateExpressionTemplate(Map<String,Object> evaluationParameters,
String expressionTemplate)
Evaluates the given expression template string against the context object
and map of parameters
|
void |
evaluatePropertyExpression(View view,
Map<String,Object> evaluationParameters,
UifDictionaryBean expressionConfigurable,
String propertyName,
boolean removeExpression)
Evaluates the configured expression for the given property name (if not exists) on the given configurable
|
List<String> |
findControlNamesInExpression(String exp)
Find the control names (ie, propertyNames) used in the passed in expression
|
void |
initializeEvaluationContext(Object contextObject)
Initializes the expression context for the given expression context object
|
String |
parseExpression(String exp,
List<String> controlNames,
Map<String,Object> context)
Takes in an expression and a list to be filled in with names(property names)
of controls found in the expression.
|
void |
populatePropertyExpressionsFromGraph(UifDictionaryBean expressionConfigurable,
boolean buildRefreshGraphs)
Pulls expressions within the expressionConfigurable's expression graph and moves them to the property
expressions
map for the expressionConfigurable or a nested expressionConfigurable (for the case of nested expression property
names)
|
String |
replaceBindingPrefixes(View view,
Object object,
String expression)
Adjusts the property expressions for a given object
|
static final String EMBEDDED_PROPERTY_NAME_ADD_INDICATOR
void initializeEvaluationContext(Object contextObject)
The object given here will form the default context for expression terms (terms without any variable prefix)
contextObject
- instance of an Objectvoid evaluateExpressionsOnConfigurable(View view, UifDictionaryBean expressionConfigurable, Map<String,Object> evaluationParameters)
Using reflection the properties for the object are retrieved and if of
String
type the corresponding value is retrieved. If the
value is not empty and contains the el placeholder see
containsElPlaceholder(String)
then the expression is evaluated
using the given context object and parameters. The evaluated string is
then set as the new property value, or in the case of a template
(expression contained within a literal string), the expression part is
replaced in the property value.
In addition to evaluating any property expressions, any configured
PropertyReplacer
for the object are also evaluated and if a
match occurs those property replacements are made
view
- view instance being renderedexpressionConfigurable
- object whose properties should be checked for expressions
and evaluatedevaluationParameters
- map of parameters that may appear in expressions, the map
key gives the parameter name that may appear in the expression, and the map value is the object that expression
should evaluate against when that name is foundString evaluateExpressionTemplate(Map<String,Object> evaluationParameters, String expressionTemplate)
If the template string contains one or more el placeholders (see
containsElPlaceholder(String)
), the expression contained within
the placeholder will be evaluated and the corresponding value will be
substituted back into the property value where the placeholder occurred.
If no placeholders are found, the string will be returned unchanged
evaluationParameters
- map of parameters that may appear in expressions, the map
key gives the parameter name that may appear in the expression, and the map value is the object that expression
should evaluate against when that name is foundexpressionTemplate
- string that should be evaluated for el expressionsvoid evaluatePropertyExpression(View view, Map<String,Object> evaluationParameters, UifDictionaryBean expressionConfigurable, String propertyName, boolean removeExpression)
view
- view instance the configurable is associated with, used to adjust binding prefixesevaluationParameters
- map that will be exposed as EL parametersexpressionConfigurable
- configurable object to pull and evaluate the expression onpropertyName
- name of the property whose expression should be evaluatedremoveExpression
- boolean that indicates whether the expression should be removed after evaluationObject evaluateExpression(Map<String,Object> evaluationParameters, String expression)
The given expression string is assumed to be one el expression and should not contain the el placeholders. The returned result depends on the evaluation and what type is returns, for instance a boolean will be return for a boolean expression, or a string for string expression
evaluationParameters
- map of parameters that may appear in expressions, the map
key gives the parameter name that may appear in the expression, and the map value is the object that expression
should evaluate against when that name is foundexpression
- el expression to evaluateboolean containsElPlaceholder(String value)
value
- String to check for contained placeholdersUifConstants.EL_PLACEHOLDER_PREFIX
,
UifConstants.EL_PLACEHOLDER_SUFFIX
String replaceBindingPrefixes(View view, Object object, String expression)
The UifConstants.NO_BIND_ADJUST_PREFIX
prefix will be removed
as this is a placeholder indicating that the property is directly on the form.
The UifConstants.FIELD_PATH_BIND_ADJUST_PREFIX
prefix will be replaced by
the object's field path - this is only applicable to DataFields. The
UifConstants.DEFAULT_PATH_BIND_ADJUST_PREFIX
prefix will be replaced
by the view's default path if it is set.
view
- the parent view of the objectobject
- Object to adjust property expressions onexpression
- The expression to adjustvoid populatePropertyExpressionsFromGraph(UifDictionaryBean expressionConfigurable, boolean buildRefreshGraphs)
Expressions that are configured on properties and pulled out by the org.kuali.rice.krad.uif.util.UifBeanFactoryPostProcessor
and put in the UifDictionaryBean.getExpressionGraph()
for the bean
that is
at root (non nested) level. Before evaluating the expressions, they need to be moved to the
UifDictionaryBean.getPropertyExpressions()
map for the
expressionConfigurable that
property
is on.
expressionConfigurable
- expressionConfigurable instance to process expressions forbuildRefreshGraphs
- indicates whether the expression graphs for component refresh should be builtString parseExpression(String exp, List<String> controlNames, Map<String,Object> context)
This method returns a js expression which can be executed on the client to determine if the original exp was satisfied before interacting with the server - ie, this js expression is equivalent to the one passed in.
There are limitations on the Spring expression language that can be used as this method. It is only used to parse expressions which are valid case statements for determining if some action/processing should be performed. ONLY Properties, comparison operators, booleans, strings, matches expression, and boolean logic are supported. Server constants and calls will be evaluated early. The isValueEmpty, listContains, and emptyList custom KRAD functions, however, will be converted to a js equivalent function. Properties must be a valid property on the form, and should have a visible control within the view.
Example valid exp: "account.name == 'Account Name'"
exp
- the expression to convert to a js conditioncontrolNames
- the list to populate with control names found in the expression (these may later be used
to add js change handlers)List<String> findControlNamesInExpression(String exp)
exp
- the expression to searchCopyright © 2005–2016 The Kuali Foundation. All rights reserved.