顯示具有 ZK 標籤的文章。 顯示所有文章
顯示具有 ZK 標籤的文章。 顯示所有文章

星期四, 4月 07, 2011

[ZK] Image setContent using Stream

Aimage stream設定範例
    
URL url = new URL(avatar);
            AImage aimg = new AImage("avatar",url.openStream());
            myPhoto.setContent(aimg);

星期日, 3月 27, 2011

[ZK] How to download file in ZK

 public void onClick$downloadAgent(Event event){
  
  try {
   Filedownload.save("download/xxx.xls", "application/octet-stream");
  } catch (FileNotFoundException e) {
   System.out.println("FileNotFoundException:" + e.getMessage());
  }
  
 }

星期三, 3月 16, 2011

[ZK] How to pass parameter to another zul page

Today i want to pass parameter to another zul page so i find the solution for using "Executions.createComponents".



arg - java.util.Map(Refer to ZK:The User Guide)
The arg argument passed to the createComponents method in the
org.zkoss.zk.ui.Executions class. It might be null, depending on how
createComponents is called.

It is the same as self.desktop.execution.arg.
params.put("name", "John");
Executions.createComponents("/my.zul", null, params);

Then, in my.zul,

...

Notice that arg is available only when creating the components for the included page, say
my.zul. On the other hand, all events, including onCreate, are processed later. Thus, if you
want to access arg in the onCreate's listener, use the getArg method of the
org.zkoss.zk.ui.event.CreateEvent class.


Testing code is the below:
In the a.zul composer.
final Map<String, Object> map = new HashMap<String, Object>(0);
    map.put("userid",detailsUser.getUserName() );

    Window changepasswordWin = null; 
    changepasswordWin = (Window) Executions.createComponents(
      "/admin/change_password.zul", 
      null,
      map);

In teh b.zul composer.(change_password.zul)
Map<String, Object> args = null;
public void onCreate$changePasswordWin(Event e) throws Exception {
  System.out.println("--ChangePassword changePasswordWin--");
 
  CreateEvent ce = (CreateEvent) ((ForwardEvent) e).getOrigin();
  this.args = ce.getArg();
  System.out.println("pass userid:" + this.args.get("userid"));
  
  //do something
  //....

  System.out.println("--/ChangePassword changePasswordWin--");
 }

星期二, 3月 15, 2011

[ZK] Dynamic to add button and listen event

  Button btnModify = new Button("Modify Password");
                //parent is cell of row
  btnModify.setParent(cell);
  btnModify.setImage("/admin/images/btn/modify_key.png");
  btnModify.addEventListener("onClick", new EventListener() {
         public void onEvent(Event event) throws Exception {
          
           //to do something
          
          } 
   });

[ZK] Messagebox EventListener

捕捉Question Messagebox的事件

//popup messagebox
Messagebox.show("Are you sure?",
      "Question", Messagebox.OK | Messagebox.CANCEL,
      Messagebox.QUESTION, new EventListener() {
       public void onEvent(Event event) throws Exception {
        //if clicks ok to do something
        if (((Integer) event.getData()).intValue() == Messagebox.OK) {
         //to do something
        }
       }
      });

星期二, 3月 01, 2011

[ZK] ZK Eclipse Setting

From: ZK Essentials/Working with the Sample Applications/Setting Up the Applications Using Eclipse

In the fifth step:
"Once the download is complete, go to Window > Preferences > ZK > ZK Packages, click Add File/Directory to add the ZK package downloaded"

The default ZK Package versioin is 3.6.3, so downloaded the latest one which is zk-bin-5.0.5.zip from zk downloads. Then keep following the fifth step to select the downloaded file and then the latest version could be displayed as an option.

星期三, 1月 26, 2011

[ZK] comfirm in zk component

使用程式控制替元件加入comfirm javascript。
範例如下:
//removePhoto.setWidgetListener("onClick", "alert('test');");
removePhoto.setWidgetListener("onClick", "if(!confirm('Remove Your Picture?')){evt.stop({au:true});}");

A client-side event listener could stop the sending of a widget event to the server by invoking Event.stop(Map) with {au:true}, such as

evt.stop({au: true});

Reference:
ZK Client-side Reference/Notifications/Widget Events
ZK Client-side Reference/Communication/AU Requests/Client-side Firing

星期二, 11月 30, 2010

[ZK] ZK Ajax Framework

最近專案需求使用JAVA EE來開發,評估之後決定選用ZK Framework來作為前端UI設計,感覺很類似.net的元件,有很多現成的componets可以使用。重點是台灣軟體公司所開發的,一定要支持一下國貨。

其他你感興趣的文章

Related Posts with Thumbnails