Does it exists a global function similar to the provided by the following method;
It returns the url for any other action defined in the plugin, but it can only be invoked by an action extending the JiraWebActionSupport class.
I need to call an action from a menu.
Just what I was looking for!
But it has a little problem: the context of the JIRA application:
In the first case, it must be invoked: /secure/YourActionName.jspa
Inthe second: /jira/secure/YourActionName.jspa
Is there an API function providing the context? Maybe by analyzing the JIRA base url to get it...
I believe ActionContext.getResponse().sendRedirect(location) will append the correct contextPath. Haven't tried it though, but the Javadocs seem accurate enough
This method can accept relative URLs; the servlet container must convert the relative URL to an absolute URL before sending the response to the client. If the location is relative without a leading '/' the container interprets it as relative to the current request URI. If the location is relative with a leading '/' the container interprets it as relative to the servlet container root.
Florin is right, but there is an even easier way, your Action classes (should?) probably subclass JiraWebActionSupport, and so, can call: getRedirect("secure/yourapp/Thing!view.jspa"); so long as your action then returns NULL, you will get redirected, with context set accordingly if present.
The problem is that the code is not inside an action, it's in a menu builder. Hence, neither
>var contextPath =
can be invoked because is a client based solution nor
because I don't want redirect anything. Simply, pass the menu links to JIRA and let it decide when to redirect (due an user action).
I got at my email another suggestion from from Andy Brook (and not listed in answers !?):
JiraWebActionSupport, and so, can call: getRedirect("secure/yourapp/Thing!view.jspa");
but as the code is not within an action... I tried to create an object by:
JireWebActionSupport jwas = new JiraWebActionSupport(); jwas.getRedirect(...);
but it did not work.
Based on a Florin's suggestion I tried to get the context from the servlet:
that would be perfect. Unfortunately, as it's not invoked from within an action, ActionContext.getRequest() returns null :(
Anyway it opens a new way: is it possible to get the HttpServletRequest from ANYWHERE (not only from an action)?
The action is called from a SimpleLinkFactory (implemented by a class) as described in the following link and in the Jobin's book:
The links are built from within that class. If the contextPath is not added (/jira/secure/MyAction.jspa) then the action is not found. When the context path is present, then it works.
It started as any story starts, on a normal, rainy day. Admin meets App, and her name was Klok2, and like any first relationship we were both trying to make it work but neither one knew what...
Connect with like-minded Atlassian users at free events near you!Find a group
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no AUG chapters near you at the moment.Start an AUG
You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs