GWT - Building Rich Internet Applications Using OO Tools
Google Web Toolkit- Build Rich WebApplications withOO ToolsBenjamin ArciszewskiSenior Software Engineer - StudyBlue
Todays Agenda● Introduce GWT and talk about what it is, why its different and why you should use it● Talk about good/bad of the toolkit● Describe the components of GWT at a high level● Go through the anatomy of a project● Walk through a sample app that is a little more complex than hello world● Bring it all together by showing some of the functionality on StudyBlue.com
PurposeTo get you excited about GWT and to build alarge community of GWT users in Wisconsin soStudyBlue has a large pool of qualifieddevelopers to choose from as we grow...
Something to think about...How many Java LOC are in the StudyBlue Webapplication (method used is Eclipse metricsplugin, only com.sb.* packages)?
10 Second History of the Web● Web pages● Interactive Web pages● Web applications● Rich Internet Applications
Ultimate Issue?● They all treat Rich Internet Applications as Web Pages!
Browser?● Rich Object Model● Performant Script processing engine (V8)● Local persistence● Rich Graphics (Canvas)● Rich set of programming APIs● Complete set of events
What is GWT?Google Web Toolkit (GWT) is a developmenttoolkit for building and optimizing complexbrowser-based applications. GWT is used bymany products at Google, including GoogleAdWords and Orkut. Its open source,completely free, and used by thousands ofdevelopers around the world.From:https://developers.google.com/web-toolkit/
What is GWT?GWT is a client-side framework fordeveloping rich internet applications inJava, taking advantage of all of thetools that come with a high-levellanguage like Java.From:Dale Beerman, Chief Technical Architect - StudyBlue
How GWT is Different● Code is in Java (mostly)● compiled to js/html● No need for ○ page templates ○ glue languages ○ scripting● Full use of Java tool stack ○ Eclipse debugger ○ Code complete ○ Continuous compilation● Shared code between client/server
Practical Description of GWT● Set of tools that turn Java into html/js. ○ Eclipse Plugin ○ Project Generator ○ J2SE proxy libraries ○ Compiler ○ Browser Plugin (for development) ○ Java Widget and Service API ○ RPC mechanism ○ WYSIWYG Visual Editor (We dont use)
Advantages for doing it this way...● Code is optimized for each browser during compile (read: optimization)● Full OO abstractions: inheritance, polymorphism, encapsulation, extension● One single language (mostly)● Ability to bind to native JS when needed● Code re-use ○ Components, Widgets and Services● High quality, easily usable, libraries
Disadvantages● Compile can be slow (especially w/ i18n) ○ One version for each browser, for each language, exponential growth...● Plugin used for local testing in browser● Give up some control (but not as much as you might think)● GWT Unit tests are SLOW● You sometimes think you are in Java
Anatomy of a GWT Project● Java code ○ client - compiled to js/html and run in browser ○ server - compiled to java and run on server ○ shared - both (must be compliant w/ client)● .gwt.xml - configuration file● .html host file - that will include your code● .css file - for styling
GWT - RPC● Its like magic ○ Define an Interface ○ Define an implementation in server ○ Define an implementation w/ callback in client.● To Configure ○ Create an interface in client ○ Create an asynchronous interface in client ○ Create an implementation on server that extends RemoteServiceServlet ○ Configure Servlet in web.xml● To use ○ Get the Async version from GWT (GWT.create) ○ Make calls, receive response in Callback
UI code● Widgets (Java objects) ○ Your code creates views via Extension and/or Composition● Customizable● Configurable● Similar to Swing● Extensible● Optional .ui.xml file bindings (StudyBlue)