This talk will explain the Google Web Toolkit (GWT), GWT architecture, and why you would want to use GWT. In addition, it will include a demo of GWT and the recently released GWT Designer (a tool that makes GWT development easy and that makes it fast to generate a complicated UI).
11. GWT Architecture JRE Emulation Library (java.lang and java.util) GWT Web UI Class library Class Libraries Java-to-JavaScript Compiler hosted web browser Designer Development tools
27. a. Instantiate Service Interface using GWT.create() public void menuCommandsayHello(String msg) { MyHelloServiceAsync myhelloService = GWT.create(MyHelloService.class);
28. b. Make the Call with an asynchronous callback object public void menuCommandsayhello(String msg) { ... // (d) Make the call. Control flow will continue immediately and later // 'callback' will be invoked when the RPC completes. myhelloService.sayHello(msg, new AsyncCallback() { public void onSuccess (Object result) { // update page with server response data } public void onFailure (Throwable caught) { // handle failure } }); }
Java dev framework for complex web Java-to-JavaScript compiler Designer(Widget, event, styling, code generation) Hosted mode When app deploy to prod compiler translates Java application to browser-compliant JavaScript, CSS, and HTML
Use GWT commandline tool IDE plugins: intellij, eclipse, Netbean etc Install GWT plugin Create a java application, select GWT in the process Create a sample GWT application Install gwt development plugin for browsers IE, Firefox, Safari.-No chrome plugin yet
Static type checking in the Java boosts productivity while reducing errors. Common JavaScript errors (typos, type mismatches) are easily caught at compile time Code prompting/completion (through IDE) Automated Java refactoring Java-based OO designs are easier to communicate and understand, thus making AJAX code base more comprehensible.
No need to code JavaScript No need to handle browser incompatibilities No need to use DOM APIs No need to build commonly used Widgets Java Tools JUnit integration Internationalization Designer
GWT Java-to-JavaScript Compiler GWT Hosted Web Browser GWT Designer JRE emulation library GWT contains JavaScript implementations of the most widely used classes in the Java standard class library GWT Web UI class library Similar to Swing UI Parses the original Java code Full parser, almost all Java constructs will be parsed correctly. Generates a full Abstract Syntax Tree (AST) GWT's compiler isn't a parlor trick, it's a real code parser and cross-language compiler Performs optimization, dead-code elimination, dynamic analysis, and other code fixups The generated JS is fast and efficient, sometimes faster than what you might write yourself Optimization All code is optimized, including some unusual tricks (like turning some methods into wrapped statics) Dead-Code Elimination Remove any code that cannot be reached, or always returns the same value(s) Javascript Generation Generate Javascript, including all necessary browser-specific checks and workarounds Javascript obfuscation and size reduction Javascript is (optionally) obfuscated to protect your trade-secrets, and to reduce it's size
Swing like Event Driven UI frameworks Far easier to manipulate DOM using Java classes than using DOM API Much easier to quickly build interfaces that works correctly on all browsers using widgets
Swing like Event Driven UI frameworks Far easier to manipulate DOM using Java classes than using DOM API Much easier to quickly build interfaces that works correctly on all browsers using widgets
A mechanism for interacting with the server by invoking a method asynchronously Makes it easy for the client and server to pass Java objects back and forth over HTTP You could move all UI logic to the client improved performance, reduced bandwidth, reduced web server load, and a pleasant user experience