You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@click.apache.org by Malcolm Edgar <ma...@gmail.com> on 2013/05/14 14:43:47 UTC

Re: configure velocity tools in click

Please note the Click Format object is fairly equivalent to the
Velocity EscapeTool.
 You can readily extend this class, or use composition, to add the
EscapeTool functionality you need.

http://click.apache.org/docs/click-api/org/apache/click/util/Format.html

regards Malcolm Edgar

On Fri, Apr 26, 2013 at 4:29 PM, Bob Schellink <sa...@gmail.com> wrote:

> How about extending VelocityTemplateService#**onInit()?
>
> There you have access to VelocityEngine. Perhaps you can register the tool
> with the engine? This is more a Velocity question though so you might want
> to check on their user list.
>
> Kind regards
>
> Bob
>
>
> On 2013/04/25 09:35, Aleksei Pokrevskiy wrote:
>
>> Thanks Bob
>>
>> from what I have understand there's no possibility to add tool to global
>> context in Click
>>
>> 24.04.2013 12:28, Bob Schellink пишет:
>>
>>> I don't think Velocity Tools works by  only configuring it. See here:
>>>
>>> http://velocity.apache.org/**tools/devel/frameworks.html<http://velocity.apache.org/tools/devel/frameworks.html>
>>>
>>> So Tools won't be available in Click since Click doesn't use
>>> VelocityView or any Tools specific
>>> APIs. That is my understanding of Tools anyway.
>>>
>>> > Adding it as model property to base page is not working when you
>>> generating template as a string
>>>
>>> You mean Context.renderTemplate?
>>>
>>> you still provide the model so can add the tools you want there or
>>> through a utility method?
>>>
>>> Kind regards
>>>
>>> Bob
>>>
>>> On 2013/04/24 09:20, Aleksei Pokrevskiy wrote:
>>>
>>>> Thanks Bob
>>>> This is how we do it now, but I want to add tool to global context (ie
>>>> make it available in all
>>>> templates)
>>>> Adding it as model property to base page is not working when you
>>>> generating template as a string
>>>>
>>>> Answering you question, configuring Velocity tools can be done via xml,
>>>> property file or java
>>>> code (see http://velocity.apache.org/**tools/devel/config.html<http://velocity.apache.org/tools/devel/config.html>
>>>> )
>>>> I've tried 1 and 2 but wasn't able to make it work
>>>>
>>>> 23.04.2013 21:35, Bob Schellink пишет:
>>>>
>>>>> Hi,
>>>>>
>>>>> I've never used Velocity Tools. How does one integrate the tools in
>>>>> standalone mode of Velocity?
>>>>> Is it enough to simply configure it inside velocity.properties or is
>>>>> some other configuration
>>>>> needed?
>>>>>
>>>>> However since it looks like most Velocity Tools are POJO's, you could
>>>>> do the following in your
>>>>> BorderPage:
>>>>>
>>>>> public BorderPage() {
>>>>>         addModel("esc", new EscapeTool());
>>>>>  }
>>>>>
>>>>> Kind regards
>>>>>
>>>>> Bob
>>>>>
>>>>> On 2013/04/23 15:41, Aleksei Pokrevskiy wrote:
>>>>>
>>>>>> Hello
>>>>>> how can I add EscapeTool to global velocity context?
>>>>>> I've tried adding velocity.properties to WEB-INF directory with
>>>>>> content:
>>>>>>
>>>>>> tools.toolbox = request
>>>>>> tools.data.version = 2.0
>>>>>> tools.data.version.type = number
>>>>>> tools.application.esc = org.apache.velocity.tools.**
>>>>>> generic.EscapeTool
>>>>>>
>>>>>> and tools.xml with content:
>>>>>>
>>>>>> <tools>
>>>>>>     <data key="version" type="number" value="2.0"/>
>>>>>>     <toolbox scope="application">
>>>>>>         <tool class="org.apache.velocity.**tools.generic.EscapeTool"
>>>>>> key="esc"/>
>>>>>>     </toolbox>
>>>>>> </tools>
>>>>>>
>>>>>> and still get $esc undefined in templates
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>
>>
>