ItEr24S08CUAsignacionGrupoRecursosAPlanificacionItEr23S10: Adding component to include required scripts in page

This commit is contained in:
Óscar González Fernández 2009-09-01 11:30:02 +02:00
parent e5bf394986
commit 00df8fa587
4 changed files with 50 additions and 1 deletions

View file

@ -0,0 +1,35 @@
package org.zkoss.ganttz.util.script;
import java.util.List;
import org.zkoss.ganttz.util.OnZKDesktopRegistry;
import org.zkoss.zk.ui.HtmlMacroComponent;
public class ScriptsComponent extends HtmlMacroComponent {
private ScriptDependenciesSorter dependenciesSorter;
public ScriptsComponent() {
OnZKDesktopRegistry<IScriptsRegister> singleton = getScriptsRegister();
dependenciesSorter = new ScriptDependenciesSorter();
singleton.store(new IScriptsRegister() {
@Override
public void register(Class<?> klassContainingScripts)
throws IllegalArgumentException {
dependenciesSorter.register(klassContainingScripts);
recreate();
}
});
}
private OnZKDesktopRegistry<IScriptsRegister> getScriptsRegister() {
return OnZKDesktopRegistry
.getLocatorFor(IScriptsRegister.class);
}
public List<ScriptDependency> getScriptDependencies() {
return dependenciesSorter.getScriptDependenciesOrderered();
}
}

View file

@ -140,4 +140,10 @@
</mold>
</component>
<component>
<component-name>scripts</component-name>
<component-class>org.zkoss.ganttz.util.script.ScriptsComponent</component-class>
<macro-uri>~./ganttz/zul/scripts.zul</macro-uri>
</component>
</language-addon>

View file

@ -0,0 +1,8 @@
<?taglib uri="http://www.zkoss.org/dsp/web/core" prefix="c"?>
<zk xmlns:n="http://www.zkoss.org/2005/zk/native">
<zscript><![CDATA[
top = self;
]]>
</zscript>
<n:script type="text/javascript" src="${each.URL}" forEach="${top.scriptDependencies}" />
</zk>

View file

@ -3,7 +3,7 @@
<?link rel="stylesheet" type="text/css" href="/common/css/navalpro_zk.css"?>
<?component name="customMenu" inline="true" macroURI="_customMenu.zul"?>
<zk self="@{define(content)}">
<scripts />
<n:div xmlns:n="http://www.zkoss.org/2005/zk/native">
<n:table width="100%" border="0" cellpadding="0" cellspacing="0">
<n:tr>