`
2277259257
  • 浏览: 498466 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

MyEclipse构建zk开发环境

 
阅读更多

今天弄了一下午,还好照着别人的 弄好了,怕以后忘了,赶紧转载在这:

在MyEclipse里创建ZK的开发环境

ZK是一个很优秀的AJAX框架,号称"Ajax framework without javascript",有点像GWT的实现,但是与GWT的完全桌面开发思想不同,它支持用ZUL,一种ZK的界面脚本来写界面,开发效率很高,界面也很漂亮,具体的介绍可以去看看它的主页:http://www.zkoss.org。但是很可惜的是,ZK目前还没有Eclipse的插件,但是利用MyEclipse提供的相关工具,我们可以创建一个差强人意的开发环境出来,本文就对此环境的创建做了具体介绍,本文的环境是JDK6.o+Eclipse3.3+MyEclipse6.0M+ZK2.4.1。

首先,去http://www.zkoss.org下载最新版的ZK,目前是2.4.1,下载开发包以及demo,下载的开发包里有ZK的开发库,以及用到的库,还有一些扩展库,另外就是ZK的源码,其中开发包下的dist目录结构如下所示:

├─lib
│ │ zcommon.jar
│ │ zhtml.jar
│ │ zk.jar
│ │ zkplus.jar
│ │ zul.jar
│ │ zweb.jar
│ │
│ ├─ext
│ │ bsh.jar
│ │ commons-el.jar
│ │ commons-fileupload.jar
│ │ commons-io.jar
│ │ Filters.jar
│ │ groovy.jar
│ │ jcommon.jar
│ │ jfreechart.jar
│ │ jruby.jar
│ │ js.jar
│ │
│ └─zkforge
│ dojoz.jar
│ fckez.jar
│ gmapsz.jar
│ json_simple.jar
│ timelinez.jar

├─src
│ zcommon-sources.jar
│ zhtml-sources.jar
│ zk-sources.jar
│ zkplus-sources.jar
│ zul-sources.jar
│ zweb-sources.jar

├─WEB-INF
│ └─tld
│ ├─web
│ │ core.dsp.tld
│ │ html.dsp.tld
│ │
│ ├─zk
│ │ core.dsp.tld
│ │
│ └─zul
│ core.dsp.tld

└─xsd
zul.xsd

将这个目录下的所有文件都拷贝到一个专门的目录,(我一般喜欢把经常用到的第三方库放在一个专门的文件夹里,并且在eclipse里创建对应的user library),比如我放在d:\EclipseUserlib\ZK下。

第二步,创建用户自定义库。在eclipse里打开window->preferences->java->build path->user libraries,如下图所示:

MyEclipse构建zk开发环境
如上图所示,点击New按钮可以创建一个新的用户库,点击建好的库后,激活Add Jars...按钮,可以添加这个用户库相关的jar包,这里我们创建三个用户库,即ZK Ajax Frame、ZK Ajax Framework Extendsion以及ZK Ajax Framework Forge Library三个,分别对应上面目录结构中的lib、ext以及zkforget。
另外一个小trick,点开jar包前的+号,可以看到有一个source attachment,双击它可以出来一个对话框,让你选源文件所在地,这里选择上面目录下的src文件夹下的对应文件,这样就可以在eclipse里使用代码浏览功能。
第三步,添加xsd到用户xml catalog entry里。这是为了确保我们可以更好的地使用MyEclipse XML Editor的功能。打开window->preferences->MyEclipse->Files and Edtors->XML->XML Catalog,如下图所示:
 
 
MyEclipse构建zk开发环境
点击Add,在弹出对话框里添加上面目录中的zul.xml到catalog中。
第四步:添加自己的自定义xml生成wizard。
打开%MyEclipse安装目录%\eclipse\plugins\com.genuitec.eclipse.wizards_5.9.100,其中templates\xml是用来存放xml文件模板的,这里我们需要生成如下几个文件:
LangAddon.vtl
Portlet.vtl
ZK.vtl
ZKWeb.vtl
ZUL.vtl
前四项分别对应zkdemo\WebContent\WEB-INF下的lang-addon.xml、portlet.xml,zk.xml和web.xml,只需要把这些文件拷贝到xml目录下,并且对应修改文件名为上述文件名即可。另外注意:打开每个vtl文件,第一行由“<?xml version="1.0" encoding="UTF-8"?>修改为“<?xml version="1.0" encoding="$encoding"?>”。
其中ZUL文件的内容如下所示:
 
<?xml version="1.0" encoding="$encoding"?>
<?page title="title" ?>
<!--
action.zul

{{IS_NOTE
Purpose:

Description:

History:
Tue Oct 25 09:51:30 2005, Created by tomyeh
}}IS_NOTE

Copyright (C) 2005 Potix Corporation. All Rights Reserved.

{{IS_RIGHT
}}IS_RIGHT
-->
<zk xmlns="http://www.zkoss.org/2005/zul"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.zkoss.org/2005/zul http://www.zkoss.org/2005/zul ">
</zk>
然后修改%MyEclipse安装目录%\eclipse\plugins\com.genuitec.eclipse.wizards_5.9.100\templates.xml,在<!-- XML Templates -->后面添加如下内容:
<template
context="com.genuitec.eclipse.wizards.xml"
script="templates/xml/ZKWeb.vtl"
name="XML template for a web.xml file with ZK capability"/>
<template
context="com.genuitec.eclipse.wizards.xml"
script="templates/xml/LangAddon.vtl"
name="XML template for a lang-addon.xml file for ZK"/>
<template
context="com.genuitec.eclipse.wizards.xml"
script="templates/xml/Portlet.vtl"
name="XML template for a port-let.xml file for ZK"/>
<template
context="com.genuitec.eclipse.wizards.xml"
script="templates/xml/ZK.vtl"
name="XML template for a zk.xml file"/>
<template
context="com.genuitec.eclipse.wizards.xml"
script="templates/xml/ZUL.vtl"
name="XML template for a *.zul file"/>
保存后重新打开eclipse。
第五步,添加新的文件类型。打开window->preferences->general-content types,如下图所示:
 
MyEclipse构建zk开发环境
其中给Java Source File添加*.zs,给XML添加*.zul,给JSP添加*.dsp,给HTML添加*.zhtml。
到此在MyEclipse下我们已经搭建了一个简易但是实用的ZK开发环境。
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics