Escaping question

View: New views
16 Messages — Rating Filter:   Alert me  

Escaping question

by stevecoh1 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Using Velocity 1.6.2 I wish to output the string "#####".
In my template, I code it "\#\#\#\#\#"
It renders as \#\#\#\#\#.

What am I doing wrong?  Or how can I make it do what I want?

Steve Cohen

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@...
For additional commands, e-mail: user-help@...


Re: Escaping question

by Jason Tesser-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I would use the ecsapetool

Thanks,
Jason Tesser
dotCMS Lead Development Manager
1-305-858-1422


On Mon, Jul 20, 2009 at 3:07 PM, Steve Cohen <scohen@...> wrote:

> Using Velocity 1.6.2 I wish to output the string "#####".
> In my template, I code it "\#\#\#\#\#"
> It renders as \#\#\#\#\#.
>
> What am I doing wrong?  Or how can I make it do what I want?
>
> Steve Cohen
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@...
> For additional commands, e-mail: user-help@...
>
>

Re: Escaping question

by stevecoh1 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks.  This sounds like the right way to go, yet I currently have a
nice simple configuration based on 1.4.  The $esc.hash seems to be a 2.0
thing.  I don't use the tools now and it seems like a fairly heavy-duty
upgrade to fix such a small problem, involving configuration files, etc.
that I don't require now.   Is there another solution that lies within
the framework of Velocity itself?

Jason Tesser wrote:

> I would use the ecsapetool
>
> Thanks,
> Jason Tesser
> dotCMS Lead Development Manager
> 1-305-858-1422
>
>
> On Mon, Jul 20, 2009 at 3:07 PM, Steve Cohen <scohen@...> wrote:
>
>  
>> Using Velocity 1.6.2 I wish to output the string "#####".
>> In my template, I code it "\#\#\#\#\#"
>> It renders as \#\#\#\#\#.
>>
>> What am I doing wrong?  Or how can I make it do what I want?
>>
>> Steve Cohen
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@...
>> For additional commands, e-mail: user-help@...
>>
>>
>>    
>
>  


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@...
For additional commands, e-mail: user-help@...


Re: Escaping question

by stevecoh1 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Also, the Tools 2.0 documentation seems written from the point of view
that you're upgrading from Tools 1.4.  Since I don't currently configure
or use the Tools, I seem to be missing some key concepts.  I can't find
the Tools 1.4 documentation.

Steve Cohen wrote:

> Thanks.  This sounds like the right way to go, yet I currently have a
> nice simple configuration based on 1.4.  The $esc.hash seems to be a
> 2.0 thing.  I don't use the tools now and it seems like a fairly
> heavy-duty upgrade to fix such a small problem, involving
> configuration files, etc. that I don't require now.   Is there another
> solution that lies within the framework of Velocity itself?
>
> Jason Tesser wrote:
>> I would use the ecsapetool
>>
>> Thanks,
>> Jason Tesser
>> dotCMS Lead Development Manager
>> 1-305-858-1422
>>
>>
>> On Mon, Jul 20, 2009 at 3:07 PM, Steve Cohen <scohen@...>
>> wrote:
>>
>>  
>>> Using Velocity 1.6.2 I wish to output the string "#####".
>>> In my template, I code it "\#\#\#\#\#"
>>> It renders as \#\#\#\#\#.
>>>
>>> What am I doing wrong?  Or how can I make it do what I want?
>>>
>>> Steve Cohen
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@...
>>> For additional commands, e-mail: user-help@...
>>>
>>>
>>>    
>>
>>  
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@...
For additional commands, e-mail: user-help@...


Re: Escaping question

by stevecoh1 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Okay, I wrote too soon.  I now see the escape tool and its hash method
in tools 1.4.  My bad.

I still don't understand what, if anything, I need to do to configure my
application to use it.  My present configuation is done entirely in Java:

    private void init(ServletContext ctx) throws
VelocityInitializationException {
       
       
        this.engine.setProperty(
RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS,
          "org.apache.velocity.runtime.log.Log4JLogChute" );

        this.engine.setProperty("runtime.log.logsystem.log4j.logger",
                        "Velocity");
       
        this.engine.setProperty("velocimacro.library",
"/resources/VM_global_library.vm");
       
       
        this.engine.setProperty("resource.loader", "webapp");
        this.engine.setProperty("webapp.resource.loader.class",
                "org.apache.velocity.tools.view.servlet.WebappLoader");

       
this.engine.setApplicationAttribute("javax.servlet.ServletContext", ctx);


        try {
            this.engine.init();
        } catch (Exception e) {
            throw new VelocityInitializationException(e);  // my own class
        }
        logHelper.info("following is initialization output from velocity");
       
    }

I assume my configuration information would go in here somewhere, but
I'm not sure where, or if anything is necessary.

Is something necessary, or, assuming velocity-tools-1.4.jar is in
WEB-INF/lib, can I just start using $esc.hash without any other
configuration?

Steve Cohen wrote:

> Also, the Tools 2.0 documentation seems written from the point of view
> that you're upgrading from Tools 1.4.  Since I don't currently
> configure or use the Tools, I seem to be missing some key concepts.  I
> can't find the Tools 1.4 documentation.
>
> Steve Cohen wrote:
>> Thanks.  This sounds like the right way to go, yet I currently have a
>> nice simple configuration based on 1.4.  The $esc.hash seems to be a
>> 2.0 thing.  I don't use the tools now and it seems like a fairly
>> heavy-duty upgrade to fix such a small problem, involving
>> configuration files, etc. that I don't require now.   Is there
>> another solution that lies within the framework of Velocity itself?
>>
>> Jason Tesser wrote:
>>> I would use the ecsapetool
>>>
>>> Thanks,
>>> Jason Tesser
>>> dotCMS Lead Development Manager
>>> 1-305-858-1422
>>>
>>>
>>> On Mon, Jul 20, 2009 at 3:07 PM, Steve Cohen
>>> <scohen@...> wrote:
>>>
>>>  
>>>> Using Velocity 1.6.2 I wish to output the string "#####".
>>>> In my template, I code it "\#\#\#\#\#"
>>>> It renders as \#\#\#\#\#.
>>>>
>>>> What am I doing wrong?  Or how can I make it do what I want?
>>>>
>>>> Steve Cohen
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: user-unsubscribe@...
>>>> For additional commands, e-mail: user-help@...
>>>>
>>>>
>>>>    
>>>
>>>  
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@...
> For additional commands, e-mail: user-help@...
>
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@...
For additional commands, e-mail: user-help@...


Re: Escaping question

by stevecoh1 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Steve Cohen wrote:

...

(never mind any of what I wrote before, I have now boiled it down to one
hopefully intelligent question):


I am NOT using VelocityView but instantiating, configuring and
initializing a VelocityEngine in java code.  I don't use Velocity View.

Since I don't use VelocityView, and the documentation for Velocity Tools
assumes I do

(http://velocity.apache.org/tools/releases/1.4/generic/EscapeTool.html)
telling me this:

> *Toolbox Configuration Example*
>  
> <tool>
>   <key>esc</key>
>   <scope>application</scope>
>   <class>org.apache.velocity.tools.generic.EscapeTool</class>
> </tool>
>
how do I perform this same step in java code (i.e. what
applicationAttributes or runtime Properties must I set, in order for my
VelocityEngine to see the Tools generally or the EscapeTool in
particular (which is all I need)?

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@...
For additional commands, e-mail: user-help@...


Re: Escaping question

by stevecoh1 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Okay, I found THIS:

http://www.mailinglistarchive.com/velocity-user@.../msg00552.html

and it works, but I'd still rather load the tool at the time the Engine
is initialized, rather than have to put it in the context everywhere I
want to use it.  So what I'm really looking for is a way to do that.



Steve Cohen wrote:

>
> Steve Cohen wrote:
>
> ...
>
> (never mind any of what I wrote before, I have now boiled it down to
> one hopefully intelligent question):
>
>
> I am NOT using VelocityView but instantiating, configuring and
> initializing a VelocityEngine in java code.  I don't use Velocity View.
> Since I don't use VelocityView, and the documentation for Velocity
> Tools assumes I do
>
> (http://velocity.apache.org/tools/releases/1.4/generic/EscapeTool.html)
> telling me this:
>
>> *Toolbox Configuration Example*
>>      
>> <tool>
>>   <key>esc</key>
>>   <scope>application</scope>
>>   <class>org.apache.velocity.tools.generic.EscapeTool</class>
>> </tool>
>>
> how do I perform this same step in java code (i.e. what
> applicationAttributes or runtime Properties must I set, in order for
> my VelocityEngine to see the Tools generally or the EscapeTool in
> particular (which is all I need)?
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@...
> For additional commands, e-mail: user-help@...
>
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@...
For additional commands, e-mail: user-help@...


Re: Escaping question

by Nathan Bubna :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

#set( $hashes = '####' )
$hashes

single-quoted strings are not interpolated.

On Mon, Jul 20, 2009 at 12:07 PM, Steve Cohen<scohen@...> wrote:

> Using Velocity 1.6.2 I wish to output the string "#####".
> In my template, I code it "\#\#\#\#\#"
> It renders as \#\#\#\#\#.
>
> What am I doing wrong?  Or how can I make it do what I want?
>
> Steve Cohen
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@...
> For additional commands, e-mail: user-help@...
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@...
For additional commands, e-mail: user-help@...


Re: Escaping question

by Nathan Bubna :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

In VelocityTools 1.4, there is little support for auto-loading
GenericTools, i wouldn't bother.  Just create a context, add tool
instances that you want and then use the already available
context-chaining support in VelocityContext to use that "tool" context
as a base context for other ones.

In VelocityTools 2.0, you can just create a ToolManager and ask it for
a ToolContext (which you can use like a standard VelocityContext) via
the createContext() method.  Auto-loading definitely requires a
special context.

On Mon, Jul 20, 2009 at 1:53 PM, Steve Cohen<scohen@...> wrote:

>
> Steve Cohen wrote:
>
> ...
>
> (never mind any of what I wrote before, I have now boiled it down to one
> hopefully intelligent question):
>
>
> I am NOT using VelocityView but instantiating, configuring and initializing
> a VelocityEngine in java code.  I don't use Velocity View.
> Since I don't use VelocityView, and the documentation for Velocity Tools
> assumes I do
>
> (http://velocity.apache.org/tools/releases/1.4/generic/EscapeTool.html)
> telling me this:
>
>> *Toolbox Configuration Example*
>>
>> <tool>
>>  <key>esc</key>
>>  <scope>application</scope>
>>  <class>org.apache.velocity.tools.generic.EscapeTool</class>
>> </tool>
>>
> how do I perform this same step in java code (i.e. what
> applicationAttributes or runtime Properties must I set, in order for my
> VelocityEngine to see the Tools generally or the EscapeTool in particular
> (which is all I need)?
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@...
> For additional commands, e-mail: user-help@...
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@...
For additional commands, e-mail: user-help@...


Re: Escaping question

by Nathan Bubna :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Mon, Jul 20, 2009 at 5:51 PM, Nathan Bubna<nbubna@...> wrote:
> In VelocityTools 1.4, there is little support for auto-loading
> GenericTools, i wouldn't bother.  Just create a context, add tool
> instances that you want and then use the already available
> context-chaining support in VelocityContext to use that "tool" context
> as a base context for other ones.

just to clarify, since i just noticed you are creating a webapp.  you
could use the ServletToolboxManager in 1.4 to manage your tools
without using the VelocityViewServlet at all.  ask if you want more
info on that.

> In VelocityTools 2.0, you can just create a ToolManager and ask it for
> a ToolContext (which you can use like a standard VelocityContext) via
> the createContext() method.  Auto-loading definitely requires a
> special context.

oh, and in 2.0, you would not need to do any configuration.  just get
a ToolContext and go, tools are lazy-loaded when used, so all are
configured to be available by default.

> On Mon, Jul 20, 2009 at 1:53 PM, Steve Cohen<scohen@...> wrote:
>>
>> Steve Cohen wrote:
>>
>> ...
>>
>> (never mind any of what I wrote before, I have now boiled it down to one
>> hopefully intelligent question):
>>
>>
>> I am NOT using VelocityView but instantiating, configuring and initializing
>> a VelocityEngine in java code.  I don't use Velocity View.
>> Since I don't use VelocityView, and the documentation for Velocity Tools
>> assumes I do
>>
>> (http://velocity.apache.org/tools/releases/1.4/generic/EscapeTool.html)
>> telling me this:
>>
>>> *Toolbox Configuration Example*
>>>
>>> <tool>
>>>  <key>esc</key>
>>>  <scope>application</scope>
>>>  <class>org.apache.velocity.tools.generic.EscapeTool</class>
>>> </tool>
>>>
>> how do I perform this same step in java code (i.e. what
>> applicationAttributes or runtime Properties must I set, in order for my
>> VelocityEngine to see the Tools generally or the EscapeTool in particular
>> (which is all I need)?
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@...
>> For additional commands, e-mail: user-help@...
>>
>>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@...
For additional commands, e-mail: user-help@...


Re: Escaping question

by bluejoe-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I had the same question before, finally I still chose VelocityView. Since VelocityView is for webapp, I had to use MockServletContext  and MockServletConfig:

 public MyVelocityEngine(ServletContext servletContext, String velocityPropertiesFile) throws ServletException
 {
  MockServletConfig msc = new MockServletConfig();
  msc.addInitParameter("org.apache.velocity.properties",  velocityPropertiesFile);
  msc.addInitParameter("org.apache.velocity.tools.loadDefaults", "false");
  msc.setServletContext(servletContext);

  JeeConfig config = new JeeConfig(msc);
  _view = new VelocityView(config);
 }

MockServletContext msc = new MockServletContext(appRoot, new FileSystemResourceLoader());
MyVelocityEngine engine = new MyVelocityEngine(msc, "...");

Then, when I want to load tools from xml files, use VelocityView.configure():

 public void loadTools(File toolXml) throws FileNotFoundException,
   IOException
 {
  XmlFactoryConfiguration conf = new XmlFactoryConfiguration();
  conf.read(new FileInputStream(toolXml));

  _view.configure(conf);
 }

I am not sure if I am using Velocity in a good manner, but MyVelocityEngine works well. Maybe there are better ways:)

yours,
bluejoe

----- Original Message -----
From: "Steve Cohen" <scohen@...>
To: "Velocity Users List" <user@...>
Sent: Tuesday, July 21, 2009 5:51 AM
Subject: Re: Escaping question


> Okay, I found THIS:
>
> http://www.mailinglistarchive.com/velocity-user@.../msg00552.html
>
> and it works, but I'd still rather load the tool at the time the Engine
> is initialized, rather than have to put it in the context everywhere I
> want to use it.  So what I'm really looking for is a way to do that.
>
>
>
> Steve Cohen wrote:
>>
>> Steve Cohen wrote:
>>
>> ...
>>
>> (never mind any of what I wrote before, I have now boiled it down to
>> one hopefully intelligent question):
>>
>>
>> I am NOT using VelocityView but instantiating, configuring and
>> initializing a VelocityEngine in java code.  I don't use Velocity View.
>> Since I don't use VelocityView, and the documentation for Velocity
>> Tools assumes I do
>>
>> (http://velocity.apache.org/tools/releases/1.4/generic/EscapeTool.html)
>> telling me this:
>>
>>> *Toolbox Configuration Example*
>>>      
>>> <tool>
>>>   <key>esc</key>
>>>   <scope>application</scope>
>>>   <class>org.apache.velocity.tools.generic.EscapeTool</class>
>>> </tool>
>>>
>> how do I perform this same step in java code (i.e. what
>> applicationAttributes or runtime Properties must I set, in order for
>> my VelocityEngine to see the Tools generally or the EscapeTool in
>> particular (which is all I need)?
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@...
>> For additional commands, e-mail: user-help@...
>>
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@...
> For additional commands, e-mail: user-help@...
>

Re: Escaping question

by stevecoh1 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks, Nathan, that's probably the easiest way for this edge case.

Nathan Bubna wrote:

> #set( $hashes = '####' )
> $hashes
>
> single-quoted strings are not interpolated.
>
> On Mon, Jul 20, 2009 at 12:07 PM, Steve Cohen<scohen@...> wrote:
>  
>> Using Velocity 1.6.2 I wish to output the string "#####".
>> In my template, I code it "\#\#\#\#\#"
>> It renders as \#\#\#\#\#.
>>
>> What am I doing wrong?  Or how can I make it do what I want?
>>
>> Steve Cohen
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@...
>> For additional commands, e-mail: user-help@...
>>
>>
>>    
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@...
> For additional commands, e-mail: user-help@...
>
>
>
>  


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@...
For additional commands, e-mail: user-help@...


Re: Escaping question

by stevecoh1 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks, Nathan.  Although your single-quoting thing is the right answer
for this particular situation, this discussion did at least get me
thinking about the Tools, which I haven't used before.  They could
provide some value for me in other situations so it's good to learn
about them.  Therefore I am interested in more info about the
ServletToolboxManager.

My situation, you might possibly remember, is that of a webapp that is
not delivered as web pages.  I was googling around for information about
this earlier and came across one of my own posts that explains the
situation:
http://www.mail-archive.com/user@.../msg02079.html

Nathan Bubna wrote:

> On Mon, Jul 20, 2009 at 5:51 PM, Nathan Bubna<nbubna@...> wrote:
>  
>> In VelocityTools 1.4, there is little support for auto-loading
>> GenericTools, i wouldn't bother.  Just create a context, add tool
>> instances that you want and then use the already available
>> context-chaining support in VelocityContext to use that "tool" context
>> as a base context for other ones.
>>    
>
> just to clarify, since i just noticed you are creating a webapp.  you
> could use the ServletToolboxManager in 1.4 to manage your tools
> without using the VelocityViewServlet at all.  ask if you want more
> info on that.
>
>  
>> In VelocityTools 2.0, you can just create a ToolManager and ask it for
>> a ToolContext (which you can use like a standard VelocityContext) via
>> the createContext() method.  Auto-loading definitely requires a
>> special context.
>>    
>
> oh, and in 2.0, you would not need to do any configuration.  just get
> a ToolContext and go, tools are lazy-loaded when used, so all are
> configured to be available by default.
>
>  
>> On Mon, Jul 20, 2009 at 1:53 PM, Steve Cohen<scohen@...> wrote:
>>    
>>> Steve Cohen wrote:
>>>
>>> ...
>>>
>>> (never mind any of what I wrote before, I have now boiled it down to one
>>> hopefully intelligent question):
>>>
>>>
>>> I am NOT using VelocityView but instantiating, configuring and initializing
>>> a VelocityEngine in java code.  I don't use Velocity View.
>>> Since I don't use VelocityView, and the documentation for Velocity Tools
>>> assumes I do
>>>
>>> (http://velocity.apache.org/tools/releases/1.4/generic/EscapeTool.html)
>>> telling me this:
>>>
>>>      
>>>> *Toolbox Configuration Example*
>>>>
>>>> <tool>
>>>>  <key>esc</key>
>>>>  <scope>application</scope>
>>>>  <class>org.apache.velocity.tools.generic.EscapeTool</class>
>>>> </tool>
>>>>
>>>>        
>>> how do I perform this same step in java code (i.e. what
>>> applicationAttributes or runtime Properties must I set, in order for my
>>> VelocityEngine to see the Tools generally or the EscapeTool in particular
>>> (which is all I need)?
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@...
>>> For additional commands, e-mail: user-help@...
>>>
>>>
>>>      
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@...
> For additional commands, e-mail: user-help@...
>
>
>
>  


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@...
For additional commands, e-mail: user-help@...


Re: Escaping question

by Nathan Bubna :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

// do this once, and keep it around for the life of your app
ServletToolboxManager  manager =
ServletToolboxManager.getInstance(servletContext,
"path/to/toolbox.xml");

// do this for every request
ChainedContext ctx = new ChainedContext(velocityEngine, httpReq,
httpRes, servletContext);
ctx.setToolbox(manager.getToolbox(ctx));

// and then use the ctx just like any other VelocityContext

On Mon, Jul 20, 2009 at 7:35 PM, Steve Cohen<scohen@...> wrote:

> Thanks, Nathan.  Although your single-quoting thing is the right answer for
> this particular situation, this discussion did at least get me thinking
> about the Tools, which I haven't used before.  They could provide some value
> for me in other situations so it's good to learn about them.  Therefore I am
> interested in more info about the ServletToolboxManager.
> My situation, you might possibly remember, is that of a webapp that is not
> delivered as web pages.  I was googling around for information about this
> earlier and came across one of my own posts that explains the situation:
> http://www.mail-archive.com/user@.../msg02079.html
>
> Nathan Bubna wrote:
>>
>> On Mon, Jul 20, 2009 at 5:51 PM, Nathan Bubna<nbubna@...> wrote:
>>
>>>
>>> In VelocityTools 1.4, there is little support for auto-loading
>>> GenericTools, i wouldn't bother.  Just create a context, add tool
>>> instances that you want and then use the already available
>>> context-chaining support in VelocityContext to use that "tool" context
>>> as a base context for other ones.
>>>
>>
>> just to clarify, since i just noticed you are creating a webapp.  you
>> could use the ServletToolboxManager in 1.4 to manage your tools
>> without using the VelocityViewServlet at all.  ask if you want more
>> info on that.
>>
>>
>>>
>>> In VelocityTools 2.0, you can just create a ToolManager and ask it for
>>> a ToolContext (which you can use like a standard VelocityContext) via
>>> the createContext() method.  Auto-loading definitely requires a
>>> special context.
>>>
>>
>> oh, and in 2.0, you would not need to do any configuration.  just get
>> a ToolContext and go, tools are lazy-loaded when used, so all are
>> configured to be available by default.
>>
>>
>>>
>>> On Mon, Jul 20, 2009 at 1:53 PM, Steve Cohen<scohen@...>
>>> wrote:
>>>
>>>>
>>>> Steve Cohen wrote:
>>>>
>>>> ...
>>>>
>>>> (never mind any of what I wrote before, I have now boiled it down to one
>>>> hopefully intelligent question):
>>>>
>>>>
>>>> I am NOT using VelocityView but instantiating, configuring and
>>>> initializing
>>>> a VelocityEngine in java code.  I don't use Velocity View.
>>>> Since I don't use VelocityView, and the documentation for Velocity Tools
>>>> assumes I do
>>>>
>>>> (http://velocity.apache.org/tools/releases/1.4/generic/EscapeTool.html)
>>>> telling me this:
>>>>
>>>>
>>>>>
>>>>> *Toolbox Configuration Example*
>>>>>
>>>>> <tool>
>>>>>  <key>esc</key>
>>>>>  <scope>application</scope>
>>>>>  <class>org.apache.velocity.tools.generic.EscapeTool</class>
>>>>> </tool>
>>>>>
>>>>>
>>>>
>>>> how do I perform this same step in java code (i.e. what
>>>> applicationAttributes or runtime Properties must I set, in order for my
>>>> VelocityEngine to see the Tools generally or the EscapeTool in
>>>> particular
>>>> (which is all I need)?
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: user-unsubscribe@...
>>>> For additional commands, e-mail: user-help@...
>>>>
>>>>
>>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@...
>> For additional commands, e-mail: user-help@...
>>
>>
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@...
> For additional commands, e-mail: user-help@...
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@...
For additional commands, e-mail: user-help@...


Re: Escaping question

by stevecoh1 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Any way to do this in my situation that is not responding to http
requests?  My pattern is just to make
calls on my engine.mergeTemplate().  The context is passed into the
method that invokes this as a simple properties, and a new
VelocityContext is constructed from it.




Nathan Bubna wrote:

> // do this once, and keep it around for the life of your app
> ServletToolboxManager  manager =
> ServletToolboxManager.getInstance(servletContext,
> "path/to/toolbox.xml");
>
> // do this for every request
> ChainedContext ctx = new ChainedContext(velocityEngine, httpReq,
> httpRes, servletContext);
> ctx.setToolbox(manager.getToolbox(ctx));
>
> // and then use the ctx just like any other VelocityContext
>
> On Mon, Jul 20, 2009 at 7:35 PM, Steve Cohen<scohen@...> wrote:
>  
>> Thanks, Nathan.  Although your single-quoting thing is the right answer for
>> this particular situation, this discussion did at least get me thinking
>> about the Tools, which I haven't used before.  They could provide some value
>> for me in other situations so it's good to learn about them.  Therefore I am
>> interested in more info about the ServletToolboxManager.
>> My situation, you might possibly remember, is that of a webapp that is not
>> delivered as web pages.  I was googling around for information about this
>> earlier and came across one of my own posts that explains the situation:
>> http://www.mail-archive.com/user@.../msg02079.html
>>
>> Nathan Bubna wrote:
>>    
>>> On Mon, Jul 20, 2009 at 5:51 PM, Nathan Bubna<nbubna@...> wrote:
>>>
>>>      
>>>> In VelocityTools 1.4, there is little support for auto-loading
>>>> GenericTools, i wouldn't bother.  Just create a context, add tool
>>>> instances that you want and then use the already available
>>>> context-chaining support in VelocityContext to use that "tool" context
>>>> as a base context for other ones.
>>>>
>>>>        
>>> just to clarify, since i just noticed you are creating a webapp.  you
>>> could use the ServletToolboxManager in 1.4 to manage your tools
>>> without using the VelocityViewServlet at all.  ask if you want more
>>> info on that.
>>>
>>>
>>>      
>>>> In VelocityTools 2.0, you can just create a ToolManager and ask it for
>>>> a ToolContext (which you can use like a standard VelocityContext) via
>>>> the createContext() method.  Auto-loading definitely requires a
>>>> special context.
>>>>
>>>>        
>>> oh, and in 2.0, you would not need to do any configuration.  just get
>>> a ToolContext and go, tools are lazy-loaded when used, so all are
>>> configured to be available by default.
>>>
>>>
>>>      
>>>> On Mon, Jul 20, 2009 at 1:53 PM, Steve Cohen<scohen@...>
>>>> wrote:
>>>>
>>>>        
>>>>> Steve Cohen wrote:
>>>>>
>>>>> ...
>>>>>
>>>>> (never mind any of what I wrote before, I have now boiled it down to one
>>>>> hopefully intelligent question):
>>>>>
>>>>>
>>>>> I am NOT using VelocityView but instantiating, configuring and
>>>>> initializing
>>>>> a VelocityEngine in java code.  I don't use Velocity View.
>>>>> Since I don't use VelocityView, and the documentation for Velocity Tools
>>>>> assumes I do
>>>>>
>>>>> (http://velocity.apache.org/tools/releases/1.4/generic/EscapeTool.html)
>>>>> telling me this:
>>>>>
>>>>>
>>>>>          
>>>>>> *Toolbox Configuration Example*
>>>>>>
>>>>>> <tool>
>>>>>>  <key>esc</key>
>>>>>>  <scope>application</scope>
>>>>>>  <class>org.apache.velocity.tools.generic.EscapeTool</class>
>>>>>> </tool>
>>>>>>
>>>>>>
>>>>>>            
>>>>> how do I perform this same step in java code (i.e. what
>>>>> applicationAttributes or runtime Properties must I set, in order for my
>>>>> VelocityEngine to see the Tools generally or the EscapeTool in
>>>>> particular
>>>>> (which is all I need)?
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: user-unsubscribe@...
>>>>> For additional commands, e-mail: user-help@...
>>>>>
>>>>>
>>>>>
>>>>>          
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@...
>>> For additional commands, e-mail: user-help@...
>>>
>>>
>>>
>>>
>>>      
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@...
>> For additional commands, e-mail: user-help@...
>>
>>
>>    
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@...
> For additional commands, e-mail: user-help@...
>
>
>
>  


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@...
For additional commands, e-mail: user-help@...


Re: Escaping question

by Nathan Bubna :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

i haven't time to check right now, but you might just avoid adding any
request or session scoped things and then pass in null for those
values.  i haven't tried this though...

On Tue, Jul 21, 2009 at 4:19 PM, Steve Cohen<scohen@...> wrote:

> Any way to do this in my situation that is not responding to http requests?
>  My pattern is just to make
> calls on my engine.mergeTemplate().  The context is passed into the method
> that invokes this as a simple properties, and a new VelocityContext is
> constructed from it.
>
>
>
>
> Nathan Bubna wrote:
>>
>> // do this once, and keep it around for the life of your app
>> ServletToolboxManager  manager =
>> ServletToolboxManager.getInstance(servletContext,
>> "path/to/toolbox.xml");
>>
>> // do this for every request
>> ChainedContext ctx = new ChainedContext(velocityEngine, httpReq,
>> httpRes, servletContext);
>> ctx.setToolbox(manager.getToolbox(ctx));
>>
>> // and then use the ctx just like any other VelocityContext
>>
>> On Mon, Jul 20, 2009 at 7:35 PM, Steve Cohen<scohen@...>
>> wrote:
>>
>>>
>>> Thanks, Nathan.  Although your single-quoting thing is the right answer
>>> for
>>> this particular situation, this discussion did at least get me thinking
>>> about the Tools, which I haven't used before.  They could provide some
>>> value
>>> for me in other situations so it's good to learn about them.  Therefore I
>>> am
>>> interested in more info about the ServletToolboxManager.
>>> My situation, you might possibly remember, is that of a webapp that is
>>> not
>>> delivered as web pages.  I was googling around for information about this
>>> earlier and came across one of my own posts that explains the situation:
>>> http://www.mail-archive.com/user@.../msg02079.html
>>>
>>> Nathan Bubna wrote:
>>>
>>>>
>>>> On Mon, Jul 20, 2009 at 5:51 PM, Nathan Bubna<nbubna@...> wrote:
>>>>
>>>>
>>>>>
>>>>> In VelocityTools 1.4, there is little support for auto-loading
>>>>> GenericTools, i wouldn't bother.  Just create a context, add tool
>>>>> instances that you want and then use the already available
>>>>> context-chaining support in VelocityContext to use that "tool" context
>>>>> as a base context for other ones.
>>>>>
>>>>>
>>>>
>>>> just to clarify, since i just noticed you are creating a webapp.  you
>>>> could use the ServletToolboxManager in 1.4 to manage your tools
>>>> without using the VelocityViewServlet at all.  ask if you want more
>>>> info on that.
>>>>
>>>>
>>>>
>>>>>
>>>>> In VelocityTools 2.0, you can just create a ToolManager and ask it for
>>>>> a ToolContext (which you can use like a standard VelocityContext) via
>>>>> the createContext() method.  Auto-loading definitely requires a
>>>>> special context.
>>>>>
>>>>>
>>>>
>>>> oh, and in 2.0, you would not need to do any configuration.  just get
>>>> a ToolContext and go, tools are lazy-loaded when used, so all are
>>>> configured to be available by default.
>>>>
>>>>
>>>>
>>>>>
>>>>> On Mon, Jul 20, 2009 at 1:53 PM, Steve Cohen<scohen@...>
>>>>> wrote:
>>>>>
>>>>>
>>>>>>
>>>>>> Steve Cohen wrote:
>>>>>>
>>>>>> ...
>>>>>>
>>>>>> (never mind any of what I wrote before, I have now boiled it down to
>>>>>> one
>>>>>> hopefully intelligent question):
>>>>>>
>>>>>>
>>>>>> I am NOT using VelocityView but instantiating, configuring and
>>>>>> initializing
>>>>>> a VelocityEngine in java code.  I don't use Velocity View.
>>>>>> Since I don't use VelocityView, and the documentation for Velocity
>>>>>> Tools
>>>>>> assumes I do
>>>>>>
>>>>>>
>>>>>> (http://velocity.apache.org/tools/releases/1.4/generic/EscapeTool.html)
>>>>>> telling me this:
>>>>>>
>>>>>>
>>>>>>
>>>>>>>
>>>>>>> *Toolbox Configuration Example*
>>>>>>>
>>>>>>> <tool>
>>>>>>>  <key>esc</key>
>>>>>>>  <scope>application</scope>
>>>>>>>  <class>org.apache.velocity.tools.generic.EscapeTool</class>
>>>>>>> </tool>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>> how do I perform this same step in java code (i.e. what
>>>>>> applicationAttributes or runtime Properties must I set, in order for
>>>>>> my
>>>>>> VelocityEngine to see the Tools generally or the EscapeTool in
>>>>>> particular
>>>>>> (which is all I need)?
>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe, e-mail: user-unsubscribe@...
>>>>>> For additional commands, e-mail: user-help@...
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: user-unsubscribe@...
>>>> For additional commands, e-mail: user-help@...
>>>>
>>>>
>>>>
>>>>
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@...
>>> For additional commands, e-mail: user-help@...
>>>
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@...
>> For additional commands, e-mail: user-help@...
>>
>>
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@...
> For additional commands, e-mail: user-help@...
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@...
For additional commands, e-mail: user-help@...