I am pursuing the task of adding my custom tabs inside my Confluence set up. I have chosen the 'Advanced' region as the favourable spot to realize this.
So i click on the Space name. Then I goto 'Browse>>Advanced' and see http://imageshack.us/f/405/advanc.png . The "Freeway Project Creation " tab we see in this image was custom added by me.
I wrote this class
package com.atlassian.myorg; import com.atlassian.confluence.core.ConfluenceActionSupport; import com.atlassian.confluence.pages.AbstractPage; import com.atlassian.confluence.pages.actions.PageAware; import com.opensymphony.xwork.Action; /** * The simplest action possible */ public class ExampleAction extends ConfluenceActionSupport { @Override public String execute() throws Exception { return Action.SUCCESS; } }
used this atlassian-plugin.xml
<atlassian-plugin key="${project.groupId}.${project.artifactId}" name="${project.name}" plugins-version="2"> <plugin-info> <description>${project.description}</description> <version>${project.version}</version> <vendor name="${project.organization.name}" url="${project.organization.url}" /> </plugin-info> <resource type="i18n" name="i18n" location="message" /> <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">/plugins/examples/hello.action?key=$helper.space.key</link> </web-item> <xwork name="My Example Action" key="example-action"> <description>Shows a simple "Hello, World!" Action</description> <package name="examples" extends="default" namespace="/plugins/examples"> <default-interceptor-ref name="validatingStack" /> <action name="hello" class="com.atlassian.myorg.ExampleAction"> <result name="success" type="velocity">/templates/example/hello.vm</result> </action> </package> </xwork> </atlassian-plugin>
The below seen is the VM
<html> <head> <title>This is my Example action!</title> <meta name="decorator" content="atl.general" /> </head> <body> <strong>Hello, Confluence World!</strong> </body> </html>
As a result when i click on this tab named "Freeway Project Creation " i see this page http://imageshack.us/f/846/imageprf.png/
Well this was good enough. But i wanted to have this page seen in the 'body area' besides the sidebar. Like for example if we click on the "Space Admin" tab and we click on 'Edit Space Label' from the side bar; we see the resulting page in the 'body area' marked http://imageshack.us/f/809/bodyarea.png/.
Would like to have your sugessions as to how that can be achieved?
Thanks
A
Community moderators have prevented the ability to post new answers.
Add this into the top of the <body> of your velocity template, and remove the <meta name="decorator"> tag:
#applyDecorator("root")
#decoratorParam("helper" $action.helper)
#decoratorParam("context" "space-administration")
#decoratorParam("mode" "view-space-administration")
#applyDecorator ("root")
#decoratorParam ("context" "spaceadminpanel")
#decoratorParam ("selection" "editspacelabels")
#decoratorParam ("title" $action.getText("action.name"))
#decoratorParam ("selectedTab" "admin")
#decoratorParam("helper" $action.helper)
You'll need to change the value of the "selection" decoratorParam to match your web-item.
Hi Joseph,
I made the change to the selection param
#decoratorParam ("selection" "add-fpc-label-action-web-ui")
since i have the web-item as "add-fpc-label-action-web-ui" as seen in my atlassian-plugin.xml.
But i get org.apache.velocity.exception.ParseErrorException: Encountered "<EOF>" at /templates/example/hello.vm[line 23, column 2]
Is this change correct?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I think you're missing #end directives, so it should be:
#applyDecorator("root") #decoratorParam("helper" $action.helper) #decoratorParam("context" "space-administration") #decoratorParam("mode" "view-space-administration") #applyDecorator ("root") #decoratorParam ("context" "spaceadminpanel") #decoratorParam ("selection" "editspacelabels") #decoratorParam ("title" $action.getText("action.name")) #decoratorParam ("selectedTab" "admin") #decoratorParam("helper" $action.helper) ## Your page code here #end #end
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi James , Your advice did infact help me thank you so much. My VM looks like this now
##requireResource("confluence.web.resources:space-admin") <html> <head> <title>This is my Example action!</title> <meta name="decorator" content="atl.general" /> </head> <content tag="key">$action.space.key</content> <body> #applyDecorator("root") #decoratorParam("helper" $action.helper) #decoratorParam("context" "space-administration") #decoratorParam("mode" "view-space-administration") #applyDecorator ("root") #decoratorParam ("context" "spaceadminpanel") #decoratorParam ("selection" "add-fpc-label-action-web-ui") #decoratorParam ("title" $action.getText("action.name")) #decoratorParam ("selectedTab" "admin") #decoratorParam("helper" $action.helper) <strong>Hello, Confluence World!</strong> #end #end </body> </html>
This is the UI i am seeing now http://imageshack.us/f/137/missingtabs.png/ .
However i am seeing just my custom tab and the other tabs like Advanced,SpaceAdmin etc have vanished. Is there something more to be added to persist those tabs along with the new Page we added ?
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.