ZK 6 and Java Applet integration

asked 2014-02-10 23:30:37 +0800

mrojas gravatar image mrojas
17 2

Hello everybody.

I'm looking for a way to integrate a Java Applet into our ZK application in order to get data from a fingerprint reader for a login window. I've read a 2009 smalltalk but as far as I can tell it's already obsoleted. I'm using a single ZUL file as the application entry point (as index.zul), and everything else is being created programatically via the Java ZK API. Any pointers in the right direction will be greatly appreciated.

Best regards and thanks in advance.

delete flag offensive retag edit


are you having trouble embedding the applet into the website, or do you need hints how to communicate from the applet via JS/Ajax to the server?

cor3000 ( 2014-02-11 02:03:08 +0800 )edit

Yes, it's about the applet communication. As I've said in my post, I'm using just an index.zul file as my application entry point, and from there all the user interface is generated via Java classes. My index.zul file uses a Java class that extends from the Window ZK class (no Composer, just Window)

mrojas ( 2014-02-11 15:41:38 +0800 )edit

Can you provide which API you use for fingerprint

sitansu ( 2014-02-12 16:28:51 +0800 )edit

Hi @sitansu I'm going to use Suprema BioMini readers and their SDK. Regards.

mrojas ( 2014-02-12 18:02:38 +0800 )edit

1 Answer

Sort by » oldest newest most voted

answered 2014-02-12 13:02:19 +0800

cor3000 gravatar image cor3000
4332 1 7
ZK Team

updated 2014-02-13 01:33:29 +0800

I don't think there have been fundamental changes to the JS <-> Applet communication in the last 10 years, and also I am not aware of changes to the ZK client API, so I tested myself with a very simple example (I assume you already have your applet running so I'll not bore you with applet security related issues).

assume an applet like this

import java.applet.Applet;
import netscape.javascript.*;
public class TestApplet extends Applet {
    private JSObject js;
    public void init() {
        js = JSObject.getWindow(this);
        js.eval("console.log('applet init')");
    public void echoJS(String script) { //called from JS
        try {
        } catch (InterruptedException e) {
        js.eval(script); //calling back into JS

It has a public method echoJS that performs in- and outbound communication...

embed the applet in a zk page

    <applet id="myapplet" code="TestApplet.class" 
       mayscript="true" onFingerPrint="System.out.println(event.getData());"/>

or in your case create the Applet component in Java

    org.zkoss.zul.Applet applet = new org.zkoss.zul.Applet();
            //register a custom event listener
    applet.addEventListener("onFingerPrint", new EventListener<Event>() {
        public void onEvent(Event event) throws Exception {

When you want to call the echoJS method on your applet just call from java (ZK webapp):

String script = "jq('@myapplet')[0].echoJS('alert(\"hello something\")')"

To fire the "onFingerPrint" event from inside your Applet code just call:

String script = "zk.Widget.$('$myapplet').fire('onFingerPrint', {data: 'somedata'}, {toServer: true})";

please let me know if this was helpful.



link publish delete flag offensive edit


I also tested this in the chrome JS console

jq('@myapplet')[0].echoJS("zk.Widget.$('$myapplet').fire('onFingerPrint', {data: 'somedata'}, {toServer: true})");

cor3000 ( 2014-02-12 13:08:52 +0800 )edit

Thanks a lot Robert, I'll try your suggestions and let you know about it.

mrojas ( 2014-02-12 15:02:16 +0800 )edit

Thank you very much Robert, it works as advertised ;) now I can listen to events from the applet on the ZK window and viceversa. Again thanks a lot.

mrojas ( 2014-02-12 16:35:14 +0800 )edit

thanks for your feedback I am glad I could help, and also for sharing information above with sitansu!

cor3000 ( 2014-02-13 01:30:55 +0800 )edit
Your answer
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

1 follower



Asked: 2014-02-10 23:30:37 +0800

Seen: 24 times

Last updated: Feb 13 '14

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