Google Web Toolkit
by Bruce Perry
|
Pages: 1, 2, 3, 4, 5
Web Developer's Hard Knocks
applicationCreator also creates the HTML front end of your Ajax application, in this case called MyForm.html.
What if your application HTML has to meet a standard such as XHTML transitional or strict? In terms of XHTML transitional, I first added the required DOCTYPE to the top of MyForm.html, as well as the html tag's associated attributes:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/2000/REC-xhtml1-20000126/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
I then uploaded MyForm.html to the World Wide Web Consortium's HTML validator at http://validator.w3.org/.
After running the validator, I made a few simple changes to the HTML, such as properly closing the meta tags and adding a: type="text/javascript" to the script tag.
Strict: Tsk, Tsk
However, if you want to meet the XHTML Strict standard, then a few more complex changes may be required. For example, the W3C's validator flagged as an "undefined element" the iframe tag that is required for GWT's history support (providing the same functionality as a browser back button). XHTML Strict has removed the iframe element.
This may not represent a problem for you (and may be solved by the GWT's future releases, as well as any other apparent issues); however, you can implement alternate strategies such as extending the GWT's classes and creating your own compliant widgets.
Shimming Widgets Into Place
An issue that always arises in web development involves the visual design of the application. The project's designer wants the page to look exactly like their creation in Adobe Illustrator, right?
Although you may not be able to achieve this eye-candy utopia while working on a complex Ajax project, you can use Firefox's DOM Inspector to at least view the HTML that your Java classes ultimately generate. Then work from there.
Go to Firefox's Tools=>DOM Inspector menu item (see Figure 5.)

Figure 5: DOM Inspector provides a behind-the-scenes glimpse (Click image for full-size screen shot)
This shows that the com.google.gwt.user.client.ui.Grid object you are working with in the Java code is implemented as an HTML table tag. The TD tag in this table that contains the OK, Submit button is associated with a style attribute that has the value "verticle-align:top."
This lines the button up with the top of the textarea. Here is the associated Java code in the MyForm.java class that initiated the correct alignment:
//set the vertical alignment for the OK button's cell
grid.getCellFormatter().setVerticalAlignment(3,0,
HasVerticalAlignment.ALIGN_TOP);
Without this call in the code, the button floated amateurishly down around the textarea's mid-section.
Now to get only that button to align flush left with the labels above it.
Resources
- Google Web Toolkit: http://code.google.com/webtoolkit/
- This article's code: gwtarticle_jul06.zip
Share your experience in our forums.
(* You must be a member of XML.com to use this feature.)
Comment on this Article
| Titles Only | Titles Only | Newest First |
- AA Locksmith Los Angeles 866-214-8964 / os Angeles Locksmith Services.
2009-02-24 19:07:58 toolmannet [Reply]
Locksmith Services Los Angeles County all jobs Great Costuner satisfaction. providing the best locksmith services in los angeles county,
call us at 866-214-8964
or visit us at http://www.alocksmithla.com
LA Locksmith, locksmith los angeles
- Submission sends empty string to servlet...
2006-09-21 15:00:46 MrSwadge [Reply]
I have got the servlet running OK with my instance of Tomcat and the request is getting through, however my form is sending the data as a blank string. What have I done wrong?
- Submission sends empty string to servlet...
2006-09-21 15:07:55 MrSwadge [Reply]
Ack! I'm so stupid.
//for the sake of brevity, clipped...
I filled in the gap and it worked perfectly.
- Submission sends empty string to servlet...
- Pretty Good - Not Very GoodThough
2006-08-09 04:06:31 tomorrowist [Reply]
It's a pretty good framework created by Google. But I don't get one thing - why is it that they are restricting server side programming by forcing the Servlet to extend the RemoteServiceServlet method? I think this tool would have been even more useful, if it had restricted the Java to Javascript compiler to just the client side. That would have kept the client and server side losely coupled.
I also don't quite like the Component model of Client development. Facilitating client development using the document object model with HTML (something like a JSP taglib for client side javascript?) would have been a very good choice. By that, there will be very little issues with the web-design. This architecture makes web-design highly dependent on client side java code, which again is not good.
Otherwise, the guys at google have yet again come up with an innovative developer tool, but I think that just like others, this toolkit will also be restricted to making AJAX goodies, and make it highly difficult for use in commercial applications.
- Why the Ajax has to be so complex?
2006-07-13 20:57:45 raman233 [Reply]
The following webpage says that GWT is complex and incomplete solution, which is best for very smart people and proposes a simple and complete Ajax GUI Classes for not so smart people: http://www.cbsdf.com/ps_blog/why-other-frameworks.htm So many pages of the article certainly shows that GWT is more hard to learn.
- Why the Ajax has to be so complex?
2006-07-14 08:52:25 bwp [Reply]
Software developers have a number of different Ajax toolkits and libraries at their disposal. The challenge is to settle on a "flavor" that best matches your style, skills, and requirements. I also favor Prototype, for instance. The reason I like what I've seen in the GWT (which is still in beta) is that 1) I use Java; 2) the GWT allows me to design an Ajax application using object-oriented design and UML drawings, a well-organized approach to software development; 3) the RPC mechanism GWT uses is servlet-based, and I use servlet containers for server-side processing; 4) the IDE I use, IntelliJ IDEA, is incorporating GWT support.
A JavaScript programmer, on the other hand, might just stick with the Dojo toolkit (http://dojotoolkit.org/) or Prototype. A user-interface designer may simply want to plug finished components into their templates. It all depends on your preferences.
- Why the Ajax has to be so complex?
- Nice toolkit , shame about the licence
2006-07-13 04:53:13 paulbrowne [Reply]
The Google Web Toolkit is a good piece of code , but there is a mistake in the article when it says 'it is available under an apache style licence'.
What the Google Website says is:
<blockquote>
The GWT Java-to-JavaScript compiler and hosted web browser are shipped binary-only and subject to the license below.
</blockquote>
My reading of 'the license below' is that you are restricted in what you can do (e.g. no redistribution) with these binary components. As a developer , this would restrict my ability to develop solutions based upon the toolkit.
Paul , Technology in Plain English (http://www.firstpartners.net/blog)
- Nice toolkit , shame about the licence
2007-01-31 07:14:23 Teresa3455 [Reply]
All GWT environment is now licensed under Apache 2.0 license.
- Nice toolkit , shame about the licence
2006-07-13 06:13:22 bwp [Reply]
Thanks for pointing out these specifics. The Java class libraries that comprise the GWT API are included under an Apache style license, but the Java-to-JavaScript compiler and hosted web browser have different licensing restrictions, as summarized at: http://code.google.com/webtoolkit/download.html .
This site points out that "the code you create with GWT is yours. Google does not assert any intellectual property rights to code or content that you create using GWT." To answer any remaining questions a developer might have about the GWT's licensing ramifications, however, you would have to delve into the fine print and/or have a lawyer look at the entire license's language.
- Nice toolkit , shame about the licence
