Tuesday, 24 April 2012

ZK MVC Using .GenericAutowireComposer utility class

This is the third post in a series of ZK MVC

I am just following the zk documentation and creating another sample 
here is the ZK Documentation url

Before this, summary of the previous post is

We started with Composer 

Then we removed all the event listeners and it is done by zk automatically by  genericcomposer utility class


Now we will see how we can remove all those binding using getfellow methods. This can be done
using org.zkoss.zk.ui.util.GenericAutowireComposer utility class which extends GenericComposer class and add the auto-wire features

Here is my zul code

<?page title="Example7" 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 />
<window title="MVC Pattern using org.zkoss.zk.ui.util.GenericAutowireComposer" border="normal" width="700px"  apply="com.me.Example8">
<column label="" />
<column label="" />
First Name :
<textbox id="firstName" />
Last Name :
<textbox id="lastName" />
Address :
<textbox id="address" />
<button id="Clear" label="Clear" forward="onClick=onClear_btn"/>


Here is my Composer java file

package com.me;

import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.util.GenericAutowireComposer;
import org.zkoss.zul.Textbox;

public class Example8 extends GenericAutowireComposer {

private static final long serialVersionUID = 1L;
private Textbox firstName; //auto-wired
private Textbox lastName; //auto-wired
private Textbox address; //auto-wired

//all getFellow() codes are removed

public void onClear_btn(Event event) {

Again here is the source code and demo

In the next post, we will see how to Get Rid of Those "forward" Attributes
using GenericForwardComposer

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...