# zk with applet

spinx73
27

hi there... I have a homework to create simple web application that can communicate with serial or usb port. I know, this can be handled by using applet. Can somebody teach me how to do step by step thanks in advance

delete retag edit

Sort by » oldest newest most voted

ashishd
1972 6

It is a homework so you are supposed to do that by yourself. We can provide you guidance. Here are the steps that you need to follow

2. After that refer to ZK Applet component reference to see how to use it in ZK application here

Try implementing it yourself first and if you run into any problems (which I'm sure you will) come back to this forum and post your codes and error messages.

spinx73
27

thanks for your guide, I will try it

spinx73
27

hello again. I did try to embedded this applet like the documentation, it did well but no applet show. I get applet from https://code.google.com/p/java-simple-serial-connector/wiki/jSSC_Terminal (jSSC terminal) and follow document. The zul file like this

<?page title="new page title" contentType="text/html;charset=UTF-8"?>
<zk>
<window title="new page title" border="normal">
code="SerialPort.class"
xmlns:ca="client/attribute"
ca:separate_jvm="true" ca:draggable="true"
width="700" height="500" />
New Content Here!
</window>


</zk>

ashishd
1972 6

Can you make it work on a simple HTML page first? If it works on simple HTML then post that code here.

spinx73
27

Hello Ashishd here is the code from their web https://code.google.com/p/java-simple-serial-connector/wiki/jSSC_Terminal (site)

<applet width="700" height="500">
<param name="separate_jvm" value="true"/>
<param name="draggable" value="true"/>


</applet>

or

<script src="http://java.com/js/deployJava.js"></script>

<script> var attributes = { code: "applet.Main", archive: "jSSC-Terminal.jar, lib/jssc.jar, lib/swing-layout-1.0.4.jar", width: 700, height: 500 }; var parameters = {separate_jvm:"true", draggable:"true", jnlp_href:"http://java-simple-serial-connector.googlecode.com/svn/trunk/terminal/launch.jnlp"}; var version = "1.5"; deployJava.runApplet(attributes, parameters, version); </script>

Is this code working correctly in your environment? I'm asking because it is better to make sure this applet is working fine without ZK first. After that we can investigate if there are any issue integrating it with ZK and how to solve them.

( 2013-07-16 05:16:36 +0800 )edit

Yes, the code is working correctly, but still couldn't work from zk, I dont know whats wrong

( 2013-07-21 08:41:57 +0800 )edit

spinx73
27

Hello Ashishd here is the complete code

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<style type="text/css">
<!--
body {
margin-left: 10px;
margin-top: 10px;
margin-right: 10px;
margin-bottom: 10px;
}
-->
</style>
<body>
<script src="http://java.com/js/deployJava.js"></script>
<script>
var attributes = {
code:       "applet.Main",
archive:    "jSSC-Terminal.jar, lib/jssc.jar",
width:      700,
height:     500
};
var parameters = {separate_jvm:"true", draggable:"true", jnlp_href:"launch.jnlp"}; <!-- Applet Parameters -->
var version = "1.5"; <!-- Required Java Version -->
deployJava.runApplet(attributes, parameters, version);
</script>
<!-- Or use the following applet element to launch the applet using jnlp_href -->
<!--
<applet width="700" height="500">
<param name="jnlp_href" value="launch.jnlp"/>
</applet>
-->
</body>
</html>


This code is work perfectly

Senthilchettyin
2615 3 8
http://emrpms.blogspot.in...

Hi ashishd

I very badly need any one of your help on ZK + Applet + Javascript. Here is the html version which works perfectly

Here is the html version link

As a first step i am trying to integrate the above into Existing ZK Application Here is the testing code

 <?page title="Auto Generated index.zul"?>
<window xmlns:w="http://www.zkoss.org/2005/zk/client"
title="Hello World!!" border="normal" width="200px">

<applet name="CSSNLibJ" id="CSSNLibJ"
archive="xFunction.jar,CSSNLibJ.jar" code="lib.CSSNLibJ" width="10"
height="10">
</applet>
<script type="text/javascript">

<![CDATA[ function f_test()

{
var CSSNLibJ = '' + zk.Widget.$("$CSSNLibJ");

var foo = zk.Widget.$('$lbl');
foo.setValue("What's Up?");
var result = CSSNLibJ.InitScanLib("8NDANMAE6W8CZ5D5");

}

]]>

</script>

<label id="lbl" value="You are using: ${desktop.webApp.version}" /> <button label="Connect" xmlns:w="http://www.zkoss.org/2005/zk/client" w:onClick="f_test();"> </button> </window>  But it does not happen any thing after this line var result = CSSNLibJ.InitScanLib("8NDANMAE6W8CZ5D5");  When i debug in IE, i am getting the following SCRIPT438: Object doesn't support property or method 'GetScannerName' Copy%20of%20index.zul, line 40 character 14 So it is clear that object does not initialized properly. But it is working fine without ZK. So please help me ## Comments use defer="true" on the script tag or execute your JS code in a function that you pass to zk.afterMount() ( 2013-07-30 05:36:47 +0800 )edit No luck after changing as per your steps ( 2013-07-30 10:04:19 +0800 )edit var CSSNLibJ = '' + zk.Widget.$("$CSSNLibJ"); you should remove that '' from this statement. It will convert the widget JS object into a string if you do this. No wonder it says CSSNLibJ has no property. ( 2013-07-30 11:06:08 +0800 )edit Just for Testing, i included that. Now i have removed. But still same problem. Look at the answer section for more detail ( 2013-07-30 11:36:33 +0800 )edit answered 2013-07-30 11:37:10 +0800 Senthilchettyin 2615 3 8 http://emrpms.blogspot.in... <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  <html xmlns="&lt;a href=" http:="" www.w3.org="" 1999="" xhtml"="">http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Pragma" content="no-cache"/> <meta http-equiv="Expires" content="-1"/> <title>Auto Generated index.zul</title> <link rel="stylesheet" type="text/css" href="/ScanDemo/zkau/web/c928039/zul/css/zk.wcs;jsessionid=581AB4506214EE742983A447A625A561"/> <script type="text/javascript" src="/ScanDemo/zkau/web/c928039/js/zk.wpd;jsessionid=581AB4506214EE742983A447A625A561" charset="UTF-8"></script> <script type="text/javascript" src="/ScanDemo/zkau/web/c928039/js/zul.lang.wpd;jsessionid=581AB4506214EE742983A447A625A561" charset="UTF-8"></script> <script type="text/javascript" src="/ScanDemo/zkau/web/c928039/js/zuljsp.js;jsessionid=581AB4506214EE742983A447A625A561" charset="UTF-8"></script> <script type="text/javascript" src="/ScanDemo/js/IdErrorDescription.js;jsessionid=581AB4506214EE742983A447A625A561" charset="UTF-8"></script> <script type="text/javascript" src="/ScanDemo/js/ScannerErrorDescription.js;jsessionid=581AB4506214EE742983A447A625A561" charset="UTF-8"></script> <script type="text/javascript" src="/ScanDemo/js/SDKLicenseKey.js;jsessionid=581AB4506214EE742983A447A625A561" charset="UTF-8"></script> </head> <body> Processing... <script class="z-runonce" type="text/javascript">// </script> <noscript> Sorry, JavaScript must be enabled. Change your browser options, then try again. </noscript> </body> </html> Error as follows Refresh the page to see messages that may have occurred before the F12 tools were opened. SCRIPT438: Object doesn't support property or method 'GetScannerName' Copy%20of%20index.zul, line 41 character 14 answered 2013-07-30 12:02:59 +0800 Senthilchettyin 2615 3 8 http://emrpms.blogspot.in... Hi ashish I think i am able to find out where is the problem is 1. Again look at this file. This file is pure HTML + Javascript 2. Now i am trying to convert the above file into ZK + Javascript. First problem i found that is, i cannot use document.getElementByID as per this link 3. Then i found the other way is zk.Widget.$("$CSSNLibJ"). But it is very sad, it perfectly works fine for components like Label, button etc. But it gives problem for ZK Applet. I saw in the zk forum, that applet tag already having some issues. 4. Then finally i removed all the Code, and just open HTML tag and put all the code as per the above file. Wow, it works perfectly. So i can conclude that some problem in ZK Applet tag, because same applet tag inside the html tag is working fine. 5. Now i have two options, one is , as i need to go with html tag, but really dont know how to read the HTML Component values in MVC or MVVM java class. 6. Second choice, still i need to try using ZK Component + Javascript. answered 2013-07-31 02:57:46 +0800 ashishd 1972 6 @Senthil, 1. Make sure the older JS is not cached 2. What is the return value of zk.Widget.$("$CSSNLibJ") ? Try console.log() or zk.log() to print it. It should return you JS widget instance for ZK Applet component. However from scan.html I suspect what you really need is the actual html applet element so you should do the following var CSSNLibJ = zk.Widget.$("$CSSNLibJ").$n();


Refer to Widget \$n() function here

Yes. i need the actual applet object. Let me try again

( 2013-07-31 04:33:05 +0800 )edit
[hide preview]