-
FEATURED COMPONENTS
First time here? Check out the FAQ!
<?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>
Hi leoyc
Try this
alert(Path.getComponent("//P/A/B/C").value);
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>
Someone can help me? thanks a lot.
Good day, leoyc.
textbox id="txtid" and path is //P/A/g1/h1/i1/ttid. it should be //P/A/g1/h1/i1/txtid
sorry,it's my wrong.
alert(Path.getComponent("//P/A/g1/h1/i1/txtid").value); can't return "xxxx".
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>
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!!!!
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.
Asked: 2010-07-25 09:53:28 +0800
Seen: 342 times
Last updated: Jul 29 '10