Velocity
  1. Velocity
  2. VELOCITY-146

Macros not evaluated on the first attempt with #parse

    Details

    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.5
    • Fix Version/s: 1.6
    • Component/s: Engine
    • Labels:
      None
    • Environment:
      Operating System: All
      Platform: PC

      Description

      I have noticed that sometimes macros do not get evaluated after Velocity has
      just been started. A subsequent request for the same resource produces a valid
      document, where macros are now correctly evaluated.

      Here's an example: I have a WAP-Mail webapp, which runs on Tomcat 3.3a. It uses
      Velocity to render the content, and the Velocity versions I have used are 1.2-
      dep, 1.3-dep and 1.3.1-dep. This problem occurs with all of these versions.

      The first request should produce a message list (there's an autologin feature,
      so the message list page is the first one being accessed). Here's the most
      relevant part of the content:

      ------------------------------------------------------------------------------

      <p>Folder: INBOX<br/></p>

      <p>
      <br/><b>Date: 05.03 11:16</b>
      <br/>Sender: John Doe
      <br/>Subject: <a href="/wapmail/message/show/

        Activity

        Mark Thomas made changes -
        Workflow Default workflow, editable Closed status [ 12551912 ] jira [ 12552689 ]
        Mark Thomas made changes -
        Workflow jira [ 12325021 ] Default workflow, editable Closed status [ 12551912 ]
        Will Glass-Husain made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Henning Schmiedehausen made changes -
        Component/s Source [ 12310214 ]
        Component/s Engine [ 12311337 ]
        Bugzilla Id 17669
        Will Glass-Husain made changes -
        Component/s Source [ 12310214 ]
        Fix Version/s 1.6 [ 12310290 ]
        Bugzilla Id 17669
        Fix Version/s 1.5 [ 12310253 ]
        Component/s Build [ 12310212 ]
        Will Glass-Husain made changes -
        Bugzilla Id 17669
        Summary Macros not evaluated on the first attempt Macros not evaluated on the first attempt with #parse
        Will Glass-Husain made changes -
        Fix Version/s 1.5 [ 12310253 ]
        Environment Operating System: All
        Platform: PC
        Operating System: All
        Platform: PC
        Bugzilla Id 17669
        Assignee Velocity-Dev List [ velocity-dev@jakarta.apache.org ]
        Description I have noticed that sometimes macros do not get evaluated after Velocity has
        just been started. A subsequent request for the same resource produces a valid
        document, where macros are now correctly evaluated.

        Here's an example: I have a WAP-Mail webapp, which runs on Tomcat 3.3a. It uses
        Velocity to render the content, and the Velocity versions I have used are 1.2-
        dep, 1.3-dep and 1.3.1-dep. This problem occurs with all of these versions.

        The first request should produce a message list (there's an autologin feature,
        so the message list page is the first one being accessed). Here's the most
        relevant part of the content:

        ------------------------------------------------------------------------------

            <p>Folder: INBOX<br/></p>

              <p>
              <br/><b>Date: 05.03 11:16</b>
              <br/>Sender: John Doe
              <br/>Subject: <a href="/wapmail/message/show/;jsessionid=rfy548xsi1?
        page=1&#038;index=0&#038;offset=0&#038;t=1046861606588">Re: test</a>
              <br/>
            </p>

            #newMessageButton("Compose a new message")
            #logoutButton("Logout")

        ------------------------------------------------------------------------------

        The subsequent call produces the following content:

        ------------------------------------------------------------------------------

            <p>Folder: INBOX<br/></p>

              <p>
              <br/><b>Date: 05.03 11:16</b>
              <br/>Sender: John Doe
              <br/>Subject: <a href="/wapmail/message/show/;jsessionid=26fqhgxt01?
        page=1&#038;index=0&#038;offset=0&#038;t=1046861641709">Re: test</a>
              <br/>
            </p>

                  <p>
              <anchor>&#62; Compose a new message
                <go href="/wapmail/editor/new/;jsessionid=26fqhgxt01">
                  <postfield name="t" value="1046861641709"/>
                </go>
              </anchor>
            </p>
                  <p>
              <anchor>&#60; Logout
                <go href="/wapmail/entry/logout/;jsessionid=26fqhgxt01">
                  <postfield name="t" value="1046861641709"/>
                </go>
              </anchor>
            </p>
           
        -------------------------------------------------------------------------------

        For some reason, #newMessageButton and #logoutButton -macros do not get
        evaluated when the first request is processed. Friends of mine have also
        reported similar behaviour in their applications.

        Is there some kind of "lazy initialization" in macro processing or is this a
        bug?
        I have noticed that sometimes macros do not get evaluated after Velocity has
        just been started. A subsequent request for the same resource produces a valid
        document, where macros are now correctly evaluated.

        Here's an example: I have a WAP-Mail webapp, which runs on Tomcat 3.3a. It uses
        Velocity to render the content, and the Velocity versions I have used are 1.2-
        dep, 1.3-dep and 1.3.1-dep. This problem occurs with all of these versions.

        The first request should produce a message list (there's an autologin feature,
        so the message list page is the first one being accessed). Here's the most
        relevant part of the content:

        ------------------------------------------------------------------------------

            <p>Folder: INBOX<br/></p>

              <p>
              <br/><b>Date: 05.03 11:16</b>
              <br/>Sender: John Doe
              <br/>Subject: <a href="/wapmail/message/show/
        Fix Version/s 1.4 [ 12310249 ]
        Jeff Turner made changes -
        Field Original Value New Value
        issue.field.bugzillaimportkey 17669 12315016
        Sami Leino created issue -

          People

          • Assignee:
            Unassigned
            Reporter:
            Sami Leino
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development