Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
badges earned

Your Points Tracker
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

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 display velocity form values on another velocity template?

I am developing a plugin that has a web-item connected to an xwork module, which displays a velocity template with a form, as such:

<form id="form" class="aui" method="post" action="#">
<button type="button" onClick="fetchAllPagesTitlesOnClick()" style="margin: 2vh auto; display: block;">Get All Pages</button>
<div style="display: block;"></div>
<label for="pageTiles" style="margin: 2vh 2vw;">Select Page Title:</label>                        
<select name="pageTitles" id="pageTitleSel" style="margin: 2vh auto;" onchange="fetchVersionsOfPage()"></select>
<button type="button" onClick="fetchPageVersionsOnClick()" style="margin: 2vh auto; display: block;">Get All Versions</button>
<label for="pageVersion1" style="margin: 2vh 2vw;">Select Page Version:</label>                        
<select name="pageVersion1" style="margin: 2vh auto;" id="pageVersionSel1" onChange="fetchPageVersionContent(1)"></select>          
<div style="display: block;"></div>
<label for="pageVersion2" style="margin: 2vh 2vw;">Select Page Version:</label>                        
<select name="pageVersion2" style="margin: 2vh auto;" id="pageVersionSel2" onChange="fetchPageVersionContent(2)"></select>
<div style="display: block;"></div>
<button type="submit" form="form" value="Submit" style="margin: 2vh auto; display: block;">Submit</button>

 My question is: how do I post the selected values onto another velocity template?

1 answer

1 accepted


I believe you should define an xwork action (in your plugin) and post to this action (which in turn does what you need and render the "other" template). 


Hi Alex, thanks for replying. I did what you said and created another xwork action, as such:

<xwork name="test-xwork" key="test-xwork">        
<description key="test-xwork.desc">#</description>        
<package name="test" extends="default" namespace="/test">            
<default-interceptor-ref name="validatingStack"/>            
<action name="test-xwork-action" class="com.example.plugin.AnotherAction">                
<result name="success" type="velocity">/velocity/result.vm</result>            

and add action="/test/test-xwork-action" into the form tag.

But when I submitted the form, Http status 404 came up. What did I do wrong?

Could be multiple reasons

  • which class does your action extends? 
  • name space issue… meaning- incorrect url (without a context or something like that)
  • maybe something else… hard to tell from the shared snippets 


Thanks for the reply, Alex. The action class extends ConfluenceActionSupport

The actions are called via .action


And you probably need to have a context path in front (for example if Confluence is run in /wiki or /confluence web context) 


404 may also be thrown when the template to render cannot be found ( make sure the path is correct - /velocity/result.vm)


Hey Alex, your solution works. Thanks so much! One last question, how do I access the selected values from the first velocity template (the one with the form) from the second velocity template?

The best way is to define a parameter in your action with the same name as the parameter in the form (select or input) and create getters/setters

this way the parameter will be automatically populated from form (request) to action 

action classes in Confluence/xwork are thread safe (new instance is created for each request)

But how will I be able to get the parameter value from the Java action class to the template?

Basically, the same way... defining the field in your class and having getters to get it's value

Assuming the field name is "myfield" and you have defined a getter: 

public String getMyfield() {
return myfield;

In this case you can access it in the Velocity template via ${myfield}


Awesome! Thank you so much Alex!

Suggest an answer

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

Miss the Confluence demos at Team 21? Watch them here!

Phew, Atlassian Team 2021 blew by. With dozens of demos and a handful of keynotes, you may have missed some of the awesome Confluence Cloud sessions. Don't' worry, you can watch them all here or on Y...

316 views 2 6
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