`

GWT1.7学习之 了解基本的使用

阅读更多

下载完了,解压缩到G盘,目录如下所示:

写道
文件夹 PATH 列表
卷序列号码为 002E0031 6015:5EE8

├─doc
│ ├─helpInfo
│ └─javadoc
│ ├─com
│ │ └─google
│ │ └─gwt
│ │ ├─animation
│ │ │ └─client
│ │ ├─benchmarks
│ │ │ └─client
│ │ ├─core
│ │ │ ├─client
│ │ │ └─ext
│ │ │ ├─linker
│ │ │ └─typeinfo
│ │ ├─dom
│ │ │ └─client
│ │ ├─event
│ │ │ ├─dom
│ │ │ │ └─client
│ │ │ ├─logical
│ │ │ │ └─shared
│ │ │ └─shared
│ │ ├─http
│ │ │ └─client
│ │ ├─i18n
│ │ │ ├─client
│ │ │ └─rebind
│ │ │ ├─format
│ │ │ └─keygen
│ │ ├─json
│ │ │ └─client
│ │ ├─junit
│ │ │ ├─client
│ │ │ └─tools
│ │ ├─user
│ │ │ ├─client
│ │ │ │ ├─rpc
│ │ │ │ └─ui
│ │ │ ├─datepicker
│ │ │ │ └─client
│ │ │ └─server
│ │ │ └─rpc
│ │ └─xml
│ │ └─client
│ └─resources

└─samples
├─DynaTable
│ ├─src
│ │ └─com
│ │ └─google
│ │ └─gwt
│ │ └─sample
│ │ └─dynatable
│ │ ├─client
│ │ └─server
│ └─war
│ ├─dynatable
│ └─WEB-INF
│ └─classes
│ └─com
│ └─google
│ └─gwt
│ └─sample
│ └─dynatable
│ ├─client
│ └─server
├─Hello
│ ├─src
│ │ └─com
│ │ └─google
│ │ └─gwt
│ │ └─sample
│ │ └─hello
│ │ └─client
│ └─war
│ ├─hello
│ └─WEB-INF
│ └─classes
│ └─com
│ └─google
│ └─gwt
│ └─sample
│ └─hello
│ └─client
├─I18N
│ ├─src
│ │ └─com
│ │ └─google
│ │ └─gwt
│ │ └─sample
│ │ └─i18n
│ │ └─client
│ └─war
│ ├─i18n
│ └─WEB-INF
│ └─classes
│ └─com
│ └─google
│ └─gwt
│ └─sample
│ └─i18n
│ └─client
├─JSON
│ ├─src
│ │ └─com
│ │ └─google
│ │ └─gwt
│ │ └─sample
│ │ └─json
│ │ ├─client
│ │ └─public
│ └─war
│ ├─json
│ └─WEB-INF
│ └─classes
│ └─com
│ └─google
│ └─gwt
│ └─sample
│ └─json
│ └─client
├─Mail
│ ├─src
│ │ └─com
│ │ └─google
│ │ └─gwt
│ │ └─sample
│ │ └─mail
│ │ └─client
│ └─war
│ ├─mail
│ └─WEB-INF
│ └─classes
│ └─com
│ └─google
│ └─gwt
│ └─sample
│ └─mail
│ └─client
└─Showcase
├─src
│ └─com
│ └─google
│ └─gwt
│ └─sample
│ └─showcase
│ ├─client
│ │ └─content
│ │ ├─i18n
│ │ ├─lists
│ │ ├─other
│ │ ├─panels
│ │ ├─popups
│ │ ├─tables
│ │ ├─text
│ │ └─widgets
│ ├─generator
│ └─public
│ ├─chrome
│ ├─dark
│ ├─images
│ └─standard
└─war
├─showcase
│ ├─chrome
│ ├─dark
│ ├─gwt
│ │ ├─chrome
│ │ │ └─images
│ │ │ └─ie6
│ │ ├─dark
│ │ │ └─images
│ │ │ └─ie6
│ │ └─standard
│ │ └─images
│ │ └─ie6
│ ├─gwtShowcaseSource
│ │ ├─css
│ │ │ ├─chrome
│ │ │ ├─chrome_rtl
│ │ │ ├─dark
│ │ │ ├─dark_rtl
│ │ │ ├─standard
│ │ │ └─standard_rtl
│ │ ├─java
│ │ └─raw
│ ├─images
│ └─standard
└─WEB-INF
└─classes
└─com
└─google
└─gwt
└─sample
└─showcase
├─client
│ └─content
│ ├─i18n
│ ├─lists
│ ├─other
│ ├─panels
│ ├─popups
│ ├─tables
│ ├─text
│ └─widgets
└─generator

 

 

将其添加到 环境变量path 中, 然后就可以在命令行直接使用附带的辅助工具来创建项目了..

 

然后我在此目录下建立了一个 gwtapp\hello 目录及子目录,进入hello文件夹dos提示符中输入:

写道
webAppCreator.cmd cn.iamsese.gwt.client.HelloWorld

 

将建立一个新项目,目录结构如下:

写道
hello
├─src
│ └─cn
│ └─iamsese
│ └─gwt
│ └─client
│ ├─client
│ └─server
└─war
├─helloworld
│ └─gwt
│ └─standard
│ └─images
│ └─ie6
└─WEB-INF
├─classes
│ └─cn
│ └─iamsese
│ └─gwt
│ └─client
│ ├─client
│ └─server
└─lib

 

建立完了,但是该怎么测试呢????

 

在网上找都是说,会有三个辅助工具 projectCreator , applicationCreator , junitCreator.. 没有找到在哪,可能是以前的版本有,但是现在没有,在google里面搜索,没有找到...

 

找了半天,不知道改怎么运行,看看实例,发现里面有个readme文件,仔细读读,原来 运行功能都藏在ant的 build.xml文件中,现录如下:

写道
If you prefer to work from the command line, you can use Ant to build your
project. (http://ant.apache.org/) Ant uses the generated 'build.xml' file
which describes exactly how to build your project. This file has been tested
to work against Ant 1.7.1. The following assumes 'ant' is on your command
line path.

To run hosted mode, just type 'ant hosted'.

To compile your project for deployment, just type 'ant'.

To compile and also bundle into a .war file, type 'ant war'.

For a full listing of other targets, type 'ant -p'.

 

意思是说,

本地服务器调试 运行 ant hosted

将gwt编译成成js 运行 ant

打包 ant war

下面是我这个helloworld里面的build.xml文件,

<?xml version="1.0" encoding="utf-8" ?>
<project name="HelloWorld" default="build" basedir=".">
  <!-- Configure path to GWT SDK -->
  <property name="gwt.sdk" location="G:/gwt-windows-1.7.0" />

  <path id="project.class.path">
    <pathelement location="war/WEB-INF/classes"/>
    <pathelement location="${gwt.sdk}/gwt-user.jar"/>
    <fileset dir="${gwt.sdk}" includes="gwt-dev*.jar"/>
    <!-- Add any additional non-server libs (such as JUnit) -->
    <fileset dir="war/WEB-INF/lib" includes="**/*.jar"/>
  </path>

  <target name="libs" description="Copy libs to WEB-INF/lib">
    <mkdir dir="war/WEB-INF/lib" />
    <copy todir="war/WEB-INF/lib" file="${gwt.sdk}/gwt-servlet.jar" />
    <!-- Add any additional server libs that need to be copied -->
  </target>

  <target name="javac" depends="libs" description="Compile java source">
    <mkdir dir="war/WEB-INF/classes"/>
    <javac srcdir="src" includes="**" encoding="utf-8"
        destdir="war/WEB-INF/classes"
        source="1.5" target="1.5" nowarn="true"
        debug="true" debuglevel="lines,vars,source">
      <classpath refid="project.class.path"/>
    </javac>
    <copy todir="war/WEB-INF/classes">
      <fileset dir="src" excludes="**/*.java"/>
    </copy>
  </target>

  <target name="gwtc" depends="javac" description="GWT compile to JavaScript">
    <java failonerror="true" fork="true" classname="com.google.gwt.dev.Compiler">
      <classpath>
        <pathelement location="src"/>
        <path refid="project.class.path"/>
      </classpath>
      <!-- add jvmarg -Xss16M or similar if you see a StackOverflowError -->
      <jvmarg value="-Xmx256M"/>
      <!-- Additional arguments like -style PRETTY or -logLevel DEBUG -->
      <arg value="cn.iamsese.gwt.client.HelloWorld"/>
    </java>
  </target>

  <target name="hosted" depends="javac" description="Run hosted mode">
    <java failonerror="true" fork="true" classname="com.google.gwt.dev.HostedMode">
      <classpath>
        <pathelement location="src"/>
        <path refid="project.class.path"/>
      </classpath>
      <jvmarg value="-Xmx256M"/>
      <arg value="-startupUrl"/>
      <arg value="HelloWorld.html"/>
      <!-- Additional arguments like -style PRETTY or -logLevel DEBUG -->
      <arg value="cn.iamsese.gwt.client.HelloWorld"/>
    </java>
  </target>

  <target name="build" depends="gwtc" description="Build this project" />

  <target name="war" depends="build" description="Create a war file">
    <zip destfile="HelloWorld.war" basedir="war"/>
  </target>

  <target name="clean" description="Cleans this project">
    <delete dir="war/WEB-INF/classes" failonerror="false" />
    <delete dir="war/helloworld" failonerror="false" />
  </target>

</project>

 

 

可以自己创建那几个命令辅助器的批处理文件....

 

下面是那个说明文件的原文:

写道
--- Generated by GWT WebAppCreator ---

Congratulations, you've successfully generated a starter project! What next?

-- Option A: Import your project into Eclipse (recommended) --

If you use Eclipse, you can simply import the generated project into Eclipse.
We've tested against Eclipse 3.3 and 3.4. Later versions will likely also
work, earlier versions may not.

In Eclipse, go to the File menu and choose:

File -> Import... -> Existing Projects into Workspace

Browse to the directory containing this file,
select "HelloWorld".

Be sure to uncheck "Copy projects into workspace" if it is checked.

Click Finish.

You can now browse the project in Eclipse.

To launch your web app in GWT hosted mode, go to the Run menu and choose:

Run -> Open Debug Dialog...

Under Java Application, you should find a launch configuration
named "HelloWorld". Select and click "Debug".

You can now use the built-in debugger to debug your web app in hosted mode.

To compile for web mode, just run your app in hosted mode and press the
"Compile/Browse" button.

-- Option B: Build from the command line with Ant --

If you prefer to work from the command line, you can use Ant to build your
project. (http://ant.apache.org/) Ant uses the generated 'build.xml' file
which describes exactly how to build your project. This file has been tested
to work against Ant 1.7.1. The following assumes 'ant' is on your command
line path.

To run hosted mode, just type 'ant hosted'.

To compile your project for deployment, just type 'ant'.

To compile and also bundle into a .war file, type 'ant war'.

For a full listing of other targets, type 'ant -p'.

-- Option C: Using another IDE --

GWT projects can be run in other IDEs as well, but will require some manual
setup. If you go this route, be sure to:

* Have your IDE build .class files into 'war/WEB-INF/classes'.
* Add gwt-user.jar and gwt-dev-<platform>.jar to your project build path.
* When creating a launch configuration, add a classpath entry for your 'src'
folder (this is somewhat unusual but GWT needs access to your source files).

If you get stuck, try to mimic what the Ant 'build.xml' would do.

 

我想说明的是,使用自带的浏览器浏览时超级的卡,很占内存,建议不要使用,可以使用额外的浏览器,或者将其放到tomcat里面去跑,要快得多....

 

 

1
0
分享到:
评论
1 楼 vb2005xu 2009-08-07  
测试页面:http://iamsese.appspot.com/
一个开源的web ui 推荐:
http://iamsese.appspot.com/mocha_v.0.9.5/index.html

相关推荐

Global site tag (gtag.js) - Google Analytics