Section 8.4. Using a Subset of the J2SE

8.4. Using a Subset of the J2SE

For client-side Ajax coding in Java, the GWT only supports certain classes from the J2SE java.lang and java.util packages. Recall that your Java code is destined to be output as JavaScript, so the GWT API has to emulate each of the Java classes, such as ArrayList, Integer, or String, in JavaScript.

For example, I started using the java.text.DateFormat class, until I remembered that the java.text package is not available (right now) in the GWT API. So for that particular application, I had to rely on the java.util.Date functionality in lieu of creating my own module for the java.text classes.

Many of the classes that Java programmers use quite often from java.lang, however, are mirrored in the GWT. The GWT has included ArrayList, HashMap, and HashSet, for instance. Typically, you will find that enough GWT API classes exist to help you accomplish your task.

The following API web pages describe which classes the GWT makes available in java.lang and java.util.




You can use the breadth of J2SE and JEE packages in the server-side classes that are linked to your GWT application. This is because those objects will run within a Java Virtual Machine (JVM) on the server. For example, imagine that you use the GWT's RPC service API, in which a JavaScript object makes a remote procedure call to a servlet and exchanges data with that component. The servlet could use the java.text package, but the client-side classes that interact with it cannot, because they are restricted to the java.lang and java.util packages.

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 © 2008-2017.
If you may any questions please contact us: