@@ -1476,6 +1476,7 @@ public class Application implements Terminal.ErrorListener, Serializable { | |||
} | |||
} | |||
Root.setCurrentRoot(root); | |||
return root; | |||
} | |||
@@ -531,6 +531,7 @@ public abstract class AbstractApplicationPortlet extends GenericPortlet | |||
} | |||
} finally { | |||
Root.setCurrentRoot(null); | |||
Application.setCurrentApplication(null); | |||
} | |||
} |
@@ -577,6 +577,7 @@ public abstract class AbstractApplicationServlet extends HttpServlet implements | |||
.onRequestEnd(request, response); | |||
} | |||
} finally { | |||
Root.setCurrentRoot(null); | |||
Application.setCurrentApplication(null); | |||
} | |||
@@ -45,6 +45,8 @@ public class Root extends AbstractComponentContainer { | |||
*/ | |||
private Component scrollIntoView; | |||
private static final ThreadLocal<Root> currentRoot = new ThreadLocal<Root>(); | |||
public Root(RootLayout rootLayout) { | |||
this.rootLayout = rootLayout; | |||
addComponent(rootLayout); | |||
@@ -446,4 +448,12 @@ public class Root extends AbstractComponentContainer { | |||
public void init(WrappedRequest request) { | |||
getRootLayout().init(request); | |||
} | |||
public static void setCurrentRoot(Root root) { | |||
currentRoot.set(root); | |||
} | |||
public static Root getCurrentRoot() { | |||
return currentRoot.get(); | |||
} | |||
} |