Community
Participate
Working Groups
Currently using RWT.getResponse().sendRedirect(url) results in a message dialog saying "The server seems to be temporarily unavailable. Would you like to retry?". Pressing Cancel leads to a page saying "Request failed. HTTP Status Code: 0" message. Pressing OK results in another message box page saying "Multiple browser-instances or browser-tabs per session are not supported. You may click OK for restarting the session." The hack described in the newsgroups ([1]) is... ugly. Please make the RWT.getResponse().sendRedirect(url) work as expected. [1] http://dev.eclipse.org/newslists/news.eclipse.technology.rap/msg02659.html
I also have that problem. It is not possible to send the redirect. (I'd like to redirect on button click).
Could you please outline your use case? Why would you want to redirect an Ajax request? Do you want to replace the page currently displayed in the browser?
I think I understand what you're trying to say. Maybe RWT.getResponse().sendRedirect(url) is not the right method to use when one wants to redirect user to another page (because it's a response to an Ajax request). But if that's the case, then it would be nice to have such a method, because the only way to do it now that I'm aware of is the one described in first comment and it's cumbersome. This method could send url to the browser so that the client-side javascript redirect the user to the specified page.
(In reply to comment #3) Exactly, RWT.getResponse().sendRedirect(url) redirects the Ajax request and cannot change the page in the browser. But I agree that there should be a way to do that with public API. Changed the title accordingly. Currently, the workaround is to use: HtmlResponseWriter writer = ContextProvider.getStateInfo().getResponseWriter(); writer.write( "parent.window.location.href=\"" + url + "\";" );
Great, this workaround is much shorter than the previous one.
I've just ried to perform a redirect as suggested in the workaround, with RAP 1.5, but the HtmlResponseWriter seems to be gone (see bug 340927). Is there an alternative way to redirect to a new webpage from a hyperlink implemented in RWT?
HtmlResponseWriter is gone, as there are no HTML or JavaScript responses anymore. In RAP 1.5, you can use this internal API: JSExecutor.execute( "parent.window.location.href=\"" + url + "\";" ); As of RAP 2.0 M3, there's finally public API to execute JavaScript on the client, see this post: http://eclipsesource.com/blogs/2012/10/17/javascriptexecutor-is-now-api/ For further questions, please use the forum.
(In reply to comment #7) > HtmlResponseWriter is gone, as there are no HTML or JavaScript responses > anymore. In RAP 1.5, you can use this internal API: > > JSExecutor.execute( "parent.window.location.href=\"" + url + "\";" ); > > As of RAP 2.0 M3, there's finally public API to execute JavaScript on the > client, see this post: > http://eclipsesource.com/blogs/2012/10/17/javascriptexecutor-is-now-api/ > For further questions, please use the forum. Tested it and it seems to work ok, apart from a typo: JSExecutor.executeJS( "parent.window.location.href=\"" + url + "\";" ); I guess that this bug can be closed then ;) Thanks for the quick response Kees
As of bug 388249, the client also accepts a "redirect" parameter in the message header. @Tim: what about a redirect service/method for the WebClient?
As of RAP 2.0 we also have UrlLauncher client service.
(In reply to Ivan Furnadjiev from comment #10) > As of RAP 2.0 we also have UrlLauncher client service. Are you sure this service can be used to replace the *current* page with another one? I think this is what this bug requested.
(In reply to Ralf Sternberg from comment #11) > (In reply to Ivan Furnadjiev from comment #10) > > As of RAP 2.0 we also have UrlLauncher client service. > > Are you sure this service can be used to replace the *current* page with > another one? I think this is what this bug requested. The UrlLauncher does not replace the current (RAP application page). Based on comment#8 JavaScriptExecutor can be used successful in this case and there is no need for other API.