Index: src/com/servoy/plugins/BehaviorProvider.java =================================================================== --- src/com/servoy/plugins/BehaviorProvider.java (revision 60) +++ src/com/servoy/plugins/BehaviorProvider.java (working copy) @@ -253,7 +253,41 @@ Debug.error(e); } } - + + public void addGlobalJsReference(Object url) + { + try + { + Method method = app.getPageContributor().getClass().getMethod("addGlobalJSResourceReference", url.getClass()); + method.invoke(app.getPageContributor(), url); + } + catch (NoSuchMethodException ex) + { + throw new UnsupportedOperationException("Cannot add global js reference. This operation is not supported for Servoy versions lower than 7.3"); + } + catch (Exception e) + { + Debug.error(e); + } + } + + public void removeGlobalJsReference(Object url) + { + try + { + Method method = app.getPageContributor().getClass().getMethod("removeGlobalResourceReference", url.getClass()); + method.invoke(app.getPageContributor(), url); + } + catch (NoSuchMethodException ex) + { + throw new UnsupportedOperationException("Cannot remove global js reference. This operation is not supported for Servoy versions lower than 7.3"); + } + catch (Exception e) + { + Debug.error(e); + } + } + /* public interface ILatestPageBehaviorListener extends IBehaviorListener { Index: src/com/servoy/plugins/WebClientProvider.java =================================================================== --- src/com/servoy/plugins/WebClientProvider.java (revision 60) +++ src/com/servoy/plugins/WebClientProvider.java (working copy) @@ -298,7 +298,12 @@ } else if ("removeGlobalCssReference".equals(method)) { return "%%elementName%%.removeGlobalCssReference(''http://yourserver.com/css/yourstyle.css');\n" + ((SERVOY_WEB_RESOURCES.YUI_CSS_FONTS == null) ? "" : "\t// you can also remove Servoy internal reference scripts (like Yahoo UI widgets):\n\t%%elementName%%.removeGlobalCssReference(SERVOY_WEB_RESOURCES.YUI_CSS_MENU)"); - + } else if ("addGlobalJsReference".equals(method)) { + return "%%elementName%%.addGlobalJsReference(''http://yourserver.com/js/yourstyle.js');\n" + ((SERVOY_WEB_RESOURCES.YUI_CSS_FONTS == null) ? "" : + "\t// you can also add Servoy internal reference scripts (like Yahoo UI widgets):\n\t%%elementName%%.addGlobalCssReference(SERVOY_WEB_RESOURCES.YUI_CSS_MENU)"); + } else if ("removeGlobalJsReference".equals(method)) { + return "%%elementName%%.removeGlobalCssReference(''http://yourserver.com/js/yourstyle.js');\n" + ((SERVOY_WEB_RESOURCES.YUI_CSS_FONTS == null) ? "" : + "\t// you can also remove Servoy internal reference scripts (like Yahoo UI widgets):\n\t%%elementName%%.removeGlobalCssReference(SERVOY_WEB_RESOURCES.YUI_CSS_MENU)"); } return null; @@ -316,6 +321,8 @@ return "Returns a Servoy markup Id to be used in your browser scripts"; else if ("removeJsReference".equals(method)) return "Removes a javascript url" + ((SERVOY_WEB_RESOURCES.YUI_CSS_FONTS == null) ? "" : " or build in servoy javascript reference (see SERVOY_WEB_RESOURCES)"); + else if ("removeGlobalJsReference".equals(method)) + return "Removes a global javascript url" + ((SERVOY_WEB_RESOURCES.YUI_CSS_FONTS == null) ? "" : " or build in servoy javascript reference (see SERVOY_WEB_RESOURCES)"); else if ("removeCssReference".equals(method)) return "Removes a css url" + ((SERVOY_WEB_RESOURCES.YUI_CSS_FONTS == null) ? "" : " or build in servoy css reference (see SERVOY_WEB_RESOURCES)"); else if ("removeGlobalCssReference".equals(method)) @@ -322,6 +329,8 @@ return "Removes a global css url" + ((SERVOY_WEB_RESOURCES.YUI_CSS_FONTS == null) ? "" : " or build in servoy css reference (see SERVOY_WEB_RESOURCES)"); else if ("addJsReference".equals(method)) return "Adds a javascript url" + ((SERVOY_WEB_RESOURCES.YUI_CSS_FONTS == null) ? "" : " or build in servoy javascript reference (see SERVOY_WEB_RESOURCES) to the page"); + else if ("addGlobalJsReference".equals(method)) + return "Adds a global js url" + ((SERVOY_WEB_RESOURCES.YUI_CSS_FONTS == null) ? "" : " or build in servoy javascript reference (see SERVOY_WEB_RESOURCES) to the page"); else if ("addCssReference".equals(method)) return "Adds a css url" + ((SERVOY_WEB_RESOURCES.YUI_CSS_FONTS == null) ? "" : " or build in servoy css reference (see SERVOY_WEB_RESOURCES) to the page"); else if ("addGlobalCssReference".equals(method)) @@ -527,7 +536,43 @@ BehaviorProvider bp = getBehavior(); if (bp != null) bp.addGlobalCssReference(url); } + + public void js_addGlobalJsReference(String url) { + addGlobalJsReference(url); + } + + public void js_addGlobalJsReference(ResourceReference url) { + addGlobalJsReference(url); + } + + public void js_removeGlobalJsReference(String url) { + removeGlobalJsReference(url); + } + + public void js_removeGlobalJsReference(ResourceReference url) { + removeGlobalJsReference(url); + } + private void addGlobalJsReference(String url) { + BehaviorProvider bp = getBehavior(); + if (bp != null) bp.addGlobalJsReference(url); + } + + private void addGlobalJsReference(ResourceReference url) { + BehaviorProvider bp = getBehavior(); + if (bp != null) bp.addGlobalCssReference(url); + } + + public void removeGlobalJsReference(ResourceReference url) { + BehaviorProvider bp = getBehavior(); + if (bp != null) bp.removeGlobalJsReference(url); + } + + public void removeGlobalJsReference(String url) { + BehaviorProvider bp = getBehavior(); + if (bp != null) bp.removeGlobalJsReference(url); + } + public void js_addJsReference(String url) { addJsReference(url); }