Velocity
  1. Velocity
  2. VELOCITY-260

patch to event handling configuration / new event handlers

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.5
    • Fix Version/s: 1.5
    • Component/s: Engine
    • Labels:
      None
    • Environment:
      Operating System: other
      Platform: Other

      Description

      Substantial patch to event handling infrastructure. See readme.txt and
      discussion on velocity-dev list for more detail. Key changes:

      (1) Event handlers can be registered in the velocity-properties, e.g.

      eventhandler.referenceinsertion.class =
      org.apache.velocity.app.event.implement.EscapeXMLEntities

      (2) Multiple event handlers can be registered for a given type and are applied
      in a "filter" pattern. The specifics vary per event handler (documented in
      the JavaDocs). The following example would first enforce a relative path rule
      to included templates, and would then check to see if the template is actually
      available.

      eventhandler.include.class =
      org.apache.velocity.app.event.implement.IncludeRelativePath,org.apache.velocity
      .app.event.implement.IncludeNotFound

      (3) Event handlers have a new lifecycle. Before they are called they are
      initialized with a link to RuntimeServices. This allows the handlers to
      retrieve Velocity properties and to have access to a number of interesting
      system methods. Each event handler is also given the current context when it
      is called. This allows the template designer (or custom directives) to change
      the behavior of the event. A nice example of this is the EscapeXMLEntities
      reference insertion handler, which stops escaping HTML when an "ignoreEscape"
      flag is set in the context.

      (4) New implemented event handlers include:
      – EscapeXMLEntities (escapes HTML/XML & < > ")
      – IncludeNotFound
      – IncludeRelativePath
      – PrintExceptions

      Using these built-in event handlers, users can do useful things (e.g. escape
      HTML) with no extra coding just by configuring velocity.properties.

      (5) The patch is almost entirely backwards compatible. The old "attach the
      handler to the context" still works, although this results in a per-request
      rather than per-application lifecycle for the handler. One difference... the
      API for the event handlers has changed, and as such will require minor editing
      and recompilation of user code. (I think this is worth it). All tests (old
      and new) work.

      1. ASF.LICENSE.NOT.GRANTED--testcases.xml
        15 kB
        Will Glass-Husain
      2. ASF.LICENSE.NOT.GRANTED--testcases.xml
        15 kB
        Will Glass-Husain
      3. ASF.LICENSE.NOT.GRANTED--src.zip
        22 kB
        Will Glass-Husain
      4. ASF.LICENSE.NOT.GRANTED--about this patch.txt
        5 kB
        Will Glass-Husain
      5. ASF.LICENSE.NOT.GRANTED--includeevent.zip
        4 kB
        Will Glass-Husain
      6. ASF.LICENSE.NOT.GRANTED--event1.patch
        107 kB
        Will Glass-Husain

        Issue Links

          Activity

          Hide
          Will Glass-Husain added a comment -

          Created an attachment (id=11230)
          java patch

          Show
          Will Glass-Husain added a comment - Created an attachment (id=11230) java patch
          Hide
          Will Glass-Husain added a comment -

          Created an attachment (id=11231)
          zip file of test cases

          Show
          Will Glass-Husain added a comment - Created an attachment (id=11231) zip file of test cases
          Hide
          Will Glass-Husain added a comment -

          Created an attachment (id=11232)
          readme.txt

          Show
          Will Glass-Husain added a comment - Created an attachment (id=11232) readme.txt
          Hide
          Will Glass-Husain added a comment -
              • Bug 20342 has been marked as a duplicate of this bug. ***
          Show
          Will Glass-Husain added a comment - Bug 20342 has been marked as a duplicate of this bug. ***
          Hide
          Will Glass-Husain added a comment -

          Created an attachment (id=11233)
          zip of additional java files not in diff (sorry!)

          Show
          Will Glass-Husain added a comment - Created an attachment (id=11233) zip of additional java files not in diff (sorry!)
          Hide
          Will Glass-Husain added a comment -

          Created an attachment (id=11234)
          testcases.xml

          Show
          Will Glass-Husain added a comment - Created an attachment (id=11234) testcases.xml
          Hide
          Will Glass-Husain added a comment -

          Created an attachment (id=11235)
          testcases.xml

          Show
          Will Glass-Husain added a comment - Created an attachment (id=11235) testcases.xml
          Hide
          Will Glass-Husain added a comment -

          committed patch based on this one. revision #280189

          Show
          Will Glass-Husain added a comment - committed patch based on this one. revision #280189
          Hide
          Will Glass-Husain added a comment -

          patch was applied, this should have been resolved.

          Show
          Will Glass-Husain added a comment - patch was applied, this should have been resolved.
          Hide
          Henning Schmiedehausen added a comment -

          Close all resolved issues for Engine 1.5 release.

          Show
          Henning Schmiedehausen added a comment - Close all resolved issues for Engine 1.5 release.

            People

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

              Dates

              • Created:
                Updated:
                Resolved:

                Development