0

ZK3.6.0/ZK3.5.3 freshly:Can't access components inside window from outside

asked 2009-03-05 01:25:13 +0800

lovetide gravatar image lovetide
169 1 7

updated 2009-03-05 01:27:58 +0800

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>

delete flag offensive retag edit

3 Replies

Sort by » oldest newest

answered 2009-03-05 04:37:46 +0800

hideokidd gravatar image hideokidd
750 1 2

updated 2009-03-05 04:45:33 +0800

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.

link publish delete flag offensive edit

answered 2009-03-12 04:09:47 +0800

lovetide gravatar image lovetide
169 1 7

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>


If I want to access 'labelTest', I must put code inside window w1_1_1 or write some code like w1.getFellow("w1_1").getFellow("w1_1_1").getFellow("labelTest"), and more level(s) more getFellow(s). I'd rather add prefix to keep component ID unique in Desktop rather than write getFellow() to access component.

I hope this BUG/feature can be kept, it like operating DOM object via JavaScript in HTML page in IE browser, it's very convenient.

link publish delete flag offensive edit

answered 2009-03-12 06:30:54 +0800

hideokidd gravatar image hideokidd
750 1 2

updated 2009-03-12 14:23:46 +0800

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.

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2009-03-05 01:25:13 +0800

Seen: 346 times

Last updated: Mar 12 '09

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More