GOOGLE WEB TOOLKIT AS MODERN AJAX FRAMEWORK FOR DEVELOPMENT OF RIAS. Grzegorz Nowak Bachelor’s Thesis April 2011 Degree Program in Information Technology School of Technology DESCRIPTION Author(s) Type of publication Date NOWAK, Grzegorz Bachelor´s Thesis 13.05.2011 Pages Language 54 English Confidential Permission for web publication ( ) Until (X) Title GOOGLE WEB TOOLKIT AS MODERN AJAX FRAMEWORK FOR DEVELOPMENT OF RIAS. Degree Program Information Technology (Data Network Technology) Tutor(s) Peltomäki, Juha Assigned by Bitcomp Oy Abstract Google Web Toolkit is an Ajax based framework for development of interactive web pages – Rich Internet Applications. With additional libraries that add support for handling geographical data it allowed creating a user-friendly experience comparable to most popular web applications in the net. The main objective was to develop an application which allows publishing of spatial data over the web using modern technologies. The most important part was the map widget which should support full user interaction with presented data. The project’s implementation was split into several phases. Analysis of requirements and architecture gave detailed knowledge about the project itself and the tools needed. Prepared development environment and project’s structure was a signal that the implementation of actual features might get started. Displaying data on the map was the subsequent step after implementing the application’s business logic. The result of the process was a fully functional application, entirely compliant with placed requirements. Additionally, the documentation of the project was created to allow faster adaptation of the application to future needs. Developed solution offers great functionality in its category. The products offered by competitive companies were comparable or worse than the presented application. Keywords Google Web Toolkit, Ajax, RIA, Smart Client, GIS, GeoServer, GeoTools, OpenLayers, Maven Miscellaneous 1 CONTENTS 1 INTRODUCTION ........................................................................................................................ 6 2 THEORETICAL BASIS ................................................................................................................. 7 2.1 Ajax ..................................................................................................................................... 7 2.1.1 General Information .................................................................................................. 7 2.1.2 Evaluation .................................................................................................................. 7 2.2 Google Web Toolkit .......................................................................................................... 8 2.2.1 Compatibility with Java and libraries ....................................................................... 9 2.2.2 JavaScript Native Interfaces ................................................................................... 10 2.2.3 Modularity ............................................................................................................... 10 2.2.4 Deferred binding ..................................................................................................... 11 2.2.5 Threads and timers ................................................................................................. 11 2.2.6 GWT-RPC .................................................................................................................. 11 2.2.7 Logging ..................................................................................................................... 13 2.2.8 Localization .............................................................................................................. 13 2.2.9 History support ........................................................................................................ 14 2.2.10 Patterns .................................................................................................................... 14 2.2.11 Testing ...................................................................................................................... 16 2.2.12 Launching and compilation details ........................................................................ 17 2.2.13 Smart GWT ............................................................................................................... 18 2.2.14 Evaluation ................................................................................................................ 19 2.3 Geographic Information System .................................................................................... 19 2.3.1 Open Geospatial Consortium ................................................................................. 19 2.3.2 Web Feature Service ............................................................................................... 19 2 2.3.3 Web Map Service .................................................................................................... 20 2.3.4 GeoServer ................................................................................................................ 20 2.3.5 GeoTools .................................................................................................................. 20 2.3.6 GWT OpenLayers ..................................................................................................... 21 2.4 Development environment ............................................................................................ 21 2.4.1 Integrated development environment .................................................................. 21 2.4.2 Source configuration management ....................................................................... 22 2.4.3 Source quality management................................................................................... 23 2.4.4 Continuous integration ........................................................................................... 24 2.4.5 Component repository management .................................................................... 24 2.5 Maven .............................................................................................................................. 24 2.5.1 Project Object Model .............................................................................................. 25 2.5.2 Build lifecycle ........................................................................................................... 27 2.5.3 Profiles ..................................................................................................................... 28 2.5.4 Archetype ................................................................................................................. 28 2.5.5 Other plug-ins .......................................................................................................... 28 3 PRACTICAL IMPLEMENTATION ............................................................................................. 30 3.1 Bitcomp Oy ...................................................................................................................... 30 3.2 Analysis of the requirements ......................................................................................... 30 3.3 Analysis of the architecture ........................................................................................... 32 3.4 Workspace setup ............................................................................................................ 34 3.5 Project structure ............................................................................................................. 35 3.6 Application layout ........................................................................................................... 40 3.7 Address search ................................................................................................................ 42 3.8 Search .............................................................................................................................. 44 3 3.9 Map .................................................................................................................................. 45 3.10 Documentation ................................................................................................................ 50 4 RESULTS .................................................................................................................................. 51 5 DISCUSSION ............................................................................................................................ 52 REFERENCES .................................................................................................................................... 53 FIGURES FIGURE 1 GWT-RPC class diagram (GWT Dev Guide, 2011.) ....................................................... 12 FIGURE 2 Model View Controller diagram ................................................................................... 15 FIGURE 3 Model View Presenter diagram .................................................................................... 16 FIGURE 4 Maven POM structure (O’Brien T, Casey J & Fox B, 2010.) ........................................ 25 FIGURE 5 Maven POM inheritance diagram (O’Brien T, Casey J & Fox B, 2010.) ...................... 26 FIGURE 6 Use case diagram ........................................................................................................... 32 FIGURE 7 Architecture diagram..................................................................................................... 33 FIGURE 8 Browser popularity diagram (StatCounter, 2011) ....................................................... 35 FIGURE 9 Skeleton of the application layout................................................................................ 40 FIGURE 10 Final look of the application. ...................................................................................... 51 TABLES TABLE 1 Maven default lifecycle for WAR and JAR packages ..................................................... 27 TABLE 2 Functional requirements ................................................................................................. 31 TABLE 3 Non functional requirements ......................................................................................... 31 4 TERMS AJAX – Asynchronous JavaScript and XML API – Application Programming Interface CI – Continuous Integration CRS – Coordinate Reference System CRUD – Create Read Update Delete CSS – Cascading Style Sheets DTO – Data Transfer Object ERM – Electronic Resource Management GET – type of HTTP request GIS – Geographic Information System GML – Geography Markup Language GWT – Google Web Toolkit HTML – Hypertext Markup Language HTTP – Hypertext Transfer Protocol IDE – Integrated Development Environment JAXB – Java Architecture for XML Binding JNI – Java Native Interfaces JSNI – JavaScript Native Interfaces JSON – JavaScript Object Notation JVM – Java Virtual Machine 5 MVC – Model View Controller MVP – Model View Presenter OSM – Open Street Map PHP – PHP: Hypertext Preprocessor POM – Project Object Model RIA – Rich Internet Application RMI – Remote Method Invocation RPC – Remote Procedure Call SCM – Source Code Management SDK – Software Development Kit TDD – Test Driven Development URL – Uniform Resource Locator WFS – Web Feature Service WMS – Web Map Service XLS – XML for Location Services. XML – Extensible Markup Language 6 1 INTRODUCTION Rich Internet Application as the name suggests is a type of interactive and dynamic web page the functionality of which is usually comparable with features provided by standalone desktop applications. There are different technologies allowing development of such including Flash, Java, Silver Light and Ajax based frameworks. Ajax is the only methodology from those mentioned above, which does not require any additional plug-ins in most of modern browsers. Unfortunately developing applications for different browsers using Ajax is a laborious process. The main reasons for such situation are the differences in the implementations of technologies used in Ajax across browsers. To allow development without worrying about those differences, JavaScript frameworks were created: Prototype, jQuery, Dojo, Google Web Toolkit and many more. The main objective of this thesis is to report development of RIA for publishing of spatial data over the web. The application allows visitors to view published data on the map, and also search it using provided tools. The overall usability should be as high as possible to support visitors with different levels of technical knowledge The project is implemented using Google Web Toolkit and managed by Maven. The user interface is based on Smart GWT widget library, except the map component which is part of OpenLayers library. Spatial data is provided using WFS hosted by GeoServer. During the development process several tools were used to improve the quality of final result. This thesis was created during the internship in Bitcomp Oy. The company creates a suite of tools to manage resources electronically. The whole process of forest management has been completely covered including mobile access. When one of the clients reported a need for an application which allows publishing of already stored data, the company decided to develop such solution using the technologies mentioned above. The thesis was developed during a double degree program, and because of that, it was evaluated in two independent universities: JAMK University of Applied Sciences and Cracow University of Technology. 7 2 THEORETICAL BASIS 2.1 Ajax 2.1.1 General Information Ajax is a set of technologies used to create dynamic web pages. It consists of following: Asynchronous calls using XMLHttpRequest object XML for data transfer HTML and CSS for displaying the data DOM for modifying the structure of the document JavaScript that ties together all above technologies. (Moore D, Budd R & Benson E, 2007, 35-36) The XMLHttpRequest is a special object that allows downloading content in the background without forcing the user to wait or reload the page. XML is not the only possible carrier of information. It is possible to use others, for example plain text or JSON which in JavaScript environment is very handy. The JavaScript is not the only option but it is also widely integrated into many popular web browsers in contrast to Flash or Java. 2.1.2 Evaluation There are many advantages and drawbacks of using Ajax. The advantages with Ajax are listed below: Only changing content is transferred so the data transfer and time needed is lower than during full page reload User has the impression of an interactive web page – an application in which functionalities are sometimes same or even richer than standalone applications Most of the technologies used in Ajax are open source and easily accessible for developers. 8 The disadvantages are listed as follows: The browser history is unable to store a dynamically created webpage Bookmarking of such application is also limited to the state in which it starts In case of slow and unreliable internet connection the responsiveness of the application might be really low in comparison to a regular web page which will load longer but its runtime will not be interrupted To allow web crawlers to index the content there should be a way to access it without using Ajax Some web browsers might not support JavaScript or it may be turned off. Even in such case the user should be able to view the content Too many server requests with XMLHttpRequest may put the servers under bigger stress. As it is clearly visible above, the advantages of Ajax are totally obscured by disadvantages. One of the reasons why so many frameworks based on Ajax were created was to overcome these drawbacks easily and to make the development faster. 2.2 Google Web Toolkit GWT is a powerful Ajax framework that gives the ability to develop RIAs without worrying about the drawbacks of Ajax. The application is developed in Java language, but it is also possible to add fragments of code in JavaScript. The source might be launched in two ways: Development mode – Java classes are being compiled to byte code and then run on custom JVM which redirects the output into the browser (GWT Developer Plug-in is required) Production mode – GWT Compiler translates the Java source into highly optimized (adjustable) and obfuscated (optional) JavaScript, tailored for different browsers and languages. The development mode is a very important part since it enables the developers to use standard Java tools to debug the code.
Description: