Class DelegatingVariableMapper

java.lang.Object
jakarta.el.VariableMapper
org.omnifaces.el.DelegatingVariableMapper

public class DelegatingVariableMapper extends VariableMapper

A variable mapper which holds the variables of one tag file invocation on top of a wrapped one.

A variable can be declared, which marks it as a tag attribute of that tag file invocation, or set, which is the ordinary variable mapper contract as used by <c:set> and <ui:param>. Only a declared variable is shielded from a nested tag file invocation, and only a declared variable also remembers the value which it inherited at the moment of declaring, its boundary value.

A nested instance therefore treats an inherited value as not inherited when it equals either the declared value or the boundary value of an enclosing instance. Both are looked up through the wrapped mapper under a prefixed name, so that they are also found when the Faces implementation puts its own variable mapper in between, which Mojarra does as soon as the nested tag file is passed an attribute of its own. The boundary value is what makes this work on MyFaces as well, whose variable mapper is dynamic and answers for the tag file which is currently being applied.

Since:
2.1
Author:
Arjan Tijms.
  • Constructor Details

    • DelegatingVariableMapper

      public DelegatingVariableMapper(VariableMapper wrapped)
      Construct delegating variable mapper.
      Parameters:
      wrapped - The variable mapper to be wrapped.
  • Method Details

    • resolveVariable

      public ValueExpression resolveVariable(String name)
      Specified by:
      resolveVariable in class VariableMapper
    • resolveWrappedVariable

      public ValueExpression resolveWrappedVariable(String name)
      Returns the value which this mapper inherits for the given name, or null when that value is merely the declaration of an enclosing mapper and therefore not inherited at all.
      Parameters:
      name - Name of the variable.
      Returns:
      The inherited value, or null when there is none.
    • declareVariable

      public ValueExpression declareVariable(String name, ValueExpression expression)
      Declares the given name as a tag attribute of the tag file invocation which this mapper represents, remembering the value which it inherits at this moment, so that a nested tag file invocation can recognize the declaration as not being its own.
      Parameters:
      name - Name of the variable.
      expression - Value expression of the variable.
      Returns:
      The previous value expression of the variable.
    • setVariable

      public ValueExpression setVariable(String name, ValueExpression expression)
      Specified by:
      setVariable in class VariableMapper