浏览 4216 次
锁定老帖子 主题:ZK plugin for Grails
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2007-10-31
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 1) Install Grails first (http://grails.codehaus.org/Installation)
2) Follow the Grails Quikc Start (http://grails.codehaus.org/Quick+Start), to build a simple Grails project with the Book domain class
3) Download ZK plugin , make sure you are in the root directory of your project, type
4) create a new file "list.zul" under "your_project\web-app" with the following content xml 代码
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 代码
2) create a zul file create a new file "service.zul" under "your_project\web-app" with the following content
xml 代码
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! 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |
发表时间:2007-10-31
nice work,you should join this plugin into grails plugins
|
|
返回顶楼 | |
发表时间:2007-10-31
Good job!
If you could resolve 'you can NOT use Grails controller after you installed the ZK plugin!' problem, that would be great! Cheers |
|
返回顶楼 | |