Hi There,
Is possible to load a Velocity template from java code? In may case, I'm creating a jira-footer and I've a
PluggableFooter class that has a method called
getFullFooterHtml
I need todo something like this
// Create the Velocity Context Map context = MacroUtils.defaultVelocityContext(); context.put("myCustomVar", customVar); context.put("otherCustomVar", otherCustomVar); // Render the Template String result = VelocityUtils.getRenderedTemplate("/com/myplugin/templates/macro.vm", context);
Any suggestion?
Cheers,
RMRodrigues.
Community moderators have prevented the ability to post new answers.
I think that I've found a possible solution. I'm doing some testes.
Solution:
Map<String, Object> context = new HashMap<String, Object>(); VelocityManager velocityManager = ComponentAccessor.getVelocityManager(); String webworkEncoding = ComponentAccessor.getApplicationProperties().getString(APKeys.JIRA_WEBWORK_ENCODING); String renderedText = velocityManager.getEncodedBody("/templates/", "MyTemplate.vm", "Base URL Here...", webworkEncoding, context);
I will confirm if that is the solution.
Thanks.
This solution is working fine.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey,
replace this line:
String result = VelocityUtils.getRenderedTemplate("/com/myplugin/templates/macro.vm", context);
with this line:
String result = VelocityUtils.getRenderedTemplate("templates/macro.vm", context); return result;
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The class VelocityUtils is not available on JIRA. It's available on Confluence only I think.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
We have done this with our instance. Depending on your JIRA version, find the soy template for the footer. Usually it can be found in root/app/static/email/global-footer.soy
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Gabrielle, Thank for your response. I've a Velocity template and not a SOY template. I need to load my Velocity template from java class and return its content processed. Thanks.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.