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

How to bind form based actions like 'Save' to designated Java classes mentioned in xwork in Confluence

Hi All,
I have made some significant progress in my customization efforst thanks to your help and looking forward to move forward similarly.
I have created the custom tab in the 'Advanced' tab and it now looks like this . I have been able to add a text field as well as a 'Save' button. I actually followed the 'Edit Space Details' option and took two of its form elements to achieve the output.
This is how my VM looks now.

   <title>Freeway Project Creation</title>
   <meta name="decorator" content="atl.general" />   

 <content tag="key">$</content>


    #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(""))
        #decoratorParam ("selectedTab" "admin")
        #decoratorParam("helper" $action.helper) 

       <div >
   			 <table width="95%" border=0 cellspacing=0 cellpadding=5>
			   <form name="editspace" method="POST" >
            #bodytag( "TextField" "label='space-name'" "name='name'" "size=40" )
            #param ("labelwidth" "100")
            #param ("tdcolor" "f0f0f0")
                <td colspan="2" align="center">
                    #tag( "Submit" "name='confirm'" "value=''" "theme='notable'" )
                    #tag( "Submit" "name='cancel'" "value=''" "theme='notable'" )


I would like to understand how this interaction with my JAVA class will result in the output like. For eg: I will enter the name in the text box for name and hit save and on a resulting page it must display the name entered.

As of now my designated java class looks like this.

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 FreewayProjectAction extends ConfluenceActionSupport 
    public String execute() throws Exception
        return Action.SUCCESS;


So I have 3 questions:

1. The 'Edit Space Details' shows the following URL 'http://localhost:1990/confluence/spaces/doeditspace.action?key=LBTEST' when i mouse over the 'Save' button. I am assuming that its governing Java class is EditSpaceDetails. So is the doEdit() method (see here that class that swings into action when we try to save the edit action of the space ? Can i get to see the xml that has this mapping specifically for this edit space details action? Is my assumptin correct ?

2. In order to have such a functionality i have mentioned earlier i.e. displaying the name entered in my custom page as detailed above what will be the changes required in my Java class.

3. In the page i have just customised there is the text box and the label is 'Name' . Should i use a different xml so that i can provide my custom label like "Project Name" ?

Please do kindly advice me on the same.


1 answer

  1. There are two ways of doing actions in confluence. One is one action class per action, in this you define an execute() method, and that gets executed. If you want another action for when you submit the form, you create a new class, eg SaveFreewayProjectAction, with an execute method. The other way is in the XML for for the action, define a method parameter, eg method="doEdit", and then for each of your actions (each one still has to be declared individual in the XML plugins file), you write a corresponding method. In this method I think you must not implement the execute() method yourself, each one has to have their own method.
  2. If you define a setter for name (void setName(String name)) in your action class, then when the form gets submitted with a name parameter, it will be passed to the setter. You can then use that value when your action is executed. If you want to access that (or a preloaded) value from the template, define a getter (String getName()) that returns it, and then you can access it from the template using $
  3. If you don't want internationalisation, just put the name you want in the label. If you want internationalisation, read this:</li<>>

Hi James,

Thanks for the support . As a first try of using my custom jars inside the execute, i Added few of my jars to the build path in my project . But stil i am getting class not found error when i run the build. The eclipse autosugest seems to easily identify the classes inside my jar. Is there a different way to import jars in a custom plugin ?

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Confluence

Introducing Confluence Cloud and Jira Software Cloud Premium

Wherever you are in your team’s journey , our goal is to support your big ambitions. We’re a cloud-first company with the mission of unleashing the potential of every team, and to address the range ...

627 views 4 17
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