0

Applet can't communicate with zkoss 5.

asked 2011-03-10 14:00:25 +0800

mhj gravatar image mhj flag of Brazil
806 1 7

When i use zkoss 3 it works(with appropriate modifications, of course), but when I use zkoss 5 does not work, the error in the applet is started, in the following line:
JSO = JSObject.getWindow (this);

if someone can help me thanks in advance.

ZK File:

<zk xmlns="http://www.zkoss.org/2005/zul"
	xmlns:h="http://www.w3.org/1999/xhtml"
	xmlns:zk="http://www.zkoss.org/2005/zk"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 
    
    <?script content="zk.useStackup = true;"?>
    <window id="test" width="100%" use="test.Test" apply="${testController}">


<script type="text/javascript">
                                            function notifyServer() {
                                                    var varUuid= $e("${wnd.uuid}").id;
                                                            zkau.send({uuid: varUuid,cmd:"onNotifyServer",data:null,ctl:true});
                                            }
                                            </script>
                                            <applet code="TestApplet" id="ticker" width="400px" style="border: 1px" mayscript="mayscript">
                                            </applet>


Test.java

public class Test extends Window {

   static {
    addClientEvent(Test.class, "onNotifyServer", CE_IMPORTANT); //assume it is an important event
  }

    @Override
  public void service(org.zkoss.zk.au.AuRequest request, boolean everError) {
    String cmd = request.getCommand();
    if (cmd.equals("onNotifyServer")) {
      Map data = request.getData();
      int x = ((Integer)data.get("x")).intValue();
      int y = ((Integer)data.get("y")).intValue();
      //do whatever you want
    } else {
      super.service(request, everError);
    }
  }
}



and Applet method:
public void actionPerformed(ActionEvent e) {
		JSObject jso = null;
		
		try {
			jso = JSObject.getWindow(this);
			jso.call("notifyServer", new Object[] {"manuel hinojosa jara"});
			System.out.println("notifyServer Fired!");
                        btnShowMessage.setText("START!");
		} catch(JSException ex) {
			System.out.println("Could not create JS Object. Javascript Disabled!");
                        btnShowMessage.setText("ERROR!");
		}

	}

delete flag offensive retag edit

3 Replies

Sort by ยป oldest newest

answered 2011-03-11 06:49:46 +0800

mhj gravatar image mhj flag of Brazil
806 1 7

in the line
jso = JSObject.getWindow(this);
is catched and label on button change to "ERROR!", when i did with zkoss 3, applet works fine and button changes to""START!.

link publish delete flag offensive edit

answered 2011-03-14 13:22:33 +0800

mhj gravatar image mhj flag of Brazil
806 1 7

i did!

link publish delete flag offensive edit

answered 2011-05-24 03:34:23 +0800

ca5h gravatar image ca5h
9

Hello, mhj! I have the same problem with calling js, described in zul file, from applet.
How did you solve that problem?

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: 2011-03-10 14:00:25 +0800

Seen: 555 times

Last updated: May 24 '11

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