You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by Ed Yu <ek...@asgnet.psc.sc.edu> on 2002/07/15 16:42:05 UTC

$toolLoader problem (Was HTML escape sequence filtering (is there a tool for that?))

Thanks. Here is my findings:

Using the toolbox.xml to define the tool works, but using the
$toolLoader tool does not:

  <tool>
    <key>xmlTool</key>
    <class>org.apache.velocity.anakia.Escape</class>
  </tool>

Here is the code:

#set($beginTag = "<font color='blue'>")
#set($endTag = "</font>")

$beginTag
See blue?	## This produces color blue
$endTag

<hr>
$xmlTool.getText($beginTag)
See blue with escape?	## This does not produce blue, so far so good!
$xmlTool.getText($endTag)
<hr>

$toolLoader("xmltool","org.apache.velocity.anakia.Escape") ## This seems
to work
$xmltool.getText($beginTag) ## This does not work
See blue with escape?
$xmltool.getText($endTag) ## This does not work

## The above code outputs
org.apache.velocity.tools.tools.ToolLoader@6d2702("xmltool","org.apache.
velocity.anakia.Escape") $xmltool.getText($beginTag) See blue with
escape? $xmltool.getText($endTag)

## In the log file
2002-07-15 10:36:05 - /VelocityStrutsTest:  Velocity   [warn]
org.apache.velocity.runtime.exception.ReferenceException: reference :
template = /t.vm [line 33,column 1] : $xmltool.getText($beginTag) is not
a valid reference.
2002-07-15 10:36:05 - /VelocityStrutsTest:  Velocity   [warn]
org.apache.velocity.runtime.exception.ReferenceException: reference :
template = /t.vm [line 35,column 1] : $xmltool.getText($endTag) is not a
valid reference.

-----Original Message-----
From: Geir Magnusson Jr. [mailto:geirm@adeptra.com]
Sent: Monday, July 15, 2002 10:00 AM
To: Velocity Developer's List
Subject: Re: HTML escape sequence filtering (is there a tool for that?)


On 7/15/02 9:43 AM, "Ed Yu" <ek...@asgnet.psc.sc.edu> wrote:

> I'm looking into JSP migration to Velocity. There is one feature that
> the <bean:write ... filter="true"> tag offer, the ability to filer
> special html characters (<, >, &, etc...). Currently is there a "tool"
> to perform such filtering?
> 

Being fundamentally lazy, I just tend to do this :


 vc.put("xmltool", new org.apache.velocity.anakia.Escape());


:)
-- 
Geir Magnusson Jr. 
Research & Development, Adeptra Inc.
geirm@adeptra.com
+1-203-247-1713



--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: $toolLoader problem (Was HTML escape sequence filtering (is there a tool for that?))

Posted by Nathan Bubna <na...@esha.com>.
Ed said:
> $toolLoader("xmltool","org.apache.velocity.anakia.Escape") ## This seems
> to work
...
> ## The above code outputs
> org.apache.velocity.tools.tools.ToolLoader@6d2702("xmltool","org.apache.
> velocity.anakia.Escape")
...

try  #set( $xmltool =
$toolLoader.load("org.apache.velocity.anakia.Escape") )

Nathan Bubna
nathan@esha.com


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>