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

AUI Form Validation in Jira PostFunction Plugin

Ubisoft
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.
July 10, 2015

I'm seeing this question come back a lot, so I imagine that a fair amount of people are having difficulty with this.

I'm trying to add form validation to a velocity template form, and I'm having a hard time getting it to work.

In my atlassian-plugin.xml, I have added, in my web-resources for my function:

<web-resource key="myfunction-resources" name="myfunction Web Resources">
  <dependency>com.atlassian.auiplugin:ajs</dependency>
  <dependency>com.atlassian.auiplugin:aui-form-validation</dependency>
  ...
  <context>atl.general</context>
</web-resource>

In my input/edit velocity template, I've tried a few things to no avail.

require(['aui/form-validation']);
$webResourceManager.requireResource("com.atlassian.auiplugin:aui-form-validation") (in and outside of html head tags)

nothing is changing on my template after I add the elements inside of my form fields.

I've put all of them inside javascript tags, and outside, no change.

I've been looking all over the place to find someone, somewhere, that has successfully implemented this, but nothing has come up.  Clearly there must be a way to get this to work?

I'm using AUI 5.6.7, JIRA 6.3.15

I must be missing something?

Thanks, 

Eric

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Answer accepted
Ulrich Hobelmann [catworkx]
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.
July 15, 2015

I managed to get it working by performing the include in the java code for the AbstractWorkflowPluginFactory (my subclass thereof).

In my getVelocityParamsForInput() (or for Edit or View) I do a webResourceManager.requireResourcesForContext("..."), where the context in your case would be "atl.general",  but you should probably try to declare your own identifier, so atl.general won't get filled up too much. The webResourceManager can be injected in the constructor, as usual.

All dependencies you declared for the context would then be pulled automatically.

Since WebResourceManager is deprecated, if anyone knows a better working solution, please tell us smile

Ubisoft
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.
July 15, 2015

Thanks for the pointers! It seems to be loading up the resources, but i'm getting a "Uncaught Error: Syntax error, unrecognized expression: aui-focusable" error now. It's preventing me from being able to submit. Not sure if it rings a bell? Eric

Ubisoft
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.
July 15, 2015

I've got the distinct feeling that I'm very very close to getting this to work. So far the rror generates only whe my form field doesn't meet the criteria. ex: <input class="text long-field" type="text" id="Tag" name="Tag" title="Tag" data-aui-field data-aui-validate-maxlength="10" value="$textutils.htmlEncode($!Tag)"> This field works fine until I actually unfocus from it with more than 10 characters. Is generates the error and seems to be stuck in a validating state, no way to even submit or cancel it, only option is to reload the page.

Ubisoft
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.
July 17, 2015

Good news! I finally got the validation working by using the cdn imports. I added <link rel="stylesheet" href="//aui-cdn.atlassian.com/aui-adg/5.6.7/css/aui.css" media="all"> <!--[if IE 9]><link rel="stylesheet" href="//aui-cdn.atlassian.com/aui-adg/5.6.7/css/aui-ie9.css" media="all"><![endif]--> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script> <script src="//aui-cdn.atlassian.com/aui-adg/5.6.7/js/aui.js"></script> <link rel="stylesheet" href="//aui-cdn.atlassian.com/aui-adg/5.6.7/css/aui-experimental.css" media="all"> <script src="//aui-cdn.atlassian.com/aui-adg/5.6.7/js/aui-experimental.js"></script> at the top of my .vm file and now all of my validation is working. no need for the webresource manager, no dependencies needed in the atlassian-plugin, so specific mentions in the factory.

TAGS
AUG Leaders

Atlassian Community Events