\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
\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
\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
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
* 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
* 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