velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kent Johnson <>
Subject EventCartridge questions
Date Fri, 11 Oct 2002 14:06:19 GMT

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).

- The ReferenceInsertionEventHandler is called from a statement like
#set ($floobie = "$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!

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.


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

View raw message