The import Classes directive works for apply attribute.
But it doesn't work for zscript.
ZUL
<?import foo.*?> <zk> <window border="normal" width="200px" apply="MyComposer"> <!-- works here --> <label id="msg" /> <zscript><![CDATA[ MyBean myBean = new MyBean(); // but throws exception here msg.setValue(myBean.getHello()); ]]></zscript> </window> </zk>
foo.MyBean
package foo; public class MyBean { public String getHello() { return "hello"; } }
foo.MyComposer
package foo; import org.zkoss.zk.ui.select.SelectorComposer; import org.zkoss.zul.Window; public class MyComposer extends SelectorComposer<Window> { private static final long serialVersionUID = 1L; @Override public void doAfterCompose(Window win) throws Exception { super.doAfterCompose(win); win.setTitle("hello"); } }
By the way, this is no error:
ZUL2
<zk> <zscript><![CDATA[ import foo.*; ]]></zscript> <window border="normal" width="200px" apply="MyComposer"> <label id="msg" /> <zscript><![CDATA[ MyBean myBean = new MyBean(); msg.setValue(myBean.getHello()); ]]></zscript> </window> </zk>