velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nathan Bubna <nbu...@gmail.com>
Subject Re: Escaping question
Date Tue, 21 Jul 2009 23:58:49 GMT
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@javactivity.org> 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@javactivity.org>
>> 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@velocity.apache.org/msg02079.html
>>>
>>> Nathan Bubna wrote:
>>>
>>>>
>>>> On Mon, Jul 20, 2009 at 5:51 PM, Nathan Bubna<nbubna@gmail.com> 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@javactivity.org>
>>>>> 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@velocity.apache.org
>>>>>> For additional commands, e-mail: user-help@velocity.apache.org
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
>>>> For additional commands, e-mail: user-help@velocity.apache.org
>>>>
>>>>
>>>>
>>>>
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
>>> For additional commands, e-mail: user-help@velocity.apache.org
>>>
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
>> For additional commands, e-mail: user-help@velocity.apache.org
>>
>>
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
>
>

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


Mime
View raw message