From 19ede23a86bee9ee86ed1b6d8413f633eecdfc47 Mon Sep 17 00:00:00 2001 From: srosse <none@none> Date: Thu, 2 Apr 2015 12:39:54 +0200 Subject: [PATCH] OO-1506: if the issue occured, trigger a full page refresh instead of a red screen --- .../CannotReplaceDOMFragmentException.java | 36 +++++++++++++++++++ .../org/olat/core/gui/components/Window.java | 14 +++++--- .../gui/control/winmgr/AjaxController.java | 34 +++++++++++------- 3 files changed, 67 insertions(+), 17 deletions(-) create mode 100644 src/main/java/org/olat/core/gui/components/CannotReplaceDOMFragmentException.java diff --git a/src/main/java/org/olat/core/gui/components/CannotReplaceDOMFragmentException.java b/src/main/java/org/olat/core/gui/components/CannotReplaceDOMFragmentException.java new file mode 100644 index 00000000000..dc4cbe3cf23 --- /dev/null +++ b/src/main/java/org/olat/core/gui/components/CannotReplaceDOMFragmentException.java @@ -0,0 +1,36 @@ +/** + * <a href="http://www.openolat.org"> + * OpenOLAT - Online Learning and Training</a><br> + * <p> + * Licensed under the Apache License, Version 2.0 (the "License"); <br> + * you may not use this file except in compliance with the License.<br> + * You may obtain a copy of the License at the + * <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a> + * <p> + * Unless required by applicable law or agreed to in writing,<br> + * software distributed under the License is distributed on an "AS IS" BASIS, <br> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br> + * See the License for the specific language governing permissions and <br> + * limitations under the License. + * <p> + * Initial code contributed and copyrighted by<br> + * frentix GmbH, http://www.frentix.com + * <p> + */ +package org.olat.core.gui.components; + +/** + * + * Initial date: 02.04.2015<br> + * @author srosse, stephane.rosse@frentix.com, http://www.frentix.com + * + */ +public class CannotReplaceDOMFragmentException extends Exception { + + private static final long serialVersionUID = 3257788145928610855L; + + public CannotReplaceDOMFragmentException(String msg) { + super(msg); + } + +} diff --git a/src/main/java/org/olat/core/gui/components/Window.java b/src/main/java/org/olat/core/gui/components/Window.java index 1128a28f801..f4ebd4ad67f 100644 --- a/src/main/java/org/olat/core/gui/components/Window.java +++ b/src/main/java/org/olat/core/gui/components/Window.java @@ -449,8 +449,14 @@ public class Window extends AbstractComponent { long durationBeforeHandleDirties = System.currentTimeMillis() - debug_start; log.debug("Perf-Test: Window durationBeforeHandleDirties=" + durationBeforeHandleDirties); } - Command co = handleDirties(); - //fxdiff FXOLAT-119: update business path + Command co; + try { + co = handleDirties(); + } catch (CannotReplaceDOMFragmentException e) { + String reRenderUri = buildURIFor(this, timestampID, null); + co = CommandFactory.createParentRedirectTo(reRenderUri); + } + //update the business path Command co2 = handleBusinessPath(ureq); if (isDebugLog) { long durationAfterHandleDirties = System.currentTimeMillis() - debug_start; @@ -861,7 +867,7 @@ public class Window extends AbstractComponent { * @return a updateUI-Command or null if there are no dirty components (normally not the case for sync (user-click) request, but often the case * for pull request, since nothing has changed yet on the screen. */ - public Command handleDirties() { + public Command handleDirties() throws CannotReplaceDOMFragmentException { // need to sync to window, since the dispatching must be finished so that the render tree is stable before we collect the dirties. // more accurately, the synchronized is needed when other classes than window call this method. synchronized(this) { @@ -933,7 +939,7 @@ public class Window extends AbstractComponent { } boolean wasDomR = toRender.isDomReplaceable(); if (!wasDomR) { - throw new AssertException("cannot replace as dom fragment:"+toRender.getComponentName()+" ("+toRender.getClass().getName()+"),"+toRender.getExtendedDebugInfo()); + throw new CannotReplaceDOMFragmentException("cannot replace as dom fragment:"+toRender.getComponentName()+" ("+toRender.getClass().getName()+"),"+toRender.getExtendedDebugInfo()); } Panel wrapper = new Panel("renderpanel"); diff --git a/src/main/java/org/olat/core/gui/control/winmgr/AjaxController.java b/src/main/java/org/olat/core/gui/control/winmgr/AjaxController.java index 3cfc6809dde..c7bdda3b1f1 100644 --- a/src/main/java/org/olat/core/gui/control/winmgr/AjaxController.java +++ b/src/main/java/org/olat/core/gui/control/winmgr/AjaxController.java @@ -48,6 +48,7 @@ import org.olat.core.dispatcher.mapper.manager.MapperKey; import org.olat.core.gui.UserRequest; import org.olat.core.gui.UserRequestImpl; import org.olat.core.gui.Windows; +import org.olat.core.gui.components.CannotReplaceDOMFragmentException; import org.olat.core.gui.components.Component; import org.olat.core.gui.components.Window; import org.olat.core.gui.components.panel.Panel; @@ -133,21 +134,28 @@ public class AjaxController extends DefaultController { reload = cc.wishAsyncReload(ureq, false); } - // check for dirty components now. - wboImpl.fireCycleEvent(Window.BEFORE_INLINE_RENDERING); - Command updateDirtyCom = window.handleDirties(); - wboImpl.fireCycleEvent(Window.AFTER_INLINE_RENDERING); - - if (updateDirtyCom != null) { - synchronized (windowcommands) { //o_clusterOK by:fj - windowcommands.add(new WindowCommand(wboImpl, updateDirtyCom)); - if(reload) { - String timestampID = ureq.getTimestampID(); - String reRenderUri = window.buildURIFor(window, timestampID, null); - Command rmrcom = CommandFactory.createParentRedirectTo(reRenderUri); - windowcommands.add(new WindowCommand(wboImpl, rmrcom)); + try { + // check for dirty components now. + wboImpl.fireCycleEvent(Window.BEFORE_INLINE_RENDERING); + Command updateDirtyCom = window.handleDirties(); + wboImpl.fireCycleEvent(Window.AFTER_INLINE_RENDERING); + + if (updateDirtyCom != null) { + synchronized (windowcommands) { //o_clusterOK by:fj + windowcommands.add(new WindowCommand(wboImpl, updateDirtyCom)); + if(reload) { + String timestampID = ureq.getTimestampID(); + String reRenderUri = window.buildURIFor(window, timestampID, null); + Command rmrcom = CommandFactory.createParentRedirectTo(reRenderUri); + windowcommands.add(new WindowCommand(wboImpl, rmrcom)); + } } } + } catch (CannotReplaceDOMFragmentException e) { + String timestampID = ureq.getTimestampID(); + String reRenderUri = window.buildURIFor(window, timestampID, null); + Command rmrcom = CommandFactory.createParentRedirectTo(reRenderUri); + windowcommands.add(new WindowCommand(wboImpl, rmrcom)); } return extractMediaResource(false); } -- GitLab