Introduction

ZK Plugin for Grails introduces GroovyGrails mode for ZK. It seamlessly integrates ZK into the Grails stack. The plugin brings ZK and Grails to the next level of rapid RIA developement, also with convention-over-configuration, Spring, and Hibernate powers. It features:

Accessing to Grails domain classes, transactional service classes, and a vast number of plugins.

Adding Properties for Employee

Create a zul page

There are two generator scripts came with ZK Plugin for Grails. The following shows how to run create-zul to create employee.zul for you.

$ grails create-zul employee

This will also create grails-apps/composers/EmployeeComposer.groovy for you.

Edit employee.zul

Although the generator creates a ready-to-run zul file for you from the template, but it is just a skeleton to make you easier to start with. Open employee.zul, and delete all codes below vbox, then modify it as follows.

Of course, the key components which will be used in the composer are lstEmployee, and pagEmployee.

Editing EmployeeComposer

From the code, you may see 2 properties lstEmployee, and pagEmployee. Both are injected by GrailsComposer, which is a subclass ofGenericForwardComposer. They, apparently, represents listbox and paging components from your .zul file.

You may notice that there is afterCompose closure. This closure is run by doAfterCompose, and it's a Groovy place to initialize your components.

The auto-wired event handle onPaging_pagEmployee will be called everytime you click pagEmployee to change the active page. Note that, the only argument of the handler must be ForwardEvent or Event to make it work.

I also show you the use of Groovy's default argument value declared at redraw method. That is, calling redraw() in afterCompose means redraw(0).

Also in redraw method, there are two places to use dynamic methods added by ZKGrails. The first one is clear
, of which removes all listitem. The second one is append, which accepts component construction via ZK Builder.