Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How to modify custom Confluence page so that its viewable like default options

angela simmons July 4, 2012

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

1 answer

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Joe Clark
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 5, 2012

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.

angela simmons July 5, 2012

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?

JamesJ July 5, 2012

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

angela simmons July 8, 2012

Hi James , Your advice did infact help me thank you so much. My VM looks like this now

##requireResource("confluence.web.resources:space-admin")
&lt;html&gt;
&lt;head&gt;
   &lt;title&gt;This is my Example action!&lt;/title&gt;
   &lt;meta name="decorator" content="atl.general" /&gt;   
 &lt;/head&gt;

 &lt;content tag="key"&gt;$action.space.key&lt;/content&gt;

&lt;body&gt;    

#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) 

        &lt;strong&gt;Hello, Confluence World!&lt;/strong&gt;
    #end
#end    
&lt;/body&gt;
&lt;/html&gt;


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 ?

TAGS
AUG Leaders

Atlassian Community Events