velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Geir Magnusson Jr." <>
Subject Re: EventCartridge questions
Date Sat, 12 Oct 2002 02:47:42 GMT
On 10/11/02 10:06 AM, "Kent Johnson" <> wrote:

> Hello,
> I am using a ReferenceInsertionEventHandler and finding some
> unexpected behavior. Is this the way it is supposed to work?
> - The reference argument passed to referenceFilter() includes the $
> and {} used in the template. So in the filter I have to check for
> "$floobie" and "${floobie}" if I want to special case the handling
> for $floobie. This differs from which just looks
> for "floobie" (and doesn't work).

Then something broke, somewhere.  The EventExample did work.

> - The ReferenceInsertionEventHandler is called from a statement like
> #set ($floobie = "$floobie and $gobble")

Yes, because it is rendering $floobie and $gobble.
> I guess that internally the quoted string is parsed like a template
> and output to a stream, so the ReferenceInsertionEventHandler is
> called. I found this behavior surprising. If it is correct I suggest
> a clarification in the docs, which now state "A
> ReferenceInsertionEventHandler allows the developer to intercept each
> write of a reference ($foo) value to the output stream".
> The reason I care about this second item is, I am building a string
> in a reference by concatenating. My ReferenceInsertionEventHandler is
> substituting XML entity escapes for <>&"' . Since the concatenation
> triggers the event handler, the characters get escaped multiple
> times. Not good!

This is a good point.  I have a good idea how to solve too...
> My workaround was to create a special variable to concatenate into
> which is not processed by the event handler. Which is how I found the
> first problem...
> A better solution for me would be a string concatenation operator, or
> not firing the EventCartridge from a #set directive.

Yes, that would be the key thing, and that's the solution I'll put in.

Geir Magnusson Jr.                                    +1-203-355-2219 (w)
Adeptra Inc.                                         +1-203-247-1713 (m)

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message