You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by "Ståle Undheim (JIRA)" <ji...@apache.org> on 2006/04/11 10:06:25 UTC

[jira] Updated: (VELOCITY-437) Intercept output of objects

     [ http://issues.apache.org/jira/browse/VELOCITY-437?page=all ]

Ståle Undheim updated VELOCITY-437:
-----------------------------------

    Attachment: valuewriter.patch

This patch when applied to Velocity 1.4 release will add support for a ValueWriter.

Changes made:
RuntimeConstants.java:
New property added: "valuewriter.classes"

RuntimeServices.java:
New method: getValueWriters();

RuntimeInstances.java:
New instance variable: valueWriters
New method: initializeValueWritters
* This method is run with the other intializers and will load the ValueWriters from the "valeuewriter.classes" configuration parameter. It creates instances, checks that they implement ValueWriter, run initialize on them and add them to the valueWriters list.

ASTReference:
I couldn't figure out where I could change this in the jjt file, so I changed ASTReference directly instead. The render method was changed so that before it checked for null, it ran through all ValueWriters, and checked if any of them could write the object. If a ValueWriter could write the object, escPrefixes will be added to the stream as normal, and the ValueWriter will have an opportunity to write the object out to the writer. 

New interface: ValueWriter
This is the interface you implement if you want to handle certain objects in a specific way rather than just have toString run on them.

> Intercept output of objects
> ---------------------------
>
>          Key: VELOCITY-437
>          URL: http://issues.apache.org/jira/browse/VELOCITY-437
>      Project: Velocity
>         Type: New Feature

>     Versions: 1.4
>     Reporter: Ståle Undheim
>     Priority: Minor
>  Attachments: valuewriter.patch
>
> Currently, all reference objects in a Velocity template file are put out using the objects toString method, with no means to control this mechanism. I propose to change this by having interceptors that can pick up variables before they are run .toString on, and write them using their own means instead.
> If I figure out how to attach files to this after posting, I will add a patch with all the code necessary to implement this.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-dev-help@jakarta.apache.org