Tuesday, 24 April 2012

ZK MVC An Annotation Based Composer For MVC

Finally , we will end using zk 6 An Annotation Based Composer For MVC
This is the 5th post in a series of ZK MVC
Here is the zk documentation and we are following that
and creating new example

Here is the Summary

Method 1 : Implements Composer
We implement Composer interface. Here we used getfellow method to hold the
reference for the UI Components and also we added listener to handle

Here is the Link for the first post

Method 2 : extends GenericComposer
Here, we removed all the event lisener by extending the GenericComposer
But remember, we need to call super doaftercompose.

Here is the link for the second post

Method 3: extends GenericAutowireComposer
Here, we removed all the getfellow methods and let them auto wired
Here we dont need override doaftercompose


Method 4: extends GenericForwardComposer
Here, we removed forward attributes using GenericForwardComposer utility class
Here is the link

Finally we will the same output using zk 6 An Annotation Based Composer For MVC

A composer analogous to GenericForwardComposer. Instead of wiring variables and adding event listeners by naming convention, this composer do the work by annotation and selectors.

Here is my zul code

<?page title="Example10" contentType="text/html;charset=UTF-8"?>
value=" http://books.zkoss.org/wiki/Small_Talks/2008/August/ZK_MVC_Made_Easy.
style="font-size : 18px;font-family: verdana,arial,sans-serif;" />
<separator />
title="MVC Pattern An Annotation Based Composer For MVC"
border="normal" width="700px" apply="com.me.Example10">
<column label="" />
<column label="" />
First Name :
<textbox id="firstName" />
Last Name :
<textbox id="lastName" />
Address :
<textbox id="address" />
<button id="Clear" label="Clear" />


Here is my composer
package com.me;

import org.zkoss.zk.ui.select.SelectorComposer;
import org.zkoss.zk.ui.select.annotation.Listen;
import org.zkoss.zk.ui.select.annotation.Wire;
import org.zkoss.zul.Textbox;
import org.zkoss.zul.Window;

public class Example10 extends SelectorComposer<Window> {

private Textbox firstName;
private Textbox lastName;
private Textbox address;

public void submit() {


Here is the demo

Here is the source code

No comments:

Post a Comment

Passing Parameter between two files using MVVM

This examples shows how to pass parameter between two zul screens. In this example, we are passing some parameters from the parent vm to...