define Variable in zscript and access by EL
From Documentation
Revision as of 04:03, 15 July 2010 by Maya001122 (talk | contribs) (Created page with '{{ZKDevelopersGuidePageHeader}} Variable defined in <tt>zscript</tt> can be easily accessed by EL. <source lang="xml" > <window> <zscript><![CDATA[ var="abc"; ]]> </zscrip…')
This documentation is for an older version of ZK. For the latest one, please click here.
Variable defined in zscript can be easily accessed by EL.
<window>
<zscript><![CDATA[
var="abc";
]]>
</zscript>
1:${var}
</window>
The result shows 1:abc
To achieve the same result in java, you can rewrite it to
<window id="win_1" use="MyWindow">
1:${win_1.var}
</window>
And the java file:
import org.zkoss.zul.Window;
public class MyWindow extends Window {
String var = "abc";
public String getVar(){
return var;
}
}
Note that ${win_1.var} will be mapped to MyWindow.getVar(). It's case sensitive. The mapping getter function will map first character of variable to upper case and append get in front of it.