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

Get a web-item to link to java code

Corin Dennison Aug 20, 2013

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
Answer accepted
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.



0 votes
Eddie Webb Aug 20, 2013

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

Corin Dennison Aug 20, 2013

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
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published in Bitbucket Pipelines

Building a Bitbucket Pipe as a casual coder :  #!/bin/bash source "$(dirname "$0")/" enable_debug extra_args="" if [[ "${DEBUG}" == "true" ]]; then extra_args="--verbose" fi # mandatory variables R...

3,330 views 3 22
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