From 48d71153c397d1715430773df3bb05102e962913 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Wed, 13 Oct 2010 16:01:09 +0200 Subject: [PATCH] Always store the current Sone in the template. --- src/main/java/net/pterodactylus/sone/web/CreateSonePage.java | 1 + src/main/java/net/pterodactylus/sone/web/LoginPage.java | 1 + src/main/java/net/pterodactylus/sone/web/LogoutPage.java | 1 + src/main/java/net/pterodactylus/sone/web/SoneTemplatePage.java | 9 +++++++++ 4 files changed, 12 insertions(+) diff --git a/src/main/java/net/pterodactylus/sone/web/CreateSonePage.java b/src/main/java/net/pterodactylus/sone/web/CreateSonePage.java index 81f1c34..f15fe04 100644 --- a/src/main/java/net/pterodactylus/sone/web/CreateSonePage.java +++ b/src/main/java/net/pterodactylus/sone/web/CreateSonePage.java @@ -59,6 +59,7 @@ public class CreateSonePage extends SoneTemplatePage { */ @Override protected void processTemplate(Request request, Template template) throws RedirectException { + super.processTemplate(request, template); String name = ""; String requestUri = null; String insertUri = null; diff --git a/src/main/java/net/pterodactylus/sone/web/LoginPage.java b/src/main/java/net/pterodactylus/sone/web/LoginPage.java index 7e99b32..a72fd02 100644 --- a/src/main/java/net/pterodactylus/sone/web/LoginPage.java +++ b/src/main/java/net/pterodactylus/sone/web/LoginPage.java @@ -52,6 +52,7 @@ public class LoginPage extends SoneTemplatePage { */ @Override protected void processTemplate(Request request, Template template) throws RedirectException { + super.processTemplate(request, template); Set localSones = webInterface.core().localSones(); template.set("sones", localSones); if (request.getMethod() == Method.POST) { diff --git a/src/main/java/net/pterodactylus/sone/web/LogoutPage.java b/src/main/java/net/pterodactylus/sone/web/LogoutPage.java index a4730ad..f173bbb 100644 --- a/src/main/java/net/pterodactylus/sone/web/LogoutPage.java +++ b/src/main/java/net/pterodactylus/sone/web/LogoutPage.java @@ -47,6 +47,7 @@ public class LogoutPage extends SoneTemplatePage { @Override protected void processTemplate(Request request, Template template) throws RedirectException { setCurrentSone(request.getToadletContext(), null); + super.processTemplate(request, template); throw new RedirectException("index.html"); } diff --git a/src/main/java/net/pterodactylus/sone/web/SoneTemplatePage.java b/src/main/java/net/pterodactylus/sone/web/SoneTemplatePage.java index 49bd26d..c271024 100644 --- a/src/main/java/net/pterodactylus/sone/web/SoneTemplatePage.java +++ b/src/main/java/net/pterodactylus/sone/web/SoneTemplatePage.java @@ -162,6 +162,15 @@ public class SoneTemplatePage extends TemplatePage { * {@inheritDoc} */ @Override + protected void processTemplate(Request request, Template template) throws RedirectException { + super.processTemplate(request, template); + template.set("currentSone", getCurrentSone(request.getToadletContext())); + } + + /** + * {@inheritDoc} + */ + @Override protected String getRedirectTarget(Page.Request request) { if (requiresLogin() && (getCurrentSone(request.getToadletContext()) == null)) { return "login.html"; -- 2.7.4