Author Topic: ZK Button Toolbarbutton onClick 事件  (Read 4689 times)

Van Chan

  • Administrator
  • Newbie
  • *****
  • Posts: 7
    • View Profile
ZK Button Toolbarbutton onClick 事件
« on: July 21, 2012, 11:52:50 AM »
Sample02.zul
--------------------
Code: [Select]
<?page id="page_event_listener_sample02" title="" contentType="text/html;charset=UTF-8"?>
<?taglib uri="http://www.zkoss.org/dsp/web/core" prefix="c" ?>
<zk>
    <window id="win_event_listener_sample02" title="Button Toolbarbutton SAMPLE02" width="600px" border="normal" closable="true" onClose="self.detach();"  apply="inisoft.mo.gui.Sample02">
        <vbox>
            <button id="btn1" label="普通按鈕" />
            <button id="btn2" label="提示按鈕" />
            <toolbarbutton id="tbtn3" label="Toolbarbutton按鈕" width="120px" />
            <toolbarbutton id="tbtn4" label="開子網頁按鈕" width="120px" />
        </vbox>
    </window>
</zk>

Sample02.java
---------------------
Code: [Select]
package inisoft.mo.gui;

import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.Executions;
import org.zkoss.zk.ui.Page;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.util.GenericForwardComposer;
import org.zkoss.zul.Button;
import org.zkoss.zul.Messagebox;
import org.zkoss.zul.Toolbarbutton;
import org.zkoss.zul.Window;

/**
 * @author Van Chan
 */
public class Sample02 extends GenericForwardComposer{
    Page page_event_listener_sample02;
    Window win_event_listener_sample02;
    Button btn1,btn2;
    Toolbarbutton tbtn3,tbtn4;
    @Override
    public void doAfterCompose(Component comp) throws Exception
    {
      super.doAfterCompose(comp);       
     
    }
   
    public void onClick$btn1(Event event)throws Exception{
           btn1.setLabel("Button 被點擊!"); 
    }
   
    public void onClick$btn2(Event event)throws Exception{
           Messagebox.show("提示 Messagebox !");
    }
   
    public void onClick$tbtn3(Event event)throws Exception{
           tbtn3.setLabel("Toolbarbutton 被點擊!");
    }
   
    public void onClick$tbtn4(Event event)throws Exception{
           Window win=(Window)Executions.createComponents("/form/Sample01.zul", null, null);
           win_event_listener_sample02.appendChild(win);
           win.setPosition("center");
           win.setSizable(true);
           win.doModal();
    }   
}
« Last Edit: July 21, 2012, 12:42:45 PM by Roy Chan »