Get a web-item to link to java code

Lailoken42 August 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
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 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.

Cheers,

Adam

0 votes
EddieW
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 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)

https://developer.atlassian.com/stash/docs/latest/how-tos/creating-a-stash-plugin.html

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

https://developer.atlassian.com/stash/docs/latest/reference/plugin-module-types/plugin-modules.html

* matching the UI

https://developer.atlassian.com/display/AUI/Buttons

Lailoken42 August 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 "http://www.google.com". 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!

Corin

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events