How to pass a dynamic data as a argument of js function in .ZUL

asked 2015-08-05 11:43:33 +0800

Jagannath gravatar image Jagannath

I have a requirement to call a js function by zul file. Below is the code

<radio id="${processChecklistBean.folderProcessChecklistRecord.checklistCode}" value="Y"

I need to send the id of above radio button to that function which is dynamically created. can you help me the right syntax for it.

below is the code for js function.

<script type="text/javascript"> function myfunc(code) { alert(code); } </script>
delete flag offensive retag edit

1 Answer

Sort by ยป oldest newest most voted

answered 2015-08-05 12:24:58 +0800

Darksu gravatar image Darksu
1991 1 4

Hello Jagannath,

I created the following code so that you can use as a reference:


    <script type="text/javascript">
        function doTest (code) {
            zAu.send(new zk.Event(zk.Widget.$('$btn'), 'onTest', null), 10);
    <window apply="org.zkoss.bind.BindComposer"
        viewModel="@id('vm') @init('pkg$.TestVM2')">
        <div width="200px">
            <label value="@load(vm.msg)" style="width: 300px;" />

        <button id="btn" label="test" onClick="@command('test')" />



package pkg$;

import org.zkoss.bind.annotation.Command;
import org.zkoss.bind.annotation.NotifyChange;
import org.zkoss.zk.ui.util.Clients;
public class TestVM2 {
    private String _msg = "before test";

    public String getMsg() {
        return _msg;

    @Command @NotifyChange("msg")
    public void test() {
        _msg = "Js Function test";

        String command = String.format("doTest('%s');", _msg);



You just have to make so small changes to the code.

Best Regards,


link publish delete flag offensive 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: 2015-08-05 11:43:33 +0800

Seen: 81 times

Last updated: Aug 05 '15

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