From 3a0ac74bb9fdcfd7c98d1db641e1acf922cee8b7 Mon Sep 17 00:00:00 2001 From: anhefti Date: Thu, 12 Sep 2019 10:14:57 +0200 Subject: [PATCH] fixed PageState bug for pop-up dialogs --- .../sebserver/gui/content/activity/ActivitiesPane.java | 2 +- .../sebserver/gui/service/page/impl/PageServiceImpl.java | 8 +++++--- .../seb/sebserver/gui/service/page/impl/PageState.java | 8 ++++++++ 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/content/activity/ActivitiesPane.java b/src/main/java/ch/ethz/seb/sebserver/gui/content/activity/ActivitiesPane.java index 30cb7818..40f0d4bd 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/content/activity/ActivitiesPane.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/content/activity/ActivitiesPane.java @@ -351,7 +351,7 @@ public class ActivitiesPane implements TemplateComposer { } else { final TreeItem item = findItemByActionDefinition( navigation.getItems(), - state.definition.activityAnchor()); + state.activityAnchor()); if (item != null) { final PageAction action = getActivitySelection(item); this.pageService.executePageAction(action, result -> { diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/page/impl/PageServiceImpl.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/page/impl/PageServiceImpl.java index 0a8c3799..60a84962 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/page/impl/PageServiceImpl.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/page/impl/PageServiceImpl.java @@ -185,9 +185,11 @@ public class PageServiceImpl implements PageService { .getUISession() .getHttpSession(); - final PageState pageState = new PageState(action.definition.targetState, action); - log.debug("Set session PageState: {} : {}", pageState, httpSession.getId()); - httpSession.setAttribute(ATTR_PAGE_STATE, pageState); + if (action != null && action.definition != null && action.definition.targetState != null) { + final PageState pageState = new PageState(action.definition.targetState, action); + log.debug("Set session PageState: {} : {}", pageState, httpSession.getId()); + httpSession.setAttribute(ATTR_PAGE_STATE, pageState); + } } catch (final Exception e) { log.error("Failed to set current PageState: ", e); } diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/page/impl/PageState.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/page/impl/PageState.java index 822173b5..9ef1bacb 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/page/impl/PageState.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/page/impl/PageState.java @@ -32,10 +32,18 @@ public final class PageState { } public Type type() { + if (this.definition == null) { + return null; + } + return this.definition.type(); } public Activity activityAnchor() { + if (this.definition == null) { + return null; + } + return this.definition.activityAnchor(); }