Add possibility to perform actions after the template has been rendered.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 25 Nov 2010 07:39:53 +0000 (08:39 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 25 Nov 2010 07:39:53 +0000 (08:39 +0100)
src/main/java/net/pterodactylus/sone/web/page/TemplatePage.java

index a6373fc..9cf9c17 100644 (file)
@@ -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.
         *