You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.
View groupJoin the community to find out what other Atlassian users are discussing, debating and creating.
I am using following code in velocity template for Project Tab Panel plugin module.
<script> AJS.$(document).ready(function() { alert(getCurrentUserName()); }); function getCurrentUserName() { var user; AJS.$.ajax({ url: "/rest/gadget/1.0/currentUser", type: 'get', dataType: 'json', async: false, success: function(data) { user = data.username; } }); return user; } </script>
When I visit my tab panel I get this error message.....
An error occurred whilst rendering this message. Please contact the administrators, and inform them of this bug. Details: ------- org.apache.velocity.exception.ParseErrorException: Encountered "{" at com.elixir.jira.CustomerIssuesProjectTabPanel:cs-customers-only/templates/tabpanels/cs-customers-only.vm[line 17, column 17] Was expecting one of: <EOF> "(" ... <RPAREN> ... <ESCAPE_DIRECTIVE> ... <SET_DIRECTIVE> ... "##" ... "\\\\" ... "\\" ... <TEXT> ... "*#" ... "*#" ... <STRING_LITERAL> ... <IF_DIRECTIVE> ... <STOP_DIRECTIVE> ... <INTEGER_LITERAL> ... <FLOATING_POINT_LITERAL> ... <WORD> ... <BRACKETED_WORD> ... <IDENTIFIER> ... <DOT> ... "{" ... "}" ... at org.apache.velocity.Template.process(Template.java:141) at
Please note that all AJS functions are working .. it produces error on ajax calls only .. what is the solution .. I have been stuck in it like forever...
Community moderators have prevented the ability to post new answers.
The problem is that the velocity engine is interpreting the "$." from "AJS.$.ajax" as a valid directive. You should include all the javascript in a web-resource and then include it in the velocity file (or require it from your panel class) so it won't be parsed.
See this for more info: https://developer.atlassian.com/display/JIRADEV/Web+Resource+Plugin+Module#WebResourcePluginModule-ReferringtoWebResources
So just try it with jQuery.ajax instead of AJS.$.ajax?!
Am I wrong or should work, when velocity is ignoring the block?
#[[<script>...</script>]]#
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I've had some trouble using jQuery directly and that's why I usually try to avoid that syntax, but yes, that should work as well.
I've never used #[[ ]]#, but if it does what you say, it should work. Maybe the velocity engine in JIRA is outdated (?).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Looking into the sources for JIRA 6.0.5, they use a custom version of the velocity engine 1.6.4-atlassian-4, which I guess is based on velocity 1.6.4. The #[[ ]]# syntax was added in version 1.7 according to their changelogs ( http://velocity.apache.org/engine/releases/velocity-1.7/changes-report.html ) and this https://issues.apache.org/jira/browse/VELOCITY-661 , so that's probably why it doesn't work.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The Script works as expected, when I excecute it in firebug.
You can try to avoid velocity parse the scriptblock by writing:
#[[<script>...</script>]]#
As described here: http://stackoverflow.com/questions/6828342/velocity-how-to-avoid-parseerrorexception-when-using-jquery
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
try with this script
<script type="text/javascript"> jQuery(document).ready( function($) { //you can get current user like this alert("User :: "+AJS.params.loggedInUser ); alert(" RemoteUser :: "+AJS.params.remoteUser); //or like this alert(getCurrentUserName()); function getCurrentUserName() { var user; AJS.$.ajax({ url: "/rest/gadget/1.0/currentUser", type: 'get', dataType: 'json', async: false, success: function(data) { user = data.username; } }); return user; } }); </script>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Connect with like-minded Atlassian users at free events near you!
Find an eventConnect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.
Host an eventYou're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.