define Variable in zscript and access by EL"

From Documentation
m (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…')
 
m (correct highlight (via JWB))
 
Line 1: Line 1:
 
{{ZKDevelopersGuidePageHeader}}
 
{{ZKDevelopersGuidePageHeader}}
  
Variable defined in <tt>zscript</tt> can be easily accessed by EL.
+
Variable defined in <code>zscript</code> can be easily accessed by EL.
 
<source lang="xml" >
 
<source lang="xml" >
 
<window>
 
<window>
Line 12: Line 12:
 
</source>
 
</source>
  
The result shows <tt>1:abc</tt>
+
The result shows <code>1:abc</code>
  
 
To achieve the same result in java, you can rewrite it to
 
To achieve the same result in java, you can rewrite it to
Line 34: Line 34:
 
</source>
 
</source>
  
Note that <tt>${win_1.var}</tt> 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 <tt>get</tt> in front of it.
+
Note that <code>${win_1.var}</code> 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 <code>get</code> in front of it.
  
 
{{ ZKDevelopersGuidePageFooter}}
 
{{ ZKDevelopersGuidePageFooter}}

Latest revision as of 10:41, 19 January 2022

DocumentationZK Developer's GuideZK in DepthZscript, java, ELdefine Variable in zscript and access by EL
define Variable in zscript and access by EL


Stop.png 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.



Last Update : 2022/01/19

Copyright © Potix Corporation. This article is licensed under GNU Free Documentation License.