public final class ExpressionInspector extends Object
This class contains methods that inspect expressions to reveal information about them.
Determine the bean instance and the property value behind a ValueExpression
.
ValueExpression valueExpression = component.getValueExpression("value"); ValueReference valueReference = ExpressionInspector.getValueReference(context.getELContext(), valueExpression); Object bean = methodReference.getBase(); Object property = methodReference.getProperty();
Determine the bean instance and the concrete getter Method
behind a ValueExpression
.
ValueExpression valueExpression = component.getValueExpression("value"); MethodReference methodReference = ExpressionInspector.getMethodReference(context.getELContext(), valueExpression); Object bean = methodReference.getBase(); Method method = methodReference.getMethod();
Determine the bean instance and the concrete action Method
behind a MethodExpression
.
MethodExpression methodExpression = commandComponent.getActionExpression(); MethodReference methodReference = ExpressionInspector.getMethodReference(context.getELContext(), methodExpression); Object bean = methodReference.getBase(); Method method = methodReference.getMethod();
Modifier and Type | Method and Description |
---|---|
static MethodReference |
getMethodReference(ELContext context,
MethodExpression methodExpression)
Gets a MethodReference from a MethodExpression.
|
static MethodReference |
getMethodReference(ELContext context,
ValueExpression valueExpression)
Gets a MethodReference from a ValueExpression.
|
static ValueReference |
getValueReference(ELContext context,
ValueExpression valueExpression)
Gets the ValueReference from a ValueExpression, without any checks whether the property is actually
a property or if it isn't a "MethodSuffix".
|
public static ValueReference getValueReference(ELContext context, ValueExpression valueExpression)
This is also a workaround for the fact that a ValueReference can't be obtained from a TagValueExpression in JSF 2.x (since it doesn't implement getValueReference and its super class just returns null).
context
- the context of this evaluationvalueExpression
- the value expression being evaluatedpublic static MethodReference getMethodReference(ELContext context, ValueExpression valueExpression)
Note that in case the expression refers to a method, the method reference contains the method with the name the expression refers to, with a matching number of arguments and a match of types. Overloads with the same amount of parameters are supported, but if the actual arguments match with the types of multiple overloads (e.g. actual argument Long, overloads for Number and Long) a random method will be chosen.
context
- the context of this evaluationvalueExpression
- the value expression being evaluatedpublic static MethodReference getMethodReference(ELContext context, MethodExpression methodExpression)
context
- the context of this evaluationmethodExpression
- the method expression being evaluatedCopyright © 2012–2019 OmniFaces. All rights reserved.