Dr. Dobb's is part of the Informa Tech Division of Informa PLC

This site is operated by a business or businesses owned by Informa PLC and all copyright resides with them. Informa PLC's registered office is 5 Howick Place, London SW1P 1WG. Registered in England and Wales. Number 8860726.


Channels ▼
RSS

Web Development

Hands-On Google Web Toolkit


Getting Started

After downloading and installing GWT, make sure you are running a recent version of Java (Java 5 or higher is recommended; see the sidebar "Java 1.4 Versus Java 5"). Create a GWT project using your IDE or the projectCreator and applicationCreator programs supplied with the toolkit. Then select a web page where you want to insert the GWT component or application. This is known as the "host page" in GWT lingo. Listing One is the page we used in this article.

To inject the GWTFlow component into the page, we include our compiled JavaScript file (more on that later) and an HTML <div> placeholder element. Because GWTFlow needs to use special effects and support browser history, we also include a third-party JavaScript library and an <iframe> element. Listing Two is the resulting host page, with newly added elements in boldface.

<html>
 <head>
   <title>GWTFlow</title>
   <link rel="stylesheet" type="text/css" href="GWTFlow.css" />
 </head>
 <body>
 <div id="header">
   <div id="logo">
     <a class="blind" href="GWTFlow.html">GWTFlow</a>
   </div>
   <p>
     <a class="tblind" href="about.html">About</a>    
     <a class="tblind" href="contact.html">Contact</a>
   </p>
 </div>
 <div id="footer">
   <p>Copyright 2007 Adam Houghton</p>
 </div>
 </body>
</html>

Listing One

<html>
 <head>
   <title>GWTFlow</title>
   <link rel="stylesheet" type="text/css" href="GWTFlow.css" />
   <!— Inject GWT code by including compiled JavaScript file —>
   <script language='javascript' src='org.gwtflow.GWTFlow.nocache.js'></script>
   <!— JavaScript we'll later need for effects —>
   <script type="text/javascript" src="script/prototype.js"></script>
   <script type="text/javascript" src="script/effects.js"></script>
 </head>
 <body>
 <!— IFrame for GWT history support —>
 <iframe src="javascript:''" id="__gwt_historyFrame"
     style="width:0;height:0;border:0"></iframe>
 <div id="header">
   <div id="logo">
     <a class="blind" href="GWTFlow.html">GWTFlow</a>
   </div>
   <p>
     <a class="tblind" href="about.html">About</a>    
     <a class="tblind" href="contact.html">Contact</a>
   </p>
 </div>
 <!— GWTFlow will put its content in this div —>
 <div id="main"></div>
 <div id="footer">
   <p>Copyright 2007 Adam Houghton</p>
 </div>
 </body>
</html>
Listing Two


Related Reading


More Insights






Currently we allow the following HTML tags in comments:

Single tags

These tags can be used alone and don't need an ending tag.

<br> Defines a single line break

<hr> Defines a horizontal line

Matching tags

These require an ending tag - e.g. <i>italic text</i>

<a> Defines an anchor

<b> Defines bold text

<big> Defines big text

<blockquote> Defines a long quotation

<caption> Defines a table caption

<cite> Defines a citation

<code> Defines computer code text

<em> Defines emphasized text

<fieldset> Defines a border around elements in a form

<h1> This is heading 1

<h2> This is heading 2

<h3> This is heading 3

<h4> This is heading 4

<h5> This is heading 5

<h6> This is heading 6

<i> Defines italic text

<p> Defines a paragraph

<pre> Defines preformatted text

<q> Defines a short quotation

<samp> Defines sample computer code text

<small> Defines small text

<span> Defines a section in a document

<s> Defines strikethrough text

<strike> Defines strikethrough text

<strong> Defines strong text

<sub> Defines subscripted text

<sup> Defines superscripted text

<u> Defines underlined text

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task. However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

 
Disqus Tips To upload an avatar photo, first complete your Disqus profile. | View the list of supported HTML tags you can use to style comments. | Please read our commenting policy.