0

I'm trying to use ZK JSP tags but the id's reference always return null if i use zul 3.6.1

asked 2009-06-03 12:12:48 +0800

krajlaci gravatar image krajlaci
15

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

delete flag offensive retag edit

3 Replies

Sort by ยป oldest newest

answered 2009-06-03 12:35:24 +0800

krajlaci gravatar image krajlaci
15

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!

link publish delete flag offensive edit

answered 2009-06-04 11:05:05 +0800

dennis gravatar image dennis
3679 1 6
http://www.javaworld.com....

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> 

link publish delete flag offensive edit

answered 2009-06-05 07:53:58 +0800

krajlaci gravatar image krajlaci
15

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!

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-06-03 12:12:48 +0800

Seen: 198 times

Last updated: Jun 05 '09

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