Hi,
I need to refresh the browser page by writing code in java class of my plugin. Please suggest if it is possible.
Thanks,
Bharadwaj Jannu
Hello @Bharadwaj Jannu
It is server/client related. Server serves the client, not vice versa. It is up to the client to decide when he requests content. It is not up to the server to deliver new content to the client when the client didnt asked for it. Hence it is the client (browser) which has to decide when a page needs to be refreshed. So theoreticaly youre limited to code that runs on client side, i.e. javascript / ajax etc...
In jira you can however trigger a redirect in some cases. In a WebWork action you can use
return returnComplete(appProperties.getBaseUrl() + "/secure/Page.jspa");
this will trigger redirect to another page or reload the current one.
hi Alexej Geldt,
where can we find returnComplete(...) method in jira and how it can be used in webwork actions?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Bharadwaj Jannu
It comes from JiraWebActionSupport which you extend in your web action controller.
public class MyAction extends JiraWebActionSupport { private final ApplicationProperties appProperties; public MyAction(final ApplicationProperties appProperties) { this.appProperties = appProperties; } @Override public String execute() throws Exception { return returnComplete(appProperties.getBaseUrl() + "/secure/MySite.jspa"); } }
you can also use it in commands of a webwork action.
example:
public String doSomeCommand() { ... return returnComplete(url); }
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi Alexeh Geldt,
I tried the above code with my required modifications, the execute() method is not getting invoked after inline editing is done.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Bharadwaj Jannu
inline edit in a webwork action? It can be done with fields as far as i know, not with actions. I think we are talking about different things. Are you sure a webwork action is the right thing to do?
please show me some of your code, im not quite sure what youre trying.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
RefreshAction.java
package com.td.inline.ref;
import com.atlassian.jira.web.action.JiraWebActionSupport;
import com.atlassian.sal.api.ApplicationProperties;
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.config.properties.APKeys;
import com.atlassian.jira.issue.Issue;
public class RefreshAction extends JiraWebActionSupport
{
private final ApplicationProperties appProperties;
private Issue issue;
private ComponentAccessor comAcc;
public RefreshAction(ApplicationProperties appProperties,ComponentAccessor comAcc,Issue issue)
{
this.appProperties = appProperties;
this.issue=issue;
this.comAcc=comAcc;
}
@Override
public String execute() throws Exception
{
System.out.println("test for issue "+issue.getId());
System.out.println(appProperties.getBaseUrl());
System.out.println(ComponentAccessor.getApplicationProperties().getString(APKeys.JIRA_BASEURL)+"/browse/"+issue.getKey());
return returnComplete(appProperties.getBaseUrl() + "/secure/MySite.jspa");
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
no, I'm not using inline edit as a webwork action.
I am giving Due Date value, based on that Due Date at DRA1 should set and populate on screen, but the value is getting populated only after the manual refresh(Both fields are present on Dates panel of view-issue-screen).
but the things happen correctly for customfields present on other panel(Details panel) of view-issue-screen.
So somehow I need to refresh the page after inline-editing is finished.
atlassian-plugin.xml of my webwork action:
<atlassian-plugin key="${project.groupId}.${project.artifactId}" name="${project.name}" plugins-version="2">
<plugin-info>
<description>${project.description}</description>
<version>${project.version}</version>
<vendor name="${project.organization.name}" url="${project.organization.url}" />
<param name="plugin-icon">images/pluginIcon.png</param>
<param name="plugin-logo">images/pluginLogo.png</param>
</plugin-info>
<webwork1 key="refresh" name="Refresh Action" i18n-name-key="java.lang.Object">
<actions>
<action name="com.td.inline.ref.RefreshAction" alias="RefreshAction">
</action>
</actions>
</webwork1>
</atlassian-plugin>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
well you didnt set up the views.
look. A webwork is much more then just an action. It is a complete MVC module with views and action controller controlling the views with commands. You use webworks when you are introducing your own new sites. Usualy you have a couple of views (sites) which are controlled by webwork action. When you navigate to your action using alias (example: http:/localhost:8080/jira/secure/MySite.jspa), the execute method is called. When you navigate to your site with a command parameter (example: http:/localhost:8080/jira/secure/MySite!command.jspa) the command method doCommand() is called. and so on...
From your posts above i asume that youre working with details panel on the view issue screen. This is where you can actualy use inline edit. The details panel is not a webwork, it is a webpanel. So i think, webwork is not the right way for you to go. Hence you cannot expect a webwork action to control a webpanel. Webpanels are controlled by ContentProviders and not by Webwork actions. You cannot however redirect from ContentProvider.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Now back to your actual problem with refreshing.
Did i get you right, you want to trigger a refresh when inline edit on details panel for a field is done? Why would you want to refresh it? After youre finished with inline edit, the field should already show true value that you just entered...
Do you think it is a good idea to refresh entire page everytime you have set something using inline edit? Imagine you have to change 10 fields. You would end up waiting for reload every time you use inline edit.
Anyway. jira fires events on client side when content changes. So when you use inline edit, youre basically just modifying content on client side. When youre finished, an event is raised which triggers an ajax call (or rest call, not sure about that) that tells the server to update the values for the fields without having to reload entire page. Fortunaly you dont have to do that yourself, it is already wired.
You could use the same mechanism. You could catch that event which is fired when inline edit is done, and force a page reload with javascript.
Example with Javascript: (not tested)
AJS.$(function() { JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function(e, context, reason) { var $context = AJS.$(context); // do on inline edit if (reason == JIRA.CONTENT_ADDED_REASON.panelRefreshed){ // force refresh location.reload(); } }); }); });
let me explain:
JIRA.bind...
binds following code to NEW_CONTENT_ADDED event. Means, this code will run when something modifies content on client side, such as inline edit.
if (reason == JIRA.CONTENT_ADDED_REASON.panelRefreshed)...
following code will be executed if something changed the panel which youre in. So basically when inline edit is finished.
location.reload();
fires a refresh.
more on catching events on client side:: https://developer.atlassian.com/display/JIRADEV/Inline+Edit+for+JIRA+Plugins
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Probably not - the java is not really directly connected to the front end.
I suspect that the most simple way to do this is actually have some javascript/AJAX that will do it. But that doesn't go into the java, it's handled by the .jsp and .vm stuff (And soy templates in later versions, possibly)
Could you tell us what your plugin does roughly? (like "provide custom field type", "report", etc) and why and where you need the refresh to happen?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Nic,
My plugin is issue-navigator-plugin which overrides the existing one.
I am doing inline editing on fields.
I'm giving values for custom fields and updating based on some condition.
The fields getting updated but they are shown only after manual refresh of page.
So the fields should get automatically loaded when I end inline editing.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
After editing if you are redirecting to a .vm file you can add a javascript which will reload the page .for reloading using javascript see this
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ah, ok, well, that's definitely not the java side of it, it's the front end, which I believe to be mostly AJAX for the interactive stuff.
I'm out of my depth though (I'm not a developer - got simple java, but I haven't done enough with AJAX to enable me to learn anything useful). Personally, I'd take a look at how Atlassian do it on their view screens.
However, I remember a discussion from a while ago. In-line edit arrived, and Atlassian got a swathe of "this is great, but why haven't you done it on the issue navigator". The answer was "we're going that way, but it's hideously complicated, so it's not going to arrive soon". If they're hesitant about it, then I suspect that there's good reason to be scared of trying to write it.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I tried to write a script as mentioned in the link, but in a different plugin.
The script should do reloading the browser when inline edit save is done for a particular field. But I'm not able to do this.
please suggest me the solution.
Thanks,
Bharadwaj Jannu
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Is it possible to use returnComplete for a command. I tried it like return returnComplete("mycommand") but it is not working.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi Bharadwaj;
i put above code in web-resouce module of plugin but its not working
actually i have project tab panel in that i dispaly content of AO table in table form from that project tab panel vm file i called servlet in that i modify AO table and againg redirect to project tab panel class.class is get executed but that modied data is not able to show on project tab panel(browser)
after refreshing page that data get dispaly
i called servlet through ajax from tab panel
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The following code I used in web-resource module to refresh web page when a panel is modified.
AJS.$(function() { JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function(e, context, reason) { var $context = AJS.$(context); // do on inline edit if (reason == JIRA.CONTENT_ADDED_REASON.panelRefreshed){ // force refresh location.reload(); } }); });
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
require(["jira/issue", "jira/util/events", "jira/util/events/types"] , function(issue, jiraUtilEvents, EventTypes) {
jiraUtilEvents.trigger(EventTypes.REFRESH_ISSUE_PAGE, [issue.getIssueId()])
});
This should be a better approach.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi Bharadwaj,
have u get any solution for it
i also have same problem need to refresh page mannulay for showing updated changes of AO table
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.