Velocity
  1. Velocity
  2. VELOCITY-565

EvaluateContext does not take account of inner.localContext

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.6
    • Component/s: None
    • Labels:
      None

      Description

      the following vtl does not render what is, IMHO, expected :

      #macro(testEval $expr)

      #foreach($value in ["val1", "val2"])
      value is : #evaluate( $expr )
      #end
      #end

      #testEval( "$

      {value}" )

      renders :

      value is : ${value}

      value is : $

      {value}

      The reason is that EvaluateContext ctor assigns 'inner.getBaseContext()'
      to instance variable 'innerContext', and getBaseContext() does not
      return VMContext localContext refs (of the #foreach directive).

      Changing the EvaluateContext ctor so that 'innerContext' is set to
      'inner' allow velocity to render the right result :

      value is : val1
      value is : val2

      But I'm not sure this would be a correct fix, should the VMContext
      return all current refs ? Could you tell me what the normal behavior is
      and what is the way all that stuff sould work ?

      Etienne Massip

      1. EvaluateContext.java
        10 kB
        Etienne Massip
      2. evalvmcontext.patch
        3 kB
        Etienne Massip

        Activity

        Will Glass-Husain created issue -
        Etienne Massip made changes -
        Field Original Value New Value
        Description

        ---------- Forwarded message ----------
        From: Massip, Etienne <Etienne.Massip@saint-gobain.com>
        Date: Sep 13, 2007 1:32 AM
        Subject: EvaluateContext : does not take account of inner.localContext
        To: dev@velocity.apache.org

        Hello,

        the following vtl does not render what is, IMHO, expected :

        #macro(testEval $expr)

            #foreach($value in ["val1", "val2"])
                value is : #evaluate( $expr )
            #end
        #end

        #testEval( "${value}" )

        renders :

        value is : ${value}
        value is : ${value}

        The reason is that EvaluateContext ctor assigns 'inner.getBaseContext()'
        to instance variable 'innerContext', and getBaseContext() does not
        return VMContext localContext refs (of the #foreach directive).

        Changing the EvaluateContext ctor so that 'innerContext' is set to
        'inner' allow velocity to render the right result :

        value is : val1
        value is : val2

        But I'm not sure this would be a correct fix, should the VMContext
        return all current refs ? Could you tell me what the normal behavior is
        and what is the way all that stuff sould work ?

        Aside, I noticed in 1.6 UG documentation, that the example for #evaluate
        directive taking a reference parameter uses the #include directive.

        Thank you !

        Etienne Massip

        the following vtl does not render what is, IMHO, expected :

        #macro(testEval $expr)

            #foreach($value in ["val1", "val2"])
                value is : #evaluate( $expr )
            #end
        #end

        #testEval( "${value}" )

        renders :

        value is : ${value}
        value is : ${value}

        The reason is that EvaluateContext ctor assigns 'inner.getBaseContext()'
        to instance variable 'innerContext', and getBaseContext() does not
        return VMContext localContext refs (of the #foreach directive).

        Changing the EvaluateContext ctor so that 'innerContext' is set to
        'inner' allow velocity to render the right result :

        value is : val1
        value is : val2

        But I'm not sure this would be a correct fix, should the VMContext
        return all current refs ? Could you tell me what the normal behavior is
        and what is the way all that stuff sould work ?

        Etienne Massip

        Etienne Massip made changes -
        Attachment EvaluateContext.java [ 12365977 ]
        Etienne Massip made changes -
        Attachment evalvmcontext.patch [ 12366087 ]
        Will Glass-Husain made changes -
        Resolution Fixed [ 1 ]
        Status Open [ 1 ] Resolved [ 5 ]
        Mark Thomas made changes -
        Workflow jira [ 12413035 ] Default workflow, editable Closed status [ 12551341 ]
        Mark Thomas made changes -
        Workflow Default workflow, editable Closed status [ 12551341 ] jira [ 12552054 ]

          People

          • Assignee:
            Will Glass-Husain
            Reporter:
            Will Glass-Husain
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development