Get a web-item to link to java code

I feel like this is something obvious, but I can't seem to figure it out. What is the simplest way to get a button to start running code in a Java class? Another related question I have, is where does the relative path of a link element in a web item begin from?

The few open source examples I can find of buttons that do things, rather than link to an absolute URL somewhere, aren't really helping me. I have put a lot of independent research and digging around into this and I am now stumped.

My goal (For now. One step at a time) is to make a button that is exactly the same as the Approve button for a pull request.

Any help with this issue would be amazing!

2 answers

1 accepted

1 vote
Accepted answer
Adam Ahmed Atlassian Team Aug 21, 2013

Hi Corin,

Relative links are relative to the root of the product. E.g. if your Stash is at http://localhost/stash, then a URL like /some/path would be http://localhost/stash/some/path.

As far as getting from a web-item button to Java code, there is no "direct" way to do this. You're asking how to take a button clicks on the client, and have it execute some Java code on the server.

This requires either using JS to make an AJAX call to a REST endpoint when the user clicks the button and then alters the current page based on the result your REST endpoint returns, or pointing the button's link to a servlet that serves your custom content in a fresh page.



Atlassian has great developer docs that will walk through most examples, but probably in some separate places.

* general stash development (make your first plugin)

* available module types ( your plugin will use 1 or more of these )

* matching the UI

I have already read through the first two links several times, and yet am still unsure of the answers to my two questions. While I am fully aware that this could be a deficiency on my part, it is not from lack of trying and I was hoping for a more specific answer.

The documentation for web-items doesn't really explain what can be linked to in the link field. Every example I find just links to an absolute URL like "". The component module seems to be for connecting modules with each other, so I thought it might help me, but the documentation doesn't really explain how to do that, just that it enables such a connection. The section on Creating Plugin Module Instances seemed promising, but it just explains about how parameters to the class are injected, not how to control execution.

I feel like I must be missing some really basic understanding of something, and maybe I am in over my head, but I am not really willing to give up, so any help would be hugely appreciated.

Thanks in advance!


Suggest an answer

Log in or Sign up to answer
Community showcase
Published Nov 06, 2018 in Bitbucket

Upgrade Best Practices

Hello! My name is Mark Askew and I am a Premier Support Engineer for products Bitbucket Server/Data Center, Fisheye & Crucible. Today, I want to bring the discussion that Jennifer, Matt, and ...

446 views 6 9
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you