0

Error opening a new Window with "window.open" javascript order

asked 2010-01-03 11:15:57 +0800

amobdlp gravatar image amobdlp
3 1 1

Hello everybody,
I am new to to zk, so perhaps my question will be stupid...

I am trying to open a child window using javascript 'window.open' and I got an exeception in tomcat (5.5.28) (and an alert msg from zk)
3 janv. 2010 17:28:47 org.zkoss.util.resource.ResourceCache$Info isValid:219
INFO: Source is changed: /cms/main.zul
3 janv. 2010 17:28:50 org.zkoss.zk.ui.impl.UiEngineImpl handleError:1114
GRAVE: >>org.mozilla.javascript.EcmaError: ReferenceError: "window" n'est pas dÚ
fini (zk#1)

and alert msg from zk :ReferenceError: "window" n'est pas défini (zk#1)

My source page is very simple (and pick from an example in this forum...) :
<window title="iframe demo" border="normal">
<zscript language="javascript">
</zscript>
<iframe id="iframe" width="95%"/>
<separator bar="true"/>

<textbox id="text" value="field"></textbox>
<label id="invisibile" value="not defined" ></label>
<button label="mybutton" id="boo" onClick="javascript:window.open('http://localhost:8080/maquette-cms-ria-1.0-SNAPSHOT/cms/test.zul','mywindow','')"/>

</window>


My target page : test.zul is also extremely simple

<window id="testZul" title="Test Zul" border="normal" mode="overlapped" width="30%" height="25%" position="center,top" closable="true" >
"Hello world"
</window>


both pages display well when i referenced them in the browser (ie http://localhost:8080/maquette-cms-ria-1.0-SNAPSHOT/cms/test.zul or http://localhost:8080/maquette-cms-ria-1.0-SNAPSHOT/cms/main.zul)

It seems (its my personal interpretation...) that javascript is no activated(or not found...) by zk. I look under
C:\xxxx\apache-tomcat-5.5.28\webapps\maquette-cms-ria-1.0-SNAPSHOT\WEB-INF\lib
and all the jars seems to be present :
28/12/2009 19:26 281ÿ694 bsh.jar
30/12/2009 00:17 57ÿ779 commons-fileupload-1.2.1.jar
28/12/2009 19:26 57ÿ779 commons-fileupload.jar
28/12/2009 19:26 83ÿ613 commons-io.jar
28/12/2009 19:26 1ÿ464ÿ360 fckez.jar
28/12/2009 19:26 4ÿ503ÿ584 groovy.jar
21/12/2009 21:59 643ÿ727 hsqldb-1.8.0.7.jar
28/12/2009 19:26 8ÿ801ÿ103 jruby.jar
28/12/2009 19:26 871ÿ260 js.jar
28/12/2009 19:26 8ÿ580ÿ107 jython.jar
30/12/2009 19:43 3ÿ745 maquette-cms-bo-1.0-SNAPSHOT.jar
02/01/2010 20:36 161ÿ609 maquette-cms-dao-1.0-SNAPSHOT.jar
03/01/2010 18:03 0 toto.txt
08/12/2009 13:09 414ÿ430 zcommon-5.0.0.RC2.jar
08/12/2009 13:09 99ÿ595 zcommons-el-1.0.3.jar
08/12/2009 13:09 56ÿ419 zhtml-5.0.0.RC2.jar
08/12/2009 13:09 962ÿ644 zk-5.0.0.RC2.jar
08/12/2009 13:09 104ÿ611 zkplus-5.0.0.RC2.jar
08/12/2009 13:09 1ÿ239ÿ837 zul-5.0.0.RC2.jar
08/12/2009 13:09 199ÿ575 zweb-5.0.0.RC2.jar

the zk.xml file is nearly empty (but generated by zkstudio so i think it is good...) :

<?xml version="1.0" encoding="UTF-8"?>

<!--
Created by ZK Studio
-->

<zk>
<device-config>
<device-type>ajax</device-type>
<timeout-uri>/timeout.zul</timeout-uri><!-- An empty URL can cause the browser to reload the same URL -->
</device-config>
</zk>
(in particular there is no section
<zscript-config>
<language-name>Java</language-name><!-- case insensitive --!>
<interpreter-class>my.MySuperJavaInterpreter</interpreter-class>
</zscript-config>
but i hope that javascript is declared by default...)
I tried different URL with window.open () without result...
What's wrong with my example !! i search on the internet and on the forum but i don't found something consistent with the exception...

Thanks you for your helps...

Alain
Ps used version:
Zk : 5.0.0.0RC2, zkstudio : 0.9.6, eclipse 3.5.1 (Build id: 20090920-1017), tomcat 5.5.28

delete flag offensive retag edit

1 Reply

Sort by » oldest newest

answered 2010-01-06 21:56:11 +0800

henrichen gravatar image henrichen
3869 2
ZK Team

<button label="mybutton" id="boo" onClick="javascript:window.open('http://localhost:8080/maquette-cms-ria-1.0-SNAPSHOT/cms/test.zul','mywindow','')"/>

ZK's event handling is running on the server side. The "javascript:" only tells the ZK engine to use "Rhino" to interpret the codes after. But it is still running in server side. It tries to find a ZK component with id="window" but cannot find it and the exception.

Here is the ZK architecture overview which might give you some ideas.

http://www.zkoss.org/doc/architecture.dsp

ZK also allows you to call client side Javascript, too. But you have to go thru Clients.evalJavaScript() method.
http://zkoss.org/javadoc/5.0/zk/org/zkoss/zk/ui/util/Clients.html#evalJavaScript(java.lang.String)

So you might try

<button label="mybutton" id="boo">
    <attribute name="onClick">
        Clients.evalJavascript("window.open('http://localhost:8080/maquette-cms-ria-1.0-SNAPSHOT/cms/test.zul','mywindow','')");
    </attribute>
</button>

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-01-03 11:15:57 +0800

Seen: 2,991 times

Last updated: Jan 06 '10

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