Grails : agile, industrial strength, rapid web application development made easy!
ZK: the simplest way to make Web applications rich!
Do you want to combine both of them?
1. Install & test the ZK plug-in
3) Download
ZK plugin , make sure you are in the root directory of your project, type
- grails install-plugin full_path_to_zk_plugin
4) create a new file "list.zul" under "your_project\web-app" with the following content
xml 代码
- <?xml version="1.0" encoding="UTF-8"?>
- <?page zscriptLanguage="Groovy"?>
-
- <window border="normal" title="Groovy Test" id="MainWindow" width="400px">
- <zscript>
- books = Book.findAll()
- </zscript>
- <listbox>
- <listhead>
- <listheader label="ID"/>
- <listheader label="Title"/>
- <listheader label="Author"/>
- </listhead>
- <listitem forEach="${books}">
- <listcell label="${each.id}"/>
- <listcell label="${each.title}"/>
- <listcell label="${each.author}"/>
- </listitem>
- </listbox>
- </window>
5) test "list.zul", make sure you are in the root directory of your project, type "grails run-app", then browse to "
http://localhost:8080/your_project/list.zul", you should be able to view the following list.
2. How does ZK plugin do it?
Actually, you can find the whole source code of this plugin by browsing to "your_project\plugins\zkplugin-0.1", right now, ZK plugin is made up of three parts.
1) maintaining the basic ZK realted java libaries
2) Participating in web.xml Generation to add ZK related servlets
3) Participating in web.xml Generation to modify the "url-pattern" of Grails filter "sitemesh"
I find that accessing the "zul" file will just return a blank page with "sitemesh" filter mapped to "/*", so I have to modify the "url-pattern" of Grails filter "sitemesh". It means that you can NOT use Grails controller after you installed the ZK plugin!
I'm still working on it to see if there is a way to let Grails filter "sitemesh" to ignore some particular url-patterns, your comments are welcome!
3. Accessing the domain class
As you can see in the above sample, accessing domain classes in ZK is very simple, just as what you can do in Grails controller.
4. Accessing the service
Accessing grails services in ZK is also very easy. Grails will define a bean with name "xxxService" of each service "XxxService", and you can access the Services in zscript directly with the help of
DelegatingVariableResolver .
1) create a service.
create a new file "HelloService.groovy" under "your_project\grails-app\services" with the following content
groovy 代码
- class HelloService {
- def serviceMethod(username) {
- return username+", welcome to ZK&Grails world!"
- }
- }
2) create a zul file
create a new file "service.zul" under "your_project\web-app" with the following content
xml 代码
- <?xml version="1.0" encoding="UTF-8"?>
- <?variable-resolver class="org.zkoss.zkplus.spring.DelegatingVariableResolver"?>
- <?page zscriptLanguage="Groovy"?>
-
- <window border="normal" title="Groovy Test" id="MainWindow" width="400px">
- <textbox id="username"/>
- <button label="Call HelloService"
- onClick="result.value=helloService.serviceMethod(username.value)"/>
- <separator/>
- <label id="result"/>
- </window>
3) test it
Browse to "http://localhost:8080/your_project/service.zul", input a name and click the button!
Enjoy it, and any comments is welcome!
分享到:
- 2007-10-31 15:19
- 浏览 10877
- 评论(2)
- 论坛回复 / 浏览 (2 / 4214)
- 查看更多
相关推荐
总之,"APE Plugin for Nero"为Nero用户提供了一个方便的工具,使他们能够在不牺牲音质的前提下,利用Nero的全面功能来管理和操作APE格式的音频文件。通过理解无损音频格式的原理和特性,以及如何在Nero中有效使用...
SDL plugin for C4droid.apk
总的来说,"Grails plugin: Calendar"是Grails框架的一个实用扩展,它为构建时间管理功能提供了便利。通过了解和使用这个插件,开发者可以快速创建具有强大日历功能的Web应用,同时得益于Grails的灵活性和Groovy语言...
"VEEAM Rman Plugin for Oracle安装和使用手册" VEEAM Rman Plugin for Oracle是VEEAM公司开发的一款插件,旨在为Oracle RAC数据库提供备份和恢复解决方案。该插件可以与VEEAM Backup & Replication集成,提供了一...
Nagios Plugin for Cacti 是一款用于集成监控系统Nagios与网络性能绘图工具Cacti的插件。这个插件旨在扩展Cacti的功能,使其能够利用Nagios的强大监控能力,提供更全面、实时的网络及服务器状态信息。 Nagios是一款...
当我们谈论“Eclipse集成ZK插件zk_plugin”时,我们指的是在Eclipse中安装一个特定的插件,以便于开发者更方便地设计、调试和管理基于ZooKeeper的应用程序。 ZooKeeper插件(zk_plugin)通常提供了以下功能: 1. *...
- **Android开发支持**:Google Plugin for Eclipse 4.3提供了完整的Android SDK集成,包括项目创建、源代码编辑、资源管理、调试器、模拟器控制等,帮助开发者高效地进行Android应用开发。 - **ADT(Android ...
《Google Plugin for Eclipse 4.2:打造高效谷歌开发环境》 在软件开发领域,集成开发环境(Integrated Development Environment,简称IDE)扮演着至关重要的角色,它为开发者提供了集编码、调试、测试于一体的高效...
"Google Plugin for Eclipse" 是一款由Google开发的集成开发环境(IDE)插件,专为Eclipse设计,目的是为了方便开发者在Eclipse中进行Google相关的应用开发,如Android应用、Google App Engine应用等。这款插件提供了...
GWT Plugin For Eclipse (1) Google Web Toolkit
该文档是一份关于Unity Bluetooth LE Plugin for Android的技术文档,主要针对的是在Unity中开发Android低功耗蓝牙功能。文档中介绍和解释了如何使用这个插件,提供了一些版本更新的详细信息,以及设置和安装插件的...
JavaScript plugin for eclipse3.5 spket-1.6.18 破解版
《Grails Datastore GORM Plugin Support 2.0.4.RELEASE:开源项目的代码生成与Android MVC模式解析》 在IT行业中,开发高效且可维护的软件系统是至关重要的。Grails Datastore GORM Plugin Support 2.0.4.RELEASE...
Google Plugin for Eclipse 3.5 离线安装包 part2 分享给需要的人 支持eclipse 3.5 myeclipse 8.X
ZK Studio Eclipse Plugin是一款专为ZK框架开发者设计的集成开发环境插件。ZK框架是一种基于组件模型的Java Web应用框架,它简化了用户界面的构建和维护,提供了丰富的客户端组件和事件处理机制,同时支持服务器端的...
ZK Studio Eclipse Plugin是一款专为Eclipse集成开发环境设计的扩展工具,主要针对ZK框架进行优化,以提升开发者在ZK应用开发中的效率。ZK框架是一个基于组件的Java Web UI框架,它使得开发者可以使用声明式语言来...
python plugin for Inteij IDEA
《Grails Plugin Converters 2.3.1与Box Java SDK v2:开源项目的融合与应用》 在当今数字化时代,开发高效的Web应用程序是至关重要的。Grails Plugin Converters 2.3.1 和 Box Java SDK v2 是两个在开源世界中备受...
zk studion plugins zk studio eclipse plugin
weblogic 8.1 plugin for Eclipse 3.4 weblogic 8.1 plugin for Eclipse 3.4 weblogic 8.1 plugin for Eclipse 3.4