Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How to create a form in soy templates

Annie April 24, 2013

I have added a new tab to my Repository view that will allow a user to configure my plugin. I want to add a form to this tab which has a couple of text input fields and a drop down menu, as well as a save button. I am using the combination of soy templates with servlets. I can't seem to find any tutorial that shows how to implement the form submission/validation/saving etc, all I can find is display-only type tutorials like: https://developer.atlassian.com/stash/docs/2.4.0-beta1/tutorials-and-examples/decorating-the-user-profile.html

Can anyone point me in the right direction?

1 answer

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Ulrich Kuhnhardt
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.
April 24, 2013

Have a look at the stash source. I have found the branch permission plugin very inspiring on how to use various soy templates, forms, buttons and general AUI integration.

cofarrell
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.
April 25, 2013

Hi @Annie,

Ulrich is absolutely right, do you have a copy of the Stash source? The branch permission plugin is a good place to start. Otherwise let me know and I'll try to condense a good example here.

Charles

Annie April 25, 2013

I don't have a copy of the source, no :(

cofarrell
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.
April 25, 2013

Hi Annie,

If you have a license to Stash my understanding is you should have access to the source:

https://my.atlassian.com/download/source/stash

Let me know if that's not the case.

Cheers,

Charles

Annie April 25, 2013

Ok, I've had a look at the source for that plugin, it's probably more complex than I want - I don't want my saving and editing to happen in a dialog, just on the page itself, so a simpler example would be good.

Annie April 25, 2013

Actually, I think I will just implement the form submission using a doPost on my servlet class, and validate the form values there. It's probably the simplest implementation.

Is there any reason not to do it this way? It's a little confusing with so many different ways of implemting similar functionality - servlets/rest/soy templates/velocity templates/ajax etc.

cofarrell
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.
April 25, 2013

Hi Annie,

That's a question that probably deserves a more detailed answer than I can give tonight. But some of that complexity is derived from the legacy of the Atlassian plugin system. Originally much of the technology was built on servlets and velocity templates. As things have moved more into Javascript and the client, we required a templating language that could be cross-compiled to both server and client, which is why we chose Soy. However, now we have the added complexity of shared logic between the server and client logic, depending on the context. My personal opinion is that if you can do all of the templating and rendering client-side, with ajax calls to the server, then things become a little more managable again, but that's easier said than done.

But to answer your question doing things in the doPost method is fine what you want, and will probably be the easiest to find examples for in our source.

I'm sorry we don't have a more streamlined solution. As you can see from our own plugins we have a similar problem, and have to resort to Servlets too. Ideally we could expose Spring MVC, which is what we inside Stash core, but that causes other problems. :(

Give me a yell if you get stuck.

Charles

TAGS
AUG Leaders

Atlassian Community Events