]> source.dussan.org Git - gitblit.git/commitdiff
Fix regression in BasePage due to changes in page construction for bottom script...
authorJames Moger <james.moger@gitblit.com>
Tue, 25 Nov 2014 14:38:58 +0000 (09:38 -0500)
committerJames Moger <james.moger@gitblit.com>
Tue, 25 Nov 2014 14:38:58 +0000 (09:38 -0500)
src/main/java/com/gitblit/wicket/pages/BasePage.java

index fbe5861be1b1314eb40711e06cc55f09fb19aa88..0d99f5e52956f865290f630b25252ca2f962e028 100644 (file)
@@ -35,7 +35,6 @@ import javax.servlet.http.HttpServletRequest;
 \r
 import org.apache.commons.io.IOUtils;\r
 import org.apache.wicket.Application;\r
-import org.apache.wicket.Component;\r
 import org.apache.wicket.Page;\r
 import org.apache.wicket.PageParameters;\r
 import org.apache.wicket.RedirectToUrlException;\r
@@ -78,13 +77,11 @@ public abstract class BasePage extends SessionPage {
 \r
        public BasePage() {\r
                super();\r
-               add(new RepeatingView("bottomScripts").setRenderBodyOnly(true));\r
                customizeHeader();\r
        }\r
 \r
        public BasePage(PageParameters params) {\r
                super(params);\r
-               add(new RepeatingView("bottomScripts").setRenderBodyOnly(true));\r
                customizeHeader();\r
        }\r
 \r
@@ -247,7 +244,7 @@ public abstract class BasePage extends SessionPage {
 \r
        protected void setupPage(String repositoryName, String pageName) {\r
                add(new Label("title", getPageTitle(repositoryName)));\r
-\r
+               getBottomScriptContainer();\r
                String rootLinkUrl = app().settings().getString(Keys.web.rootLink, urlFor(GitBlitWebApp.get().getHomePage(), null).toString());\r
                ExternalLink rootLink = new ExternalLink("rootLink", rootLinkUrl);\r
                WicketUtils.setHtmlTooltip(rootLink, app().settings().getString(Keys.web.siteName, Constants.NAME));\r
@@ -511,6 +508,16 @@ public abstract class BasePage extends SessionPage {
                return sb.toString();\r
        }\r
 \r
+       private RepeatingView getBottomScriptContainer() {\r
+               RepeatingView bottomScriptContainer = (RepeatingView) get("bottomScripts");\r
+               if (bottomScriptContainer == null) {\r
+                       bottomScriptContainer = new RepeatingView("bottomScripts");\r
+                       bottomScriptContainer.setRenderBodyOnly(true);\r
+                       add(bottomScriptContainer);\r
+               }\r
+               return bottomScriptContainer;\r
+       }\r
+\r
        /**\r
         * Adds a HTML script element loading the javascript designated by the given path.\r
         *\r
@@ -518,14 +525,10 @@ public abstract class BasePage extends SessionPage {
         *            page-relative path to the Javascript resource; normally starts with "scripts/"\r
         */\r
        protected void addBottomScript(String scriptPath) {\r
-               Component bottomScriptContainer = get("bottomScripts");\r
-               if (bottomScriptContainer instanceof RepeatingView) {\r
-                       // Always true.\r
-                       RepeatingView bottomScripts = (RepeatingView) bottomScriptContainer;\r
-                       Label script = new Label(bottomScripts.newChildId(), "<script type='text/javascript' src='"\r
-                                       + urlFor(new JavascriptResourceReference(this.getClass(), scriptPath)) + "'></script>\n");\r
-                       bottomScripts.add(script.setEscapeModelStrings(false).setRenderBodyOnly(true));\r
-               }\r
+               RepeatingView bottomScripts = getBottomScriptContainer();\r
+               Label script = new Label(bottomScripts.newChildId(), "<script type='text/javascript' src='"\r
+                               + urlFor(new JavascriptResourceReference(this.getClass(), scriptPath)) + "'></script>\n");\r
+               bottomScripts.add(script.setEscapeModelStrings(false).setRenderBodyOnly(true));\r
        }\r
 \r
        /**\r
@@ -535,14 +538,10 @@ public abstract class BasePage extends SessionPage {
         *            inline script code\r
         */\r
        protected void addBottomScriptInline(String code) {\r
-               Component bottomScriptContainer = get("bottomScripts");\r
-               if (bottomScriptContainer instanceof RepeatingView) {\r
-                       // Always true.\r
-                       RepeatingView bottomScripts = (RepeatingView) bottomScriptContainer;\r
-                       Label script = new Label(bottomScripts.newChildId(),\r
-                                       "<script type='text/javascript'>/*<![CDATA[*/\n" + code + "\n//]]>\n</script>\n");\r
-                       bottomScripts.add(script.setEscapeModelStrings(false).setRenderBodyOnly(true));\r
-               }\r
+               RepeatingView bottomScripts = getBottomScriptContainer();\r
+               Label script = new Label(bottomScripts.newChildId(),\r
+                               "<script type='text/javascript'>/*<![CDATA[*/\n" + code + "\n//]]>\n</script>\n");\r
+               bottomScripts.add(script.setEscapeModelStrings(false).setRenderBodyOnly(true));\r
        }\r
 \r
 }\r