ZK Applet Component

From Documentation
Revision as of 10:28, 12 December 2011 by Vincent (talk | contribs)


Stop.png This documentation is for an older version of ZK. For the latest one, please click here.


Embedding an applet class into a ZUL file

By the code sample, inserting a ZK applet into ZUL file is straight forward. It works the same as original object-embed tag, but neater and simpler.

<applet codebase="path/to/applet/classfolder" code="ticker" height="320" width="620"></applet>

ZK applet attribute / method specification table:

Attribute:

Attribute Usage
codebase Specifies the path of the applet class.
code Specifies the applet (*.class) of the applet to be loaded.
name Specifies the name attribute of the applet to be loaded.

Method:

Method Usage
Map getParams() Get Params Map, it will effect the initialize variable of applet.
void setParams(Map params) Set Params Map, it will effect the initialize variable of applet.
void invoke(String function)
void invoke(String function, String[] argument)
Invoke public method of Applet
void setField(String field, String value) Set public field of Applet

Initializing applet in ZK.

Usually Applet have many params to initialize (<params>). User could use getParams() and setParams() methods to change the initial variable of Applet. In this case, Applet will change their params and restart itself automaticlly.

...
Map params = ticker.getParams();
params.put("msg","ZK is Simple and Rich!");
ticker.setParams(params);
...

or, You can use dynamic properities supported by ZK Applet to make it simple and easy.

...
<applet codebase="folder" code="ticker" msg="ZK is Simple and Rich!" />
..

Invoking applet method in ZK.

Another common usage is trying to invoke public method or change field value of the applet. This kinds of tasks usually need working with client side javascript before.
By invoke and setField method supported by ZK Applet component, It can be done easily on server side (of course JAVA).

...
// invoke stop / start method of applet
<toolbarbutton label="Stop" onClick='ticker.invoke("stop");' /> 
<toolbarbutton label="Start" onClick='ticker.invoke("start");' />
// set message attribute of applet
<toolbarbutton label="Set Message" onClick='ticker.setField("message", "ZK Applet Component is great!!");' />
...



Last Update : 2011/12/12

Copyright © Potix Corporation. This article is licensed under GNU Free Documentation License.