-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Suppose there's a sample code below:
I put zscript code outside of Window component, when zscript code try to access components inside Window, an 'Typed variable declaration: Attempt to resolve method: getValue() on undefined variable or class name username...' error is reported.
If move zscript code into Window, it will work.
This sample code works ok when using ZK 3.5.2
Sample code:
<?xml version="1.0" encoding="UTF-8"?> <?taglib uri="http://www.zkoss.org/dsp/web/core" prefix="c" ?> <?page title="FaxBox WebAccess"?> <zk> <zscript> <![CDATA[ public OnTimer() { // Keep alive } public LDAPLogin () { String u = username.getValue(); String p = password.getValue(); info.setValue (u); } ]]> </zscript> <window id="login_window" title="登录" border="normal" width="400px" sizable="false" mode="overlapped" position="center, top" style='margin-top:50px;' onOK='LDAPLogin()' xmlns:h="http://www.w3.org/1999/xhtml"> <timer id="timer" running="true" delay="30000" repeats="true" onTimer="OnTimer()"/> <div style='text-align:center;'><label style='font-family:黑体; font-size:20px;'>FaxBox</label></div> <grid> <rows> <row> Domain/Email Account <hbox><textbox id="username" constraint="no empty"/>@DOMAIN.com</hbox> <zscript> username.focus (); </zscript> </row> <row>Password <textbox type="password" constraint="no empty" id="password" /></row> <row><label/><hbox><button label=" Login " onClick="LDAPLogin()"/></hbox></row> </rows> </grid> <label id="info" style="color:red;"/> </window> </zk>
Hi,
Exactly that's a bug of ZK 3.5.2, the formal use should be
<zscript> <![CDATA[ //@DECLARATION public void OnTimer() { // Keep alive } public void LDAPLogin () { String u = login_window.getFellow("username").getValue(); String p = login_window.getFellow("password").getValue(); login_window.getFellow("info").setValue(u); } ]]> </zscript>
You could not access components within a window directly.
So, the bug has been fixed since Zk 3.5.3
Thanks for notice.
Thank you for your response hideokidd.
That piece of code works with ZK 3.0.x and 3.5.0/1/2, if it's a bug, it's not just exists in ZK 3.5.2.
The "The ID Space" section in zk-dev-guide show a restricted component access method, but this BUG/feature provide a convenient component access method.
suppose there are 3 level ID spaces like this:
<window id='w1'> <window id='w1_1'> <window id='w1_1_1'> <label id='labelTest' value='Test'/> </window> </window> </window>
Hi,
Obviously the original use of component access is convenient, but it doesn't obey the rule of namespace. Maybe we will make a shortcut to achieve this without using getFellow() method.
BTW, there is a discussion similar to the problem, please see
http://www.zkoss.org/forum/index.zul#path%3DlistComment%3BdiscussionId%3D7271%3BcategoryId%3D14%3B
Thanks.
Asked: 2009-03-05 01:25:13 +0800
Seen: 346 times
Last updated: Mar 12 '09