Sebastian
Sebastian

Reputation: 81

Jira-Servlet-Plugin using TemplateRenderer

I'm trying to develop a simple HTTP-Servlet, to render a Velocity Template.

My Servlet:

Map<String, Object> context = Maps.newHashMap();
resp.setContentType("text/html;charset=utf-8");
templateRenderer.render("/templates/test/input.vm", context, httpRespnse.getWriter());

atlassian-plugin.xml

<webwork1 key="newactions1" name="New actions1" class="java.lang.Object">
    <actions>
        <action name="test.ActionAlpha" alias="FirstNewAction">
            <view name="success">/templates/test/input.vm</view>
            <view name="error">/templates/test/input.vm</view>
            <view name="input">/templates/test/input.vm</view>
        </action>
    </actions>
</webwork1>

(See: https://developer.atlassian.com/display/JIRADEV/Plugin+Tutorial+-+Internationalising+Your+Plugin)

Everything works fine so far, but after the page is rendered the menu-bar on the left is missing (The other Menu-webitems in the websection)

If I call the URL in my browser by hand, with "!default" behind the action-name, the sidebar is displayed.

http://host:port/jira/secure/FirstNewAction!default.jspa

But if I call the URL without "!default" the output is the same as the servlet produces. Is there a possibility for the TemplateRenderer to add the "!default" term?

Upvotes: 2

Views: 1933

Answers (1)

Lars kleen
Lars kleen

Reputation: 21

I guess

Map<String, Object> context = Maps.newHashMap();
templateRenderer.render("/templates/test/input.vm", context, httpRespnse.getWriter());

passes an empty map to the render method, if you omit the context parameter the default context should be passed which includes the webResources. Another idea is to add something like

meta name="decorator" content="atl.admin"

to the heads section

Upvotes: 2

Related Questions