Revision history [back]

click to hide/show revision 1
initial version

answered 2012-04-02 09:22:08 +0800

benbai gravatar image benbai

Hi Madruga,

Please refer to the sample below, it has 3 buttons: 'test', 'test two' and 'test three',

The 'test' button bind an 'onTest' event to command 'test', it will change the text of the label. Click the 'test two' button will trigger the onTest event of test button by event forwarding. Click the 'test three' button will send an au request to trigger onTest event of test button.


package j2kbd391$v2;

import java.util.*;

import org.zkoss.bind.BindContext;
import org.zkoss.bind.Form;
import org.zkoss.bind.ValidationContext;
import org.zkoss.bind.Validator;
import org.zkoss.bind.annotation.Command;
import org.zkoss.bind.annotation.NotifyChange;
import org.zkoss.bind.annotation.ContextParam;
import org.zkoss.bind.annotation.ContextType;
import org.zkoss.zul.*;
import org.zkoss.zk.ui.Component;
public class TestVM {
    private String _msg = "before test";

    public String getMsg() {
        return _msg;
    @Command @NotifyChange("msg")
    public void test () {
        _msg = "after test";


    <script type="text/javascript">
        function doTest () {
            zAu.send(new zk.Event(zk.Widget.$('$btn'), 'onTest', null), 10);
    <window apply="org.zkoss.bind.BindComposer"
        viewModel="@id('vm') @init('j2kbd391$v2.TestVM')">
        <div width="200px">
            <label value="@load(vm.msg)" style="width: 300px;" />
        <button id="btn" label="test" onTest="@command('test')" />
        <button label="test two" forward="onClick=btn.onTest" />
        <button label="test three">
            <attribute name="onClick">

Regards, Ben

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