Hi All ,
I want to redirect the user to a version tab panel(created through a plugin) after the user creates a version. How can this be done ? In 4.3 there is a AddVersion action which can be extended and for 4.4 there is an Add Version Event .
Please can someone help me with this .
Thanx
I wouldn't modify any of the files in jira.
Instead, add the following using a web resource context, or just put in announcement banner:
AJS.$(function () { AJS.$("#project-config-versions-add").submit(function() { window.location.href = "http://www.google.com"; }); });
That's just an example - you should check the return code of the ajax call, and only if valid and the version is created should you redirect. I'm putting this code very much as a starting point only...
like that!
(10 characters needed in comment? )
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanx Jamie :) , the script works fine for 4.4 but not for 4.3 . what changes should i make to make this script work in 4.3 ?
and by web resource context you meant web resource plugin module ?
In my url i need the project key and the created version id , will i be able to get that in the script ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
for 4.3 you need to do it the old way AFAIK.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
For 4.3 i am trying the below code to redirect in the class which extends the AddVersion action
Redirect redirect=(Redirect)ActionFactory.getAction(Action.SUCCESS); redirect.setUrl("http://www.google.com"); return redirect.execute();
but i get an exception
java.lang.IllegalArgumentException: Action 'success' not found or could not be initialized a class with that name could not be found.
Is the correct way to redirect ?
i also tried by adding a new <view> in the plugin.xml and return to that view but i get an exception
java.lang.illegalstateexception cannot forward after response has been committed
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jamie,
with the old way i am not able to redirect to the version tab .
i used the following
return getRedirect("../../browse/"+pKey+"/fixforversion/"+vId+"");
Is this correct ? am i missing something ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jobin, When i use the above return statement i get a java.lang.IllegalStateException
and the URL is :http://localhost:2990/jira/secure/project/AddVersion.jspa?atl_token=BV8N-OK2J-IQUQ-YNNK|90ac7060aaed2a887488c89579c0438382ac78e8|lin&pid=10000
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I am sorry , i did not get , which token at the end ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
For testing i had used this as a URL
return getRedirect("/browse/RM/fixforversion/10221");
a valid pkey and version id .
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
cool. But it is still missing the token. Just a wild guess.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Maybe it is because of the missing token in the end? Can you try adding that too in the URL and see if it helps?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
?atl_token=BV8N-OK2J-IQUQ-YNNK|90ac7060aaed2a887488c89579c0438382ac78e8|lin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I tried with the token but its still not redirecting and giving the same exception(java.lang.IllegalStateException) when i add a version .
My tab is in the first position so its displayed by default when i redirect to browse/RM/fixforversion/10221
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jamie ,
How can i check the return code of the ajax call in the script provided by you.
AJS.$(function () { AJS.$("#project-config-versions-add").submit(function() { window.location.href = "http://www.google.com"; }); });
Also the URL contains the version id which is created , can this be possible ?
Thank you
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Mizan,
I have implemented AddVersion 4.3 in do execute method i have put this
{
String url="http://localhost:2990/jira/browse/MP/fixforversion/10001";
return getRedirect(url);
}
i am able to redirect properly.
problem:- i am not able to add new version from Manage Versions even it is not showing in versions list. but i am able to get in my code via super.getName();
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You are able to redirect and the version is not getting added because you have not called the super.doExecute()
super.getName() returns the name you have entered not the version name
I dont know why its not redirecting
@Override protected String doExecute() throws Exception { Long vid = null; String ret_val = super.doExecute(); if (!ret_val.equals(Action.ERROR)){ String verName=getName(); System.out.println("Version name from add version:"+verName); String in=getProjectObject().getKey(); System.out.println("pid:"+in); Collection<Version> version1=getVersionManager().getVersionsByName(verName); Iterator i=version1.iterator(); if(i.hasNext()) { Version v=(Version) i.next(); vid=v.getId(); } return getRedirect("/browse/"+in+"/fixforversion/"+vid+""); } else{ System.out.println("this is a error"+ret_val); return ret_val; } }
Above is my code
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
i have done with Redirection
i just have @overiden all methods AddVersion in my class.
addition to that i have called super(authenticationContext,versionService); constructor.
the basic change in code is doexucute method is : return getRedirect("/browse/MP/fixforversion/10002");
prior to this it was : returning as return getRedirect("ManageVersions.jspa?pid=" + getProjectObject().getId());
now its working fine.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Tousif , From Jira source i noticed that doExecute() returns getRedirect("ManageVersions.jspa?pid=" + getProjectObject().getId());
I did as you said and replaced
getRedirect("ManageVersions.jspa?pid=" + getProjectObject().getId());
with
return getRedirect("/browse/"+pkey+"/fixforversion/"+vid);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Try
return getRedirect("/browse/"+pKey+"/fixforversion/"+vId);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanx , so it is possible to redirect after listening the VersionCreateEvent ? for 4.3 i am trying to redirect using the getRedirect("url");
eg:
return getRedirect("../../browse/"+pKey+"/fixforversion/"+vId+"");
but this does not help i get a java.lang.IllegalStateException
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Which js files i will have to modify ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Listeners run in a different thread. So redirecting in a listener is not possible. You should modify the Javascript files as Jamie mentioned!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It's done through a rest call in 4.4, so I think you would need to write some javascript to plug in to that. It won't be as simple as the old way.
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.