Skip to content
Snippets Groups Projects
Commit 19ede23a authored by srosse's avatar srosse
Browse files

OO-1506: if the issue occured, trigger a full page refresh instead of a red screen

parent 4d542afb
No related branches found
No related tags found
No related merge requests found
/**
* <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);
}
}
......@@ -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");
......
......@@ -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);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment