Получение URL страницы без параметров #PL-2122 Fixed

This commit is contained in:
Konstantin Devyatkin 2013-05-13 08:36:25 +00:00
parent 2e4d418021
commit 4ea7ee251a
2 changed files with 13 additions and 6 deletions

View File

@ -25,16 +25,22 @@ import java.util.UUID;
public abstract class ControllerUtils {
private static final String DISPATCHER = "dispatch";
public static String getWebControllerURL(String mapping) {
if (mapping == null) throw new IllegalArgumentException("Mapping cannot be null");
public static String getLocationWithoutParams() {
URI location = AppUI.getCurrent().getPage().getLocation();
String baseUrl;
try {
baseUrl = location.toURL().toExternalForm();
StringBuilder baseUrl = new StringBuilder(location.toURL().toExternalForm());
if (location.getQuery() != null) {
baseUrl.delete(baseUrl.indexOf(location.getQuery()) - 1, baseUrl.length());
}
return baseUrl.toString();
} catch (MalformedURLException e) {
throw new RuntimeException(e);
}
}
public static String getWebControllerURL(String mapping) {
if (mapping == null) throw new IllegalArgumentException("Mapping cannot be null");
String baseUrl = getLocationWithoutParams();
StringBuilder url = new StringBuilder(baseUrl).append(getDispatcher());
if (!mapping.startsWith("/")) {

View File

@ -13,6 +13,7 @@ import com.haulmont.cuba.gui.components.DialogAction;
import com.haulmont.cuba.gui.components.IFrame;
import com.haulmont.cuba.security.global.NoUserSessionException;
import com.haulmont.cuba.web.App;
import com.haulmont.cuba.web.controllers.ControllerUtils;
import com.vaadin.server.Page;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@ -60,7 +61,7 @@ public class NoUserSessionHandler extends AbstractExceptionHandler {
@Override
public void actionPerform(Component component) {
String url = Page.getCurrent().getLocation().toString() + "?restartApplication";
String url = ControllerUtils.getLocationWithoutParams() + "?restartApplication";
Page.getCurrent().open(url, "_self");
}