Professional Documents
Culture Documents
Eric West
Paul Zolnierczyk
Overview
What is GWT?
The motivation behind GWT
GWT Setup
Code Example
Strengths and Weaknesses
Conclusion
What is the GWT?
Core
Java-to-Javascript compiler
Functionality
Automates client-server communication
Not reliant on traditional postbacks (page loads)
Utilizes AJAX (Asynchronous JavaScript and XML)
Widget library (UI components)
Really simple RPC
Use serializable classes
GWT does the rest
Both client and server agree on object
No XML definition required
Motivation
Avoid Javascript, use Java
Javascript is extremely difficult to debug.
No compile time errors
Javascript can mimic an OO style, but objects are not aware of
eachother until runtime invocation.
All the perks of Java and your favorite IDE
Refactoring
Debugging (breakpoints)
Unit testing
Javadocs
OO design patterns
Motivation Continued
Simplify the development process
Building a complex app is difficult enough. Connecting
the client and service using AJAX can be a nightmare.
Create a rich UI that works within a browser
Automate web native functionality
Back and Forward buttons
RESTful urls
Links represent a state in the web app that can be revisited.
CSS Styles
Keyboard support
A conventional (simple) AJAX setup
<div id="ajax_output"> document.getElementById(
Waiting to be replaced by Ajax Call "ajax_output").innerHTML
</div> = xmlHttp.responseText;
}
<script type="text/javascript"> } catch (e) {
var xmlHttp=null; document.getElementById("ajax_output").
different browser innerHTML = "Error on Ajax return call : " + e.description;
try { }
// Firefox, Opera 8.0+, Safari, IE7+
xmlHttp = new XMLHttpRequest(); }
} catch (e) { xmlHttp.open("get","pages/index.html");
// Internet Explorer xmlHttp.open(RequestType, Source);
try { xmlHttp.send(null);
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) { </script>
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
}
xmlHttp.onreadystatechange = function(){
if (xmlHttp.readyState == 4)
try {
if (xmlHttp.status == 200) {
function populateList()
{
new Ajax.Updater('listcontainer', handlerAddress, {
method: 'get',
parameters: {
filter1: document.getElementById("dropDownList1").value,
filter2: document.getElementById("dropDownList2").value
},
onLoading: function() {
loadingImgage.className = "";
},
onComplete: function() {
loadingImg.className = "hidden";
},
onFailure: function(){
alert("An error occurred completing your request.");
}
});
}
//]]>
</script>
Really simple RPC
5. Open eclipse
GWT Integration Cont’d
6. Click File -> Import 7. Choose "Existing
menu Projects into Workspace“
GWT Integration Cont’d
8. Enter the directory that has ".project" file.
GWT Integration Cont’d
9. You see your ‘YourProject' project on eclipse
How to Build and Call GWT RPC
Service
There are always three steps involved to make GWT RPC service.
Defining the service's synchronous and asynchronous interface
(client side)