use of org.eclipse.rap.rwt.client.service.JavaScriptExecutor in project rap by entirej.
the class RWTUtils method patchClient.
public static void patchClient(String conext, String timeoutPage) {
// https://github.com/eclipse/rap/blob/master/bundles/org.eclipse.rap.rwt/js/rwt/runtime/ErrorHandler.js
JavaScriptExecutor executor = RWT.getClient().getService(JavaScriptExecutor.class);
StringBuilder builder = new StringBuilder();
builder.append("(function() {");
builder.append("console.log('patchClient');");
builder.append(" var errorHandler = rwt.runtime.ErrorHandler;");
builder.append(" var origShowErrorBox = rwt.util.Functions.bind(errorHandler.showErrorBox, errorHandler );");
builder.append(" errorHandler.showErrorBox = function( errorType,freeze, errorDetails ) {");
builder.append("console.log(errorType +' - '+errorDetails);");
// enable if IE issue with connections
// builder.append(" if( errorType === \"connection error\" ) {");
// builder.append(" settimeout( function() {");
// builder.append(" rwt.remote.Connection.getInstance()._retry();");
// builder.append(" }, 100 );} else");
builder.append(" if( errorType === \"session timeout\" || errorType === \"client error\" ) {");
if (timeoutPage == null || timeoutPage.isEmpty())
builder.append(" parent.window.location.href = this._getRestartURL();");
else
builder.append(" parent.window.location.href = \"").append(timeoutPage).append("\";");
builder.append(" ");
builder.append(" ");
builder.append(" ");
builder.append(" ");
builder.append(" } else {");
builder.append(" origShowErrorBox( errorType, freeze,errorDetails );");
builder.append(" }");
builder.append(" };");
builder.append("}() );");
// System.err.println(builder.toString());
executor.execute(builder.toString());
}
use of org.eclipse.rap.rwt.client.service.JavaScriptExecutor in project rap by entirej.
the class EJRwtSpringAuthUtil method logout.
public static void logout() {
StringBuffer url = new StringBuffer();
url.append(RWT.getRequest().getContextPath());
String encodeURL = RWT.getResponse().encodeURL(url.toString());
if (encodeURL.contains("jsessionid")) {
encodeURL = encodeURL.substring(0, encodeURL.indexOf("jsessionid"));
}
encodeURL += "logout";
String browserText = MessageFormat.format("parent.window.location.href = \"{0}\";", encodeURL);
JavaScriptExecutor executor = RWT.getClient().getService(JavaScriptExecutor.class);
if (executor != null) {
executor.execute(browserText);
}
}
Aggregations