From 73047ddcb9d707b645871f12bc0f3c981bcac743 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Thu, 25 Nov 2010 08:39:53 +0100 Subject: [PATCH] Add possibility to perform actions after the template has been rendered. --- .../net/pterodactylus/sone/web/page/TemplatePage.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/main/java/net/pterodactylus/sone/web/page/TemplatePage.java b/src/main/java/net/pterodactylus/sone/web/page/TemplatePage.java index a6373fc..9cf9c17 100644 --- a/src/main/java/net/pterodactylus/sone/web/page/TemplatePage.java +++ b/src/main/java/net/pterodactylus/sone/web/page/TemplatePage.java @@ -125,6 +125,8 @@ public class TemplatePage implements Page, LinkEnabledCallback { return new RedirectResponse(re1.getTarget()); } + postProcess(request); + StringWriter stringWriter = new StringWriter(); template.render(stringWriter); pageNode.content.addChild("%", stringWriter.toString()); @@ -167,6 +169,21 @@ public class TemplatePage implements Page, LinkEnabledCallback { } /** + * This method will be called after + * {@link #processTemplate(net.pterodactylus.sone.web.page.Page.Request, Template)} + * has processed the template and the template was rendered. This method + * will not be called if + * {@link #processTemplate(net.pterodactylus.sone.web.page.Page.Request, Template)} + * throws a {@link RedirectException}! + * + * @param request + * The request being processed + */ + protected void postProcess(Request request) { + /* do nothing. */ + } + + /** * Can be overridden to redirect the user to a different page, in case a log * in is required, or something else is wrong. * -- 2.7.4