Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

AUI Form Validation in Jira PostFunction Plugin

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">

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

$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?



1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

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

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

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.

Good news! I finally got the validation working by using the cdn imports. I added <link rel="stylesheet" href="//" media="all"> <!--[if IE 9]><link rel="stylesheet" href="//" media="all"><![endif]--> <script src="//"></script> <script src="//"></script> <link rel="stylesheet" href="//" media="all"> <script src="//"></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.


Atlassian Community Events