Chapter 7. Host Mode


What's the GwtAjax-shell script for? This script is another one of the GWT's command-line tools. The script will launch a special browser that the GWT provides, as well as a window that will display a log with debugging information for your application. This special browser is designed to debug and display your application as Java objects loaded into a Java Virtual Machine (JVM), before the GWT has generated JavaScript from it.

Along with the coding of your application in an IDE, the GWT calls this development stage host mode. Figure 5 shows a GWT application running in host mode.

Here is what the GwtAjax-shell script or XXX-shell looks like:

 #!/bin/sh APPDIR='dirname $0'; java -XstartOnFirstThread -cp "$APPDIR/src:$APPDIR/bin:/Users/bruceperry/1gwt/gwt-mac- 1.2.11/gwt-user.jar:/Users/bruceperry/1gwt/gwt-mac-1.2.11/gwt-dev-mac.jar" com.google.gwt.dev.GWTShell -out "$APPDIR/www" "$@" com.parkerriver.gwt.intro.GwtAjax/GwtAjax.html; 

Notice the Java classpath, the quoted string following the -cp option in the shell script. It includes the /src and /bin directories in the top level of the application, as well as the gwt-user.jar and gwt-dev-mac.jar (or, for instance, gwt-dev-linux.jar) libraries.

The code that you use or depend on to create your application, before launching host mode, must be included on the classpath. For instance, if you are using various JAR files, such as jdom.jar, junit.jar, or log4j.jar (representing the JDOM XML-handling library, the JUnit unit-testing framework, and the log4j logging classes, respectively) to develop server-side classes, and these classes are a part of the GWT application, then include the appropriate JARs in this shell script's classpath.

Figure 7-1. A GWT application running within the framework's special browser


The purpose of this browser mode is to allow the developer to make incremental changes in the application, then get visual feedback, before the tool compiles the widgets and underlying logic into JavaScript. You can also compile your Java code into JavaScript within the host mode environment, which then launches your default browser, such as Firefox, to display the application. To accomplish this task, click the Compile/Browse button on the browser.




Google Web Toolkit for Ajax
Google Web Toolkit GWT Java AJAX Programming: A step-by-step to Google Web Toolkit for creating Ajax applications fast
ISBN: 1847191002
EAN: 2147483647
Year: 2006
Pages: 29

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net