From: David ‘Bombe’ Roden Date: Thu, 25 Nov 2010 07:39:53 +0000 (+0100) Subject: Add possibility to perform actions after the template has been rendered. X-Git-Tag: 0.3.1-RC1~30 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=73047ddcb9d707b645871f12bc0f3c981bcac743;p=Sone.git Add possibility to perform actions after the template has been rendered. --- 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. *