-
FEATURED COMPONENTS
First time here? Check out the FAQ!
If I use zul 3.5.0 or 3.5.2 every things o.k., but
i would like to use zul 3.6.1 , but every id's return null.
Why? Simple example:
I have the following JSP:
<?xml version="1.0" encoding="UTF-8" ?>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib uri="http://www.zkoss.org/jsp/zul" prefix="zk" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head><title></title></head>
<body>
<zk:page zscriptLanguage="java" id="asd">
<zk:zscript>
void test(){
alert(testButton.getLabel());
}
</zk:zscript>
<zk:window>
<zk:button id="testButton" onClick="test();" label="TEST_IT" />
</zk:window>
</zk:page>
</body>
</html>
I catch the following error:
undefined variable or class name: testButton
testNotWork() function doesn't working, but testWork() good working. why? please help me!
<zk:page zscriptLanguage="java" id="pageId">
<zk:zscript>
void testNotWork(){
alert(testButton.getLabel());
}
void testWork(){
alert(Path.getComponent("//pageId/windowId/testButton").getLabel());
}
</zk:zscript>
<zk:window id="windowId">
<zk:button id="testButton" onClick="testWork();" label="TEST_IT" />
</zk:window>
</zk:page>
thx!
this is IDSpace Issue, you should move zscript into window(a IDSpaceOwner) if you want to use a component_id directly in the method.
or you can pass it as a argument of the test(),
<?xml version="1.0" encoding="UTF-8" ?> <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ taglib uri="http://www.zkoss.org/jsp/zul" prefix="zk" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head><title></title></head> <body> <zk:page zscriptLanguage="java" id="asd"> <zk:zscript> void test(comp){ alert(comp.getLabel()); } </zk:zscript> <zk:window> <zk:button id="testButton" onClick="test(self);" label="TEST_IT" /> </zk:window> </zk:page> </body> </html>
Thanks dennis,unfortunatly the argument solution doesn't solve my global problem.
In this case , I must give for all needed components to my functions.
But the zscript move into window very simplme and good.
Thanks!
Thanks!
Thanks!
Asked: 2009-06-03 12:12:48 +0800
Seen: 198 times
Last updated: Jun 05 '09