0

why this temp.zul can't return "Hello!",return null?

asked 2010-07-25 09:53:28 +0800

leoyc gravatar image leoyc
163 3

<?xml version="1.0" encoding="GB2312"?>
<?page id="P"?>
<zk>
<window id="A">
<window id="B">
<label id="C" value="Hello!"/>

</window>

<button label="保存" width="80px" height="25px" onClick="ok()"/>

<zscript>

void ok()
{
alert(Path.getComponent("//P/A/B/C.value"));

}
</zscript>

</window>
</zk>

delete flag offensive retag edit

13 Replies

Sort by » oldest newest

answered 2010-07-25 20:50:14 +0800

jimmyshiau gravatar image jimmyshiau
4921 5
http://www.zkoss.org/ ZK Team

Hi leoyc
Try this

alert(Path.getComponent("//P/A/B/C").value);

link publish delete flag offensive edit

answered 2010-07-26 07:30:38 +0800

leoyc gravatar image leoyc
163 3

updated 2010-07-26 23:23:28 +0800

thanks,as1225.
but I can't get the value of the grid children's component.

like that:



<?xml version="1.0" encoding="GB2312"?>
<?page id="P"?>
<zk>
<window id="A">
<window id="B">
<label id="C" value="Hello!"/>

</window>


<grid id="g1">
<rows id="h1">
<row id="i1">
<textbox id="txtid" value="xxxx"/>
</row>
</rows>
</grid>

<button label="save" width="80px" height="25px" onClick="ok()"/>

<zscript>

void ok()
{
alert(Path.getComponent("//P/A/g1/h1/i1/ttid").value);

}
</zscript>

</window>
</zk>

link publish delete flag offensive edit

answered 2010-07-27 03:09:13 +0800

leoyc gravatar image leoyc
163 3

updated 2010-07-27 03:11:15 +0800

Someone can help me? thanks a lot.

link publish delete flag offensive edit

answered 2010-07-27 03:14:56 +0800

Arsen gravatar image Arsen
381 2

updated 2010-07-27 03:15:15 +0800

Good day, leoyc.
textbox id="txtid" and path is //P/A/g1/h1/i1/ttid. it should be //P/A/g1/h1/i1/txtid

link publish delete flag offensive edit

answered 2010-07-27 04:41:33 +0800

leoyc gravatar image leoyc
163 3

updated 2010-07-27 04:44:19 +0800

sorry,it's my wrong.

alert(Path.getComponent("//P/A/g1/h1/i1/txtid").value); can't return "xxxx".

link publish delete flag offensive edit

answered 2010-07-27 12:06:38 +0800

leoyc gravatar image leoyc
163 3

updated 2010-07-27 23:29:43 +0800

why Path.getComponent("//P/A/g1/h1/i1/txtid").value can't return "xxxx"?

what's wrong?


<?xml version="1.0" encoding="GB2312"?>
<?page id="P"?>
<zk>
<window id="A">
<window id="B">
<label id="C" value="Hello!"/>

</window>


<grid id="g1">
<rows id="h1">
<row id="i1">
<textbox id="txtid" value="xxxx"/>
</row>
</rows>
</grid>

<button label="save" width="80px" height="25px" onClick="ok()"/>

<zscript>

void ok()
{
alert(Path.getComponent("//P/A/g1/h1/i1/txtid").value);

}
</zscript>

</window>
</zk>

link publish delete flag offensive edit

answered 2010-07-28 01:10:31 +0800

leoyc gravatar image leoyc
163 3

run this code:

alert(Path.getComponent("//P/A/g1/h1/i1/txtid").value);

error message is :

Sourced file: inline evaluation of: `` ok();'' : reflection error: bsh.ReflectError: Error in property getter: bsh.UtilTargetError : bsh.UtilTargetError : at Line: 25 : in file: inline evaluation of: `` void ok() { alert(Path.getComponent("//P/A/g1/h1/i1/txt . . . '' : .value

Called from method: ok : at Line: 19 : in file: inline evaluation of: `` ok();'' : ok ( )


someone help me ,pls!!!!

link publish delete flag offensive edit

answered 2010-07-28 01:45:28 +0800

Arsen gravatar image Arsen
381 2

Real strange thing is going on. Example from wiki http://docs.zkoss.org/wiki/Component_path_and_accesibility

<window id="win_1">
	<window id="win_1_1">
		<label id="lab_1" value="initial by label" />		
	</window>	
	<zscript>   	
	public void sayHello()
	{ 
		Label l = (Label)Path.getComponent("/win_1/win_1_1/lab_1");
		l.setValue("changed");
	}        
   	</zscript>
   	<button label="ok" onClick="sayHello()"/>	   	
</window>

Copy this text in zk demo http://www.zkoss.org/zkdemo/userguide/ and press "Try it". It doesn't work.

I believe this is bug.

link publish delete flag offensive edit

answered 2010-07-28 01:59:31 +0800

leoyc gravatar image leoyc
163 3

Thank you, your code can be run and it's ok.

But I want get the value of the grid children's component.

link publish delete flag offensive edit

answered 2010-07-28 16:03:53 +0800

jj gravatar image jj
638 3

@leoyc
the following code will work

alert(Path.getComponent("//P/A/txtid").value); 

grid is not an IdSpace component, thus should not be specified in the path.

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: 2010-07-25 09:53:28 +0800

Seen: 342 times

Last updated: Jul 29 '10

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