It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Confluence Plugin developing with xwork and apache velocity file

Burak Cet Aug 16, 2012

Hi,

I am trainee at one computer company. My supervisor wanted me to make confluence plugin in order to do that i decided to use xwork. I create one button in this way and this .xwork directs it to new page which is .vm

My code in atlassian-plugin.xml is here:

<xwork name="add-draft-label-action-xwork" key="add-draft-label-action-xwork">
    <description key="item.add-draft-label-action-xwork.link.desc">Defines what the "Add 'draft' label" action does.</description>
        <package name="add-draft-label" extends="default" namespace="/plugins/add-draft-label">
        <default-interceptor-ref name="defaultStack"/>
            <action name="add-label" class="com.atlassian.plugins.tutorial.AddDraftLabelAction">
			<result name="success" type="velocity">/hello.vm</result>               
			<!-- <result name="success" type="velocity">/templates/hello.vm</result> -->

			<!--   <result name="success" type="redirect">${page.urlPath}</result> -->
            </action>
        </package>
</xwork>

and My hello.vm is :

<html>
<head>
    <title>This is my Example action!</title>
    <meta name="decorator" content="atl.general" />
</head>
<body>
	Hello $name! what is up
</body>
</html>

and at the and my execute file which is in AdddraftLabelAction.java is here :

public String execute() throws Exception
    {  
       
        //  next, get the Template  *
        Template t = Velocity.getTemplate("hello.vm");
        // create a context and add data 
        VelocityContext context = new VelocityContext();
        String mes = "World";
        context.put("name",mes);
        // now render the template into a StringWriter 
        StringWriter writer = new StringWriter();
        t.merge( context, writer );
        // show the World 
        System.out.println( writer.toString() );  

        return "success";
    }

When i do all of them it only shows at screen Hello $name! what is up
but it should show Hello World! what is up

what should i do ? please help me.

1 answer

0 votes
w s Feb 06, 2013

I notice your meta tag may have a type-o:

<metaname="decorator"content="atl.general"/>

Notice: ALT.general

Egor Malyshev Feb 06, 2015

Nope, it's atl.general

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published in Confluence

6 Awesome Ways to Apply Trello, JIRA and Confluence to your Project

I attended  Atlassian Summit 2019  and learned a lot from the presenters, attendees and knowledgeable Atlassian product managers. The presentations I attended focused on applying Agile, pla...

853 views 6 16
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you