Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How to read external resources in Velocity

Adolfo Casari
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 24, 2012

I would like to read {key:value} pairs in Velocity templates (for user macros). These values are placed in an external resource file.

Is this possible?

Thank you,

1 answer

1 accepted

0 votes
Answer accepted
Andy Brook [Plugin People]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 24, 2012

Access to physical files would be a security risk and can't be done directly, Two options:

a) you could do this using a different approach, though a Beanshell (part of bobs Scripting plugin) that could load resources and generate markup. Some scripting/Dev skills required.

b) IIRC you can write a plugin that contributes the necessary resources as part of a plugin, with a Java accessor object written to read the data, that object could then be made available in the velocity context. Dev skills required.

Adolfo Casari
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 24, 2012

I think b) is the way to go, is there any URL that document this approach?

Thank you.

Andy Brook [Plugin People]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 25, 2012

You'll need to create a plugin with a Velocity Context Module, that bundles the 'helper' you access from Velocity, along with the resources that may be packaged within the plugin or on your local OS if thats what you wanted to do.

- https://developer.atlassian.com/display/CONFDEV/Velocity+Context+Module

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events