Google Web Toolkit 2 Application Development Cookbook - Shamsuddin Ahammad - E-Book

Google Web Toolkit 2 Application Development Cookbook E-Book

Shamsuddin Ahammad

0,0
31,19 €

-100%
Sammeln Sie Punkte in unserem Gutscheinprogramm und kaufen Sie E-Books und Hörbücher mit bis zu 100% Rabatt.

Mehr erfahren.
Beschreibung

GWT 2 radically improves web experience for users by using existing Java tools to build no-compromise AJAX for any modern browser. It provides a solid platform so that other great libraries can be built on top of GWT. Creating web applications efficiently and making them impressive, however, is not as easy as it sounds. Writing web applications for multiple browsers can be quite tasking. In addition, building, reusing, and maintaining large JavaScript code bases and AJAX components can be difficult. GWT 2 Application Development Cookbook eases these burdens by allowing developers to quickly build and maintain complex yet highly efficient JavaScript front-end applications in the Java programming language . It tells you how to make web experience all the more thrilling and hassle free, using various tools along with GWT SDK.This book starts with developing an application from scratch. Right from creating the layout of the home page to home page elements including left and right sidebars, to placing tree like navigational menu, menu bars, tool bars, banners, footers are discussed with examples.

You will see how to create forms using the Ext GWT library widgets and handle different types of events. Then you will move on to see how to design a database for sales processing systems and learn to create the database in MySQL with the help of easy–to-follow recipes.

One of the interesting topics of this book is using JPA in GWT. Using the JPA object in GWT is a challenge. To use them perfectly, a mechanism to convert the JPA object into plain object and vice versa is required. You will see recipes to use entity classes, entity managers, and controller classes in GWT application. You will efficiently create reports with parameters, variables and subreports, and get the report output in both HTML and PDF format using real-world recipes.

You will then learn to configure the GlassFish server to deploy a GWT application with database. Finally, learn how to trace speed and improve perfomance in web applications using tracing techniques.

Das E-Book können Sie in Legimi-Apps oder einer beliebigen App lesen, die das folgende Format unterstützen:

EPUB

Seitenzahl: 159

Veröffentlichungsjahr: 2010

Bewertungen
0,0
0
0
0
0
0
Mehr Informationen
Mehr Informationen
Legimi prüft nicht, ob Rezensionen von Nutzern stammen, die den betreffenden Titel tatsächlich gekauft oder gelesen/gehört haben. Wir entfernen aber gefälschte Rezensionen.



Table of Contents

Google Web Toolkit 2 Application Development Cookbook
Credits
About the Author
About the Reviewers
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Errata
Piracy
Questions
1. Setting up the GWT Environment in NetBeans
Introduction
Installing JDK
Getting ready
How to do it...
Installing GWT SDK
Important features
Getting ready
How to do it...
Installing GlassFish
Getting ready
How to do it...
There's more...
See also
Installing MySQL server
Getting ready
How to do it...
Configuring the MySQL Server
Getting ready
How to do it...
Installing NetBeans IDE
Getting ready
How to do it...
Adding the GlassFish server in NetBeans
Getting ready
How to do it...
There's more...
Installing the GWT4NB plugin in NetBeans
Getting ready
How to do it...
Creating a GWT project in NetBeans
Getting ready
How to do it...
How it works...
Directory and file structure
Running the project
Adding Ext GWT
Getting ready
How to do it...
How it works...
See also
2. Creating Home Page with Panels and Menus
Introduction
Creating the home page layout class
Getting ready
How to do it...
How it works...
There's more...
Setting the size of the panel
Showing or hiding header in the content panel
BorderLayoutData
Classes and packages
See also
Adding the banner
Getting ready
How to do it...
How it works...
See also
Adding menus
How to do it...
How it works...
See also
Creating the left-hand sidebar
How to do it...
How it works...
See also
Creating the right-hand sidebar
How to do it...
How it works...
See also
Creating the main content panel
How to do it...
How it works...
See also
Creating the footer
How to do it...
How it works...
VerticalPanel
Setting alignment for VerticalPanel
See also
Using the HomePage instance in EntryPoint
Getting ready
How to do it...
How it works...
EntryPoint
RootPanel
Class and packages
See also
3. Forms with Layout and Widgets
Introduction
Using widgets
How to do it...
Using TextField
How to do it...
How it works...
There's more...
Using TextField for password
Creating a read-only TextField
Using a simple combo box
How to do it...
How it works...
Using the radio button
How to do it...
Using DateField
How to do it...
How it works...
Creating a simple form
How to do it...
How it works...
Creating a form with two columns
How to do it...
How it works...
Creating a TabPanel to show forms as tabs
Getting ready
How to do it...
How it works...
See also
Creating a navigation sidebar with Accordion layout
Getting ready
How to do it...
How it works...
See also
4. Handling your First Events
Introduction
Handling ButtonEvent
How to do it...
How it works...
There's more...
See also
Using the SelectionChange event
How to do it...
How it works...
See also
Handling FieldEvent
Getting ready
How to do it...
How it works...
See also
Working with the KeyUp event
Getting ready
How to do it...
How it works...
There's more...
See also
Handling ChangeEvent
Getting ready
How to do it...
How it works...
See also
Working with MenuEvent
Getting ready
How to do it...
How it works...
See also
Using FocusEvent
How to do it...
How it works...
See also
Handling the DatePicker event
Getting ready
How to do it...
How it works...
See also
5. Creating Database for Sales Processing
Introduction
Designing the database for sales processing
Creating the database
Getting ready
How to do it...
There's more...
Creating database using MySQL Command Line Client
See also
Creating tables with primary key
How to do it...
Creating tables from MySQL Command Line Client
See also
Defining foreign keys
Getting ready
How to do it...
There's more...
Creating all the other tables using MySQL Query Browser
Creating all the other tables in Command Client
Backing up database
How to do it...
How it works...
See also
Restoring database
Getting ready
How to do it...
How it works...
See also
6. Managing Entities using JPA
Introduction
JPA in GWT
Uses
Creating a database connection in NetBeans
Getting ready
How to do it...
Direct URL Entry
Creating a persistence unit
Getting ready
How to do it...
How it works...
EclipseLink
EclipseLink JPA
Data source
persistence.xml
sun-resources.xml
Creating entity classes from the database
Getting ready
How to do it...
How it works...
Named query
Entity classes
Sales.java
SalesDetails.java
SalesDetailsPK.java
Creating controller classes
Getting ready
How to do it...
How it works...
Entity manager
Entity manager factory
Controller class for sales entity
Importing packages
Defining a constructor
Creating the entity manager
Defining a method to persist object
Defining a method to edit object
Defining method to remove object
Defining methods for finding objects
7. Communicating with the Server using GWT RPC
Introduction
Creating DTO classes
Getting ready
How to do it...
Mapping entity classes and DTOs
Getting ready
How to do it...
There's more...
Creating the GWT RPC Service
Getting ready
How to do it...
How it works...
Defining an RPC method to persist objects
Getting ready
How to do it...
How it works...
Calling the RPC method from Client UI
How to do it...
How it works...
Finding an entity
How to do it...
How it works...
Updating an entity
How to do it...
How it works...
Deleting an entity
How to do it...
How it works...
Managing a list for RPC
How to do it...
How it works...
See also
Authenticating a user through username and password
Getting ready
How to do it...
How it works...
8. Reporting with iReport
Introduction
Important features
Installing iReport plugins in NetBeans
Getting ready
How to do it...
How it works...
Creating a report
How to do it...
How it works...
Adding a parameter in a report
Getting ready
How to do it...
How it works...
Adding a subreport
Getting ready
How to do it...
How it works...
Adding a variable
Getting ready
How to do it...
How it works...
Showing a report in the GWT application as HTML
Getting ready
How to do it...
How it works...
Creating HTML report viewer
How to do it...
How it works...
Calling HtmlReportViewer
Getting ready
How to do it...
How it works...
Showing a report in a GWT application as PDF
How to do it...
How it works...
Creating a PDF report viewer
How to do it...
How it works...
Calling PdfReportViewer
Getting ready
How to do it...
How it works...
9. Deploying a GWT Application
Introduction
Building a project and creating the WAR file
Getting ready
How to do it...
How it works...
Deploying on the GlassFish Server from NetBeans
Getting ready
How to do it...
How it works...
Creating the JDBC Connection Pool in GlassFish
Getting ready
How to do it...
How it works...
Creating a JDBC Resource in GlassFish Server
Getting ready
How to do it...
Deploying the WAR file in the GlassFish Server
Getting ready
How to do it...
How it works...
10. Using Speed Tracer
Introduction
Installing Speed Tracer
Getting ready
How to do it...
How it works...
See also
Running Speed Tracer
Getting ready
How to do it...
How it works...
There's more...
See also
Analyzing event details
Getting ready
How to do it...
See also
Analyzing network
Getting ready
How to do it...
How it works...
See also
Understanding hints
Getting ready
How to do it...
See also
Index

Google Web Toolkit 2 Application Development Cookbook

Google Web Toolkit 2 Application Development Cookbook

Copyright © 2010 Packt Publishing

All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.

Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.

Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.

First published: November 2010

Production Reference: 1191110

Published by Packt Publishing Ltd.

32 Lincoln Road

Olton

Birmingham, B27 6PA, UK.

ISBN 978-1-849512-00-8

www.packtpub.com

Cover Image by Vinayak Chittar ( <[email protected]> )

Credits

Author

Shamsuddin Ahammad

Reviewers

Ventsislav Chochev

Yiwen Ng (Tony)

Jagmohan Purohit

Acquisition Editor

Dilip Venkatesh

Development Editor

Neha Mallik

Technical Editor

Krutika Katelia

Copy Editor

Neha Shetty

Indexer

Tejal Daruwale

Editorial Team Leader

Akshara Aware

Project Team Leader

Ashwin Shetty

Project Coordinator

Michelle Quadros

Proofreader

Clyde Jenkins

Graphics

Nilesh Mohite

Production Coordinator

Kruthika Bangera

Cover Work

Kruthika Bangera

About the Author

Shamsuddin Ahammad is a Senior Lecturer and the Course Coordinator at Daffodil Institute of IT, Bangladesh. He has been teaching Java, Programming Methods, and Database Systems since 2002. He has experience in supervising hundreds of academic projects. Shamsuddin has a Masters degree in Management Information Systems (MIS) from Daffodil International University, Dhaka. He obtained the B.Sc. (Hons) degree in Computing and Information Systems (CIS) from NCC Education Ltd, U.K. and London Metropolitan University in a joint program from the Daffodil Institute of IT. Prior to that, he has completed the IDCS & IADCS of NCC Education Ltd. He is an Additional Reviewer of Conference on Quality Engineering in Software Technology (CONQUEST) organized by the International Software Quality Institute (iSQI) in Germany. He is the author of the book titled iReport 3.7, published by Packt Publishing in March, 2010.

Extraordinary moral support from my respected parents, Md. Saidur Rahaman and Suriya Begum, is my greatest inspiration to write this book. My loving wife, Jesmin Rashid, has played a great role in my progression.

My brother and sisters, relatives, friends, and colleagues at Daffodil Institute of IT have inspired me a lot to writing this book — a special thanks to all of them. I'm very thankful to my teacher, Md. Nasimul Kader Sohel, for his warm support.

It is my great fortune to have worked with a great team of publishing professionals at Packt Publishing. I extend my sincerest gratitude to Dilip Venkatesh, Neha Mallik, Krutika Katelia and Michelle Quadros for their great cooperation in writing this book.

About the Reviewers

Ventsislav Chochev is software developer from Bulgaria, Europe. His educational degree is Bachelor of Informatics in "Computer programming and design". He currently works in IDxS, Belgium as a web developer, mainly using Java EE, Seam/Spring framework for their sensor's data presentation. His background covers many activities, such as using GWT and Java for application development.

Yiwen Ng (Tony) is a Java software developer with over seven years of commercial application development and consulting experience. Fringe passions involve agile methodology, mobile development, web enterprise development, configuration management, and security. If cornered, he may actually admit to knowing the latest technologies in Java and pair programming.

He's easily amused by programming language design and collaborative applications. Yiwen also develops a few android mobile applications and RIA GWT-based web applications. Occasionally, he works as a consultant on a contract basis. Yiwen may be reached directly via email at <[email protected]>.

Currently, he is employed at Tullett Prebon in Singapore as a Senior Software Developer.

Jagmohan Purohit started his career in MindTree Ltd. in 2007 as a Programmer Analyst. Over the course of his career, he had the good fortune of working on diverse technologies and vertical industries. He has over three years of experience in GWT and Smart GWT. Currently, he is playing the role of a Senior Software Engineer at MindTree Ltd. His current area of interest includes GWT, Alfresco, and Weblogic Portal.

His family hails from Berhampur in Orissa. He completed his graduation in Engineering from NIST (National Institute of Science and Technology), Berhampur in 2007. His other hobbies include travelling and reading.

Reviewing GWT 2 Application Development Cookbook was a wonderful experience, which gave me an opportunity to know about Ext GWT integration and some best practices for GWT coding.

Preface

GWT 2 radically improves the web experience for users by using the existing Java tools to build a no-compromise AJAX for any modern browser. It provides a solid platform so that the other great libraries can be built on top of the GWT. Creating web applications efficiently and making them impressive, however, is not as easy as it sounds. Writing web applications for multiple browsers can be quite tasking. In addition, building, reusing, and maintaining large JavaScript code bases and AJAX components can be difficult.

GWT 2 Application Development Cookbook eases these burdens by allowing the developers to build and maintain complex, yet highly efficient JavaScript frontend applications in the Java programming language quickly. It tells you how to make the web experience all the more thrilling and hassle-free by using various tools along with the GWT SDK.

This book starts with developing an application from scratch. Right from creating the layout of the home page to home page elements including left and right sidebars, to placing a tree-like navigational menu, menu bars, tool bars, banners, and footers are discussed with examples.

You will see how to create forms using the Ext GWT library widgets and handle different types of events. Then, you will move on to see how to design a database for sales processing systems, and learn how to create the database in MySQL with the help of easy-to-follow recipes.

One of the interesting topics of this book is using the JPA in GWT. Using the JPA object in GWT is a challenge. To use it perfectly, a mechanism to convert the JPA object into a plain object and vice versa is required. You will see recipes to use entity classes, entity managers, and controller classes in the GWT application. You will efficiently create reports with parameters, variables, and subreports, and get the report output in both HTML and PDF formats using real-world recipes.

You will then learn how to configure the GlassFish server to deploy a GWT application with a database. Finally, you will learn how to trace speed and improve performance in web applications using tracing techniques.

Create impressive web applications with tool bars, menus, multiple windows, and more with this step-by-step guide.

What this book covers

Chapter 1, Setting up the GWT Environment in NetBeans shows which tools and technologies are required to build a web application using GWT, JPA, and iReport in NetBeans. The required installation and configuration of the tools are shown as easy-to-follow recipes.

Chapter 2, Creating Home Page with Panels and Menus creates the layout of the application. It shows how to divide the page into the banner, left and right sidebars, and the center and footer sections.

Chapter 3, Forms with Layout and Widgets includes recipes that show how to use widgets to create forms, sidebars for navigation, tab panel, and so on.

Chapter 4, Handling your First Events includes easy-to-follow recipes that show how to handle the typical GWT events such as button event, field event, menu event, focus event, change event, and so on.

Chapter 5, Creating Database for Sales Processing creates a sample database in MySQL for Sales Processing Systems. To create a database and its tables with the required constraints, easily the uses of MySQL GUI tools have been shown.

Chapter 6, Managing Entities using JPA deals with the Java Persistence API (JPA) framework. It is a framework that is used to manage relational data in Java EE and Java SE applications. JPA provides a Plain Old Java Object (POJO) persistence model for object relational mapping. This chapter shows how to create a database connection, persistence unit, entity classes, and controller classes for the database CRUD operations.

Chapter 7, Communicating with Server using GWT RPC deals with the communication between the client and the server. The recipes in this chapter describe how to use the JPA in the server side and Data Transfer Objects (DTO) in the client side. It discusses how the GWT RPC mechanism allows the server and the client to pass Java objects back and forth.

Chapter 8, Reporting with iReport shows how to use iReport for the reporting solutions in Java web applications. Parameterized reports, subreports, and reports with variables are shown in some recipes. Then, the chapter discusses and shows how to show the created reports as HTML or PDF in the GWT application.

Chapter 9, Deploying a GWT Application includes recipes that show how to build the GWT project for the deployment, and before the deployment, how to create JDBC connection pool and resources in the GlassFish server are given as recipes.

Chapter 10, Using Speed Tracer deals with the extension Speed Tracer. Speed Tracer is a Google Chrome browser extension which is used to identify and fix performance problems in web applications. Installation and use of Speed Tracer for the created GWT applications are shown in this chapter.

What you need for this book

The software list required for this book is as follows:

Software

Download URL

JDK 6

http://www.oracle.com/technetwork/java/javase/downloads/index.html

GWT 2 SDK

http://code.google.com/webtoolkit/download.html

GlassFish 3.0.1

https://glassfish.dev.java.net/downloads/3.0.1-final.html

MySQL Community Server 5.1

http://www.mysql.com/downloads/mysql/

NetBeans

http://netbeans.org/downloads/index.html

GWT4NB

https://gwt4nb.dev.java.net/servlets/ProjectDocumentList

Ext GWT 2.2 SDK

http://www.sencha.com/products/gwt/thank-you.php?dl=extgwt220gwt2

iReport Plugin for NetBeans

http://jasperforge.org//website/ireportwebsite/IR%20Website/ir_download.html?header=project&target=ireport

Google Chrome

http://www.google.com/chrome

MySQL GUI tools

http://dev.mysql.com/downloads/gui-tools/5.0.html

Who this book is for

If you want to build AJAX web applications with GWT, then this book is for you. Developers with prior programming experience of Java development and object-oriented programming will find this book very useful.

Conventions

In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

Code words in text are shown as follows: "We can include other contexts through the use of the include directive."

A block of code is set as follows:

menuBar.add(menuBarItemFile); menuBar.add(menuBarItemReports); menuBar.add(menuBarItemHelp);

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "Right-click on the Servers option, and then click on Add Server."

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book — what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply send an e-mail to <[email protected]>, and mention the book title via the subject of your message.

If there is a book that you need and would like to see us publish, please send us a note in the SUGGEST A TITLE form on www.packtpub.com or e-mail <[email protected]>.