How to write an xwork tag for a section="system.space" web item ?

vishnu soman June 12, 2012

Hi All
I used this web-item

<web-item name="add-fpc-label-action-web-ui" key="add-fpc-label-action-web-ui" section="system.space" weight="150">
        <description key="item.add-fpc-label-action-web-ui.link.desc">Allows the Create Freeway Project functionality.</description>
        <label key="Freeway Project Creation"/>
        <link linkId="add-fpc-label-action">/spaces/copyspaceoptionsfpc.action?key=$helper.space.key</link>
    </web-item>



to display my custom tab named Freeway Project Creation as seen in the below screenshot.
http://imageshack.us/photo/my-images/138/addedtabs.png/

Now i would like to display a simple Page displaying "Hello World" on the click of the tab "Freeway Project Creation" as seen here.

http://imageshack.us/f/98/addedtabshw.png/


What should be the xwork tag i need to write to achieve this ? Please advice.

Thanks

Vishnu

2 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Answer accepted
Joe Clark
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 17, 2012

Here's an example plugin showing the very bare minimum that is required in order to get a custom action to render a custom velocity template: http://filebin.ca/5goyOY7r1ZS

Once you install this plugin, you can access the example action under "/plugins/examples/hello.action"

Some key things to note:

1. The result of the ExampleAction.execute() method is Action.SUCCESS. This maps to <result name="success"> in the atlassian-plugin.xml.

2. The location of the velocity file in the /src/main/resources directory matches the location in the atlassian-plugin.xml (/templates/example/hello.vm)

Hopefully this will help clarify for you what is the 'basic' example, which you can build from.

vishnu soman June 17, 2012

Hi Joseph,

Thanks this did help me view almost the output i desired. http://imageshack.us/f/577/hellooutput.jpg/ . The part of using the decorators remains.

Really appreciate it.:)

V

1 vote
Suraiya Banu June 12, 2012

Hi, you will have to add the following in your atlassian-plugin.xml file

<xwork name="nameulike" key="keyulike">

<package name="packnameulike" extends="default" namespace="/ulike">

<default-interceptor-ref name="validatingStack"/>

<action name="actionulike" class="path to your action class">

<interceptor-ref name="defaultStack"/>

<result name="success" type="velocity">/path to your velocity file</result>

<result name="error" type="velocity">/path to your velocity file</result>

</action>

</package>

</xwork>

Hope it helps...

vishnu soman June 12, 2012

Hi Suraiya.

Many thanks for your detailed reply! I tried to implement using your suggestion This is the xwork i used for the earlier written web item.

&lt;xwork name="add-fpc-label-action-xwork" key="add-fpc-label-action-xwork"&gt;
		&lt;package name="add-fpc-label" extends="default" namespace="/plugins/add-fpc-label"&gt;
		&lt;default-interceptor-ref name="validatingStack"/&gt;
	
		&lt;action name="add-fpc" class="com.lionbridge.confluence.plugins.AddDraftLabelAction"&gt;
	            &lt;interceptor-ref name="defaultStack"/&gt;
			&lt;result name="success" type="velocity"&gt;/templates/extra/copyspace/copyspaceoptions.vm&lt;/result&gt;
			&lt;result name="error" type="velocity"&gt;/templates/extra/copyspace/copyspaceoptions.vm&lt;/result&gt;
	    &lt;/action&gt;
	
	&lt;/package&gt;
	&lt;/xwork&gt;

But i am getting the same error page on click. http://imageshack.us/f/4/errorpagez.png/

Is there any things i need to lookout for in the values i mentioned according to your xwork. I have just used a dummy AddDraftLabel tutorial class and a dummy vm named copyspaceoptions.vm. Are these things very crucial to the expected output

Suraiya Banu June 12, 2012

Yes it is crucial. Make sure you are extending the proper action class and also using the proper decoratorParam for "context" and "mode" in your .vm file. You cannot leave the .vm file empty(just in case you have left it empty). This should hopefully fix it.

Suraiya

vishnu soman June 14, 2012

Hi Suraiya..

Really appreciate your help! :) Can a class like this http://pastebin.com/rhVKfzeM and a VM like http://pastebin.com/VmZm0kdL suffice in the above scenario? Really looking forward for your help..Can you provide some pseudo hints for the same...i think i am near to achieve my target thanks to your support..!

Thanks!

TAGS
AUG Leaders

Atlassian Community Events