\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
import org.apache.wicket.markup.html.basic.Label;\r
import org.apache.wicket.markup.html.link.ExternalLink;\r
import org.apache.wicket.markup.html.panel.FeedbackPanel;\r
+import org.apache.wicket.markup.html.resources.JavascriptResourceReference;\r
+import org.apache.wicket.markup.repeater.RepeatingView;\r
import org.apache.wicket.protocol.http.RequestUtils;\r
import org.apache.wicket.protocol.http.WebResponse;\r
import org.apache.wicket.protocol.http.servlet.ServletWebRequest;\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
return sb.toString();\r
}\r
\r
+ /**\r
+ * Adds a HTML script element loading the javascript designated by the given path.\r
+ *\r
+ * @param scriptPath\r
+ * page-relative path to the Javascript resource; normally starts with "script/"\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
+ }\r
+\r
+ /**\r
+ * Adds a HTML script element containing the given code.\r
+ *\r
+ * @param code\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
+ }\r
+\r
}\r