Package org.zkoss.xel

Interface VariableResolverX

All Superinterfaces:
VariableResolver

public interface VariableResolverX extends VariableResolver
An extension of 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.

Since:
5.0.0
Author:
tomyeh
  • Method Details

    • resolveVariable

      Object resolveVariable(XelContext ctx, Object base, Object name) throws XelException
      Resolves the the given variable on the given base object.

      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") is called then (where we assume the returned object in the previous call is foo).

      Parameters:
      ctx - the context of this evaluation
      base - 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 resolve
      Throws:
      XelException