Home   Single Page

Implement Java Classes in zscript

Thanks to the power of BeanShell[14], the implementation of Java classes can be done in zscript as follows.

<zscript>
    public class MyWindow extends Window {    
    }    
</zscript>
<window use="MyWindow"/>

Tip: Many scripting languages, e.g., JRuby, also allow developers to define classes that are accessible by JVM. Please consult the corresponding manuals for details.

To separate codes from the view, you can put all zscript codes in a separated file, say mywnd.zs, and then,

<zscript src="/zs/mywnd.zs"/>
<window use="MyWindow"/>

Tip: You can use the init directive to specify a zscript file, too. The difference is the init directive is evaluated before any component is created (in the Page Initial phase). For more information, refer to the init Directive section in the ZK User Interface Markup Language chapter.



[14] http://www.beanshell.org