public interface VariableResolverX extends VariableResolver
VariableResolver to have more control to
resolve the variables.
With VariableResolver, VariableResolver.resolveVariable(java.lang.String)
is called to resolve a top-level variable (for example, ${a.b.c}
where a is a top-level variable).
With VariableResolverX, resolveVariable(XelContext, Object, Object)
is called to resolve not only top-level variables but also properties
(for example, ${a.b.c} where b and c
are properties).
If VariableResolverX is implemented, VariableResolver.resolveVariable(java.lang.String)
is ignored. In other words, EL evaluator always invoke
resolveVariable(XelContext, Object, Object).
Notice you have to follow the same rule to invoke the resolveVariable method.
And there is a method called Evaluators.resolveVariable(org.zkoss.xel.XelContext, org.zkoss.xel.VariableResolver, java.lang.Object, java.lang.Object)
that can be used to do the job.
| Modifier and Type | Method and Description |
|---|---|
Object |
resolveVariable(XelContext ctx,
Object base,
Object name)
Resolves the the given variable on the given base object.
|
resolveVariableObject resolveVariable(XelContext ctx, Object base, Object name) throws XelException
It resolves not only top-level variables but also properties.
For example, when resolving foo.duke,
resolveVariable(ctx, null, "foo") is called first.
And if it returns an non-null object,
resolveVariable(ctx, foo, "duke"),/code> is called then
(where we assume the returned object in the previous call is foo).
ctx - the context of this evaluationbase - the base object whose property value is to be returned,
or null to resolve a top-level variable.name - the name of the variable (or property) to resolveXelExceptionCopyright © 2018. All rights reserved.