10/07/2006 令Sn Google Web Toolkit (GWT) Basics Sang Shin Java Technology Architect Evangelist Sun Microsystems, Inc sangshin@sun.com Www JavapassIon com Welcome to google Web Toolkit presentation
Google Web Toolkit (GWT) Basics Sang Shin Java Technology Architect & Evangelist Sun Microsystems, Inc. sang.shin@sun.com www.javapassion.com Welcome to Google Web Toolkit presentation. 10/07/2006
10/07/2006 ●S Disclaimer Acknowledgments Even though sang shin is a full-time employee of Sun microsystems, the contents here are created as his own personal endeavor and thus does not necessarily reflect any official stance of Sun Microsystems on any particular technology Most of the slides in this presentations are created from the contents from Google Web Toolkit(GWT) website >http://code.googlecom/webtoolkit/ 2
Source: http://code.google.com/webtoolkit/ 2 Disclaimer & Acknowledgments • Even though Sang Shin is a full-time employee of Sun Microsystems, the contents here are created as his own personal endeavor and thus does not necessarily reflect any official stance of Sun Microsystems on any particular technology • Most of the slides in this presentations are created from the contents from Google Web Toolkit (GWT) website > http://code.google.com/webtoolkit/ 10/07/2006
10/07/2006 ●S Agenda What is Why GWT? building user interface GWT Widgets vent Handling ylIng Remote Procedural call (RPC Steps for building GWT RPC application Serializable type Handling exceptions This is what we are going to learn in this presentation First, we will learn what GWT is and why and when you want to use GWT for building AJAX applications We will then learn how to use built-in widgets that come with the GWT package. We will learn how to create and register event handlers to widgets. We will also learn how Css styles can b ttached to widge The next topic is how to perform Remore procedure call between the client and server. We will start with step by step guideline on how to do it. We will briefly touches upon how parameter and return data types are serialized. We will also learn how to do handle exceptions that might occur when RPC operation is being performed
This is what we are going to learn in this presentation. First, we will learn what GWT is and why and when you want to use GWT for building AJAX applications. We will then learn how to use built-in widgets that come with the GWT package. We will learn how to create and register event handlers to widgets. We will also learn how CSS styles can be attached to widgets. The next topic is how to perform Remore procedure call between the client and server. We will start with step by step guideline on how to do it. We will briefly touches upon how parameter and return data types are serialized. We will also learn how to do handle exceptions that might occur when RPC operation is being performed. Source: http://code.google.com/webtoolkit/ 3 Agenda • What is & Why GWT? • Building User interface > GWT Widgets > Event Handling > Styling • Remote Procedural Call (RPC) > Steps for building GWT RPC application > Serializable types > Handling exceptions 10/07/2006
10/07/2006 ●S Agenda JavaScript Native Interface (JSNi) Motivation for jsni Accessing native JavaScript code from Java code Accessing Java methods and fields from native JavaScript GWT Project GWT Module configuration Deployment Ve will talk about JavaScript Native Interface which is called JSNI. First, we will learn when you want to use JsNI. Then we will learn how you can access native JavaScript code from Java code and vice versa. Lastly we will learn the GWT project related information including module configuration and deployment
We will talk about JavaScript Native Interface which is called JSNI. First, we will learn when you want to use JSNI. Then we will learn how you can access native JavaScript code from Java code and vice versa. Lastly we will learn the GWT project related information including module configuration and deployment. Source: http://code.google.com/webtoolkit/ 4 Agenda • JavaScript Native Interface (JSNI) > Motivation for JSNI > Accessing native JavaScript code from Java code > Accessing Java methods and fields from native JavaScript code • GWT Project > GWT Module configuration > Deployment 10/07/2006
10/07/2006 令Sn What is and Why Gwr?
What is and Why GWT? 10/07/2006
10/07/2006 ●S What is GWT? Java software development framework that makes writing AJAX applications easy Let you develop and debug AJAX applications in the Java language using the Java development tools of your choice NetBeans or Eclipse applications When you deploy your application to production, the compiler translates your Java application to browser-compliant JavaScript and HTML Source hatede google comebtcid 6 You can think of GWT as Java software development framework for building AJAX pplication In other words, it lets you develop and debug AJAX applications in the Java development environment. You can use your favorite development tool such NetBeans or Eclipse to develop the application. When you are done with the testing and debugging, you can deploy the application. During the deployment phase, the GWT compiler compiles the Java code into JavaScript and HTML
You can think of GWT as Java software development framework for building AJAX application. In other words, it lets you develop and debug AJAX applications in the Java development environment. You can use your favorite development tool such as NetBeans or Eclipse to develop the application. When you are done with the testing and debugging, you can deploy the application. During the deployment phase, the GWT compiler compiles the Java code into JavaScript and HTML. Source: http://code.google.com/webtoolkit/ 6 What is GWT? • Java software development framework that makes writing AJAX applications easy • Let you develop and debug AJAX applications in the Java language using the Java development tools of your choice > NetBeans or Eclipse • Provides Java-to-JavaScript compiler and a special web browser that helps you debug your GWT applications > When you deploy your application to production, the compiler translates your Java application to browser-compliant JavaScript and HTML 10/07/2006
10/07/2006 ●S Two Modes of Running GWT App Hosted mode Your application is run as Java bytecode within the Java Virtual Machine(JVM You will typically spend most of your development time in hosted mode because running in the JVM means you can take advantage of Java's debugging facilities Web mode Your application is run as pure JavaScript and HTML, compiled from your original Java source code with the GWT Java-to-Java Script compiler When you deploy your GWT applications to production, you deploy this JavaScript and HTML to your web servers, so end users will only see the web mode version of your application GWT applications can be run in two modes &A *Hosted mode-In hosted mode, your application is run as Java bytecode within the Java Virtual Machine(JVM). You will typically spend most of your development time in hosted mode because running in the JVM means you can take advantage of Javas debugging facilities and remain within an idE like Eclipse Web mode-In web mode, your application is run as pure JavaScript and HTML, compiled from your original Java source code with the GWT Java-to JavaScript compiler. When you deploy your GWT applications to production, you deploy this JavaScript and HTML to your web servers, so end users will only see the web mode version of your application To support hosted mode, GWT ships with a special web browser with hooks into the JVM. See the GWT architecture diagram below for more information
GWT applications can be run in two modes: * Hosted mode - In hosted mode, your application is run as Java bytecode within the Java Virtual Machine (JVM). You will typically spend most of your development time in hosted mode because running in the JVM means you can take advantage of Java's debugging facilities and remain within an IDE like Eclipse. * Web mode - In web mode, your application is run as pure JavaScript and HTML, compiled from your original Java source code with the GWT Java-to-JavaScript compiler. When you deploy your GWT applications to production, you deploy this JavaScript and HTML to your web servers, so end users will only see the web mode version of your application. To support hosted mode, GWT ships with a special web browser with hooks into the JVM. See the GWT architecture diagram below for more information. Source: http://code.google.com/webtoolkit/ 7 Two Modes of Running GWT App • Hosted mode > Your application is run as Java bytecode within the Java Virtual Machine (JVM) > You will typically spend most of your development time in hosted mode because running in the JVM means you can take advantage of Java's debugging facilities • Web mode > Your application is run as pure JavaScript and HTML, compiled from your original Java source code with the GWT Java-to-JavaScript compiler > When you deploy your GWT applications to production, you deploy this JavaScript and HTML to your web servers, so end users will only see the web mode version of your application 10/07/2006
10/07/2006 ●S Why Use Java Programming Language for AJAX Development? Static type checking in the Java language boosts productivity while reducing errors Common JavaScript errors(typos, type mismatches are easily caught at compile time rather than by users at runtime Code prompting/completion is widely available Automated Java refactoring is pretty snazzy these days Java-based oo designs are easier to communicate and understand, thus making your AJAX code base more comprehensible with less documentation You can use all of your favorite Java development tools(Eclipse, IntelliJ JProfiler, JUnit) for AJAX development. Static type checking in the Java language boosts productivity while reducing errors Common JavaScript errors(typos, type mismatches )are easily caught at compile time rather than by users at runtime Code prompting/completion is widely available Automated Java refactoring is pretty snazzy these days. Java-based oo designs are easier to communicate and understand, thus making your AJAX code base more compreher le with less documentation
Java technologies offer a productive development plaform, and with GWT, they can instantly become the basis of your AJAX development platform as well. Here are some of the benefits of developing with GWT: * You can use all of your favorite Java development tools (Eclipse, IntelliJ, JProfiler, JUnit) for AJAX development. * Static type checking in the Java language boosts productivity while reducing errors. * Common JavaScript errors (typos, type mismatches) are easily caught at compile time rather than by users at runtime. * Code prompting/completion is widely available. * Automated Java refactoring is pretty snazzy these days. * Java-based OO designs are easier to communicate and understand, thus making your AJAX code base more comprehensible with less documentation. Source: http://code.google.com/webtoolkit/ 8 Why Use Java Programming Language for AJAX Development? • Static type checking in the Java language boosts productivity while reducing errors. • Common JavaScript errors (typos, type mismatches) are easily caught at compile time rather than by users at runtime. • Code prompting/completion is widely available • Automated Java refactoring is pretty snazzy these days. • Java-based OO designs are easier to communicate and understand, thus making your AJAX code base more comprehensible with less documentation. 10/07/2006
10/07/2006 ●S Why GWT? No need to learn/use Java Script language Leverage Java programming knowledge you already have No need to handle browser incompatibilities and quirks GWT handles them for you No need to learn/use DOM APls Use Java aPls No need to handle forward/backward buttons browser-history GWT handles it for you No need to build commonly used Widgets >Most of them come with GWt ource. hatede- google cometic 9
. Source: http://code.google.com/webtoolkit/ 9 Why GWT? • No need to learn/use JavaScript language > Leverage Java programming knowledge you already have • No need to handle browser incompatibilities and quirks > GWT handles them for you • No need to learn/use DOM APIs > Use Java APIs • No need to handle forward/backward buttons browser-history > GWT handles it for you • No need to build commonly used Widgets > Most of them come with GWT 10/07/2006
10/07/2006 ●S Why GWT? Leverage various tools of Java programming language for writing/debugging/testing For example, NetBeans or Eclipse JUnit integration GWTs direct integration with JUnit lets you unit test both in debugger and in a browser and you can even unit test asynchronous RPCs Internationalization GWT includes a flexible set of tools to help you internationalize your applications and libraries GWT internationalization support provides a variety of techniques to internationalize strings, typed values, and Source htpdtde google omhettooir 10
. Source: http://code.google.com/webtoolkit/ 10 Why GWT? • Leverage various tools of Java programming language for writing/debugging/testing > For example, NetBeans or Eclipse • JUnit integration > GWT's direct integration with JUnit lets you unit test both in a debugger and in a browser and you can even unit test asynchronous RPCs • Internationalization > GWT includes a flexible set of tools to help you internationalize your applications and libraries > GWT internationalization support provides a variety of techniques to internationalize strings, typed values, and classes 10/07/2006