Hi,
Does it exists a global function similar to the provided by the following method;
com.atlassian.jira.web.action.JiraWebActionSupport.getRedirect(String arg0)
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.
Many thanks,
Pablo
You should be able to call it from anywhere using a link like this:
/secure/YouActionName!viewName.jspa
Doesn't that work? For a menu, use a web-item.
/secure/YouActionName!viewName.jspa
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...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You can also build the url client-side. There should be a
<script type="text/javascript">var contextPath = '';</script>
on every page, with the appropriate value.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The problem is that the code is not inside an action, it's in a menu builder. Hence, neither
<script
type
=
"text/javascript"
>var contextPath =
''
;<
/script
>
can be invoked because is a client based solution nor
ActionContext.getResponse().sendRedirect(location)
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:
ActionContext.getRequest().getContextPath();
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)?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If it is from a web-item, you don't need to append context path. If not, where is your code? What kind of plugin module is it?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Jobin is right. Web-items do not require a context path. So if those aren't web-items, what are they? What is that menu builder you are using? When is it called and what does it do?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The action is called from a SimpleLinkFactory (implemented by a class) as described in the following link and in the Jobin's book:
https://answers.atlassian.com/questions/69412/adding-dynamic-links-to-user-s-top-navigation-bar
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This will get you the full base url.
ComponentAccessor.getApplicationProperties().getString(APKeys.JIRA_BASEURL)
Use ComponentManager is the older JIRA versions.
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.