December 16, 2010

Published December 16, 2010 by

Google Web Toolkit 2 Application Development Cookbook


Over 70 simple but incredibly effective practical recipes to develop web applications using GWT with JPA , MySQL and iReport


Overview of Google Web Toolkit 2 Application Development Cookbook

  • Create impressive, complex browser-based web applications with GWT 2
  • Learn the most effective ways to create reports with parameters, variables, and subreports using iReport
  • Create Swing-like web-based GUIs using the Ext GWT class library
  • Develop applications using browser quirks, Javascript,HTML scriplets from scratch
  • Part of Packt's Cookbook series: Each recipe is a carefully organized sequence of instructions to complete the task as efficiently as possible

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.

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

What you will learn from this book :

  • Set up and configure GWT SDK, GlassFish server, MySQL server, NetBeans, GWT4NB, Ext GWT , iReport plugins for developing the business application in GWT
  • Design a database for sales processing system in MySQL, back up and restore the database
  • Identify business entities and the relationships and constraints among them
  • Handle events such clicking on buttons, typing in text fields, selecting items in a combo box, selecting radios, selecting menus, and selecting toolbar icons
  • Manage entities using entity framework through Java Persistence API (JPA)
  • Use iReport for any GWT application to get the output of the reports in both HTML and PDF format
  • Create Graphical User Interface (GUI) for accepting user input and display information to the user using Ext GWT
  • Control communication between the server and client using GWTRPC mechanism
  • Create a WAR file for GWT application and deploy it in Glassfish server

Approach
The recipes in this book are in a straightforward and easy to follow format.The range of topics covered in this book will bring out the forward-thinking Java developer in you.

Who this book is written 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.

Read More

September 22, 2010

Published September 22, 2010 by

Creating GWT Project in Eclipse

Getting Ready:

Before following this quick tutorial ensure that you have done the followings:
1.       Install the JDK. You can download it from http://www.oracle.com/technetwork/java/javase/downloads/index.html
2.       Install the Eclipse IDE. It can be downloaded from http://www.eclipse.org/downloads/
3.       Install the GWT SDK which is available for download at http://code.google.com/webtoolkit/download.html
4.       Install the Google Plugin for Eclipse as instructed at http://code.google.com/eclipse/docs/download.html


How to do it:

Now follow the steps below to create the GWT Project
1.       Start Eclipse IDE
2.       Go to File | New | Other…
3.       Select Web Application Project under Google


4.       Press Next
5.       Give Project Name HelloGWT; give a Package Name (in this example it is com.blogspot.gwtguide.eclipse.hello); select Use Google Web Toolkit



6.       If the GWT SDK is not configured, click on Configure SDKs… ; add the web toolkit and press OK to close the dialog


7.       Press Finish and the project is created.




Run the project and see output



Read More

May 14, 2010

Published May 14, 2010 by

Setting up Ext GWT in NetBeans GWT Project

Introduction: Ext GWT is a Java UI component library for building rich Internet applications with Google Web Toolkit.

Features of Ext GWT include:
  • High performance, customizable UI widgets
  • Full theming support with standard CSS
  • Well designed, consistent and fully documented source code
  • Native GWT solution with no external JavaScript or 3rd party libraries
  • Full remote procedure support using GWT RPC, JSON, and XML
  • Support for Java 1.5 features, including generics, enums, and varargs
  • Commercial and Open Source licenses available

Download: Ext GWT SDK is available to download at http://www.extjs.com/products/gwt/download.php

In this article we will learn how to setup the Ext GWT in NetBeans GWT project. If you have not created the GWT project in NetBeans yet, follow the post Creating GWT Project in NetBeans.

Follow the steps below:

1. Extract the downloaded EXT GWT SDK, for example gxt-2.1.1-gwt2.zip
2. Open the GWT-Guide project in NetBeans.
3. Create a folder named lib in the GWT-Guide project. To do this, go to File | New File... | Other in Categories | Folder in File Types; press Next; give a name lib and press Finish.



4. Copy the gxt.jar file from gxt-2.1.1 folder and paste it in the lib folder created in the previous step. To do so go to Files tab | select the lib folder | right click on it | Paste.


5. Add the gxt.jar file in the project library. To do so go to Projects tab | select Libraries | right click on it | Add Jar/Folder... | select the gxt.jar file in the lib folder and Open.





6. In the same way copy the resources folder from gxt-2.1.1 folder and paste it in web folder in the project.

Now the project directory structure is as below:


7. Modify the GWT module. Include the text <inherits name="com.extjs.gxt.ui.GXT"/> under the <module/> in Main.gwt.xml file.

Complete code for the GWT module is as below:


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 1.7.0//EN" "http://google-  web-toolkit.googlecode.com/svn/tags/1.7.0/distro-source/core/src/gwt-module.dtd">

<module>
      <inherits name="com.google.gwt.user.User"/>

      <inherits name="com.extjs.gxt.ui.GXT"/>
      <entry-point class="com.blogspot.gwtguide.client.MainEntryPoint"/>
      <!-- modify the entry point class package and name according to your entry point class -->

</module>

8. Modify the welcomeGWT.html file. Add <link rel="stylesheet" type="text/css" href="resources/css/gxt-all.css" /> under the <head> section.

The complete HTML code is :

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>
        <meta name='gwt:module' content='com.packtpub.gwt=com.packtpub.gwt'>
        <title>gwt
        <link rel="stylesheet" type="text/css" href="resources/css/gxt-all.css" />
    </head>
    <body>
        <script type="text/javascript"  src="com.packtpub.gwt/com.packtpub.gwt.nocache.js">
    </body>
</html>
Read More

April 30, 2010

Published April 30, 2010 by

Creating GWT Project in NetBeans

If the GWT4NB plugin is already installed just directly follow the steps below, otherwise read GWT4NB : Plugin for Creating GWT Applications in NetBeans first.

1. Go to File | New Project...
2. Select Java Web from Categories and Web Application from Projects; press Next.


3.Give a Project Name, Browse the Project Location; press Next.


4. Select the Server, Java EE Version and write the Context Path; press Next.




5. Select Google Web Toolkit from Frameworks, Browse GWT Installation Folder, write name for GWT Module; press Finish.


GWT Project is now created.


Read More
Published April 30, 2010 by

GWT4NB : Plugin for Creating GWT Applications in NetBeans

GWT4NB is a support plugin for NetBeans. The GWT4NB project aims to enable developers to take advantage of both: the superior support for creating Web Applications built into the NetBeans IDE and the power of GWT (Google Web Toolkit).

Functionalities provided by GWT4NB includes:

- Using GWT with new or existing web project
- Deployment, running and debugging GWT applications
- Assistance in code editing like creating RPC services.

Go to https://gwt4nb.dev.java.net/ to learn more about this Java tool. This article guides you to setup the plugin in NetBeans.

Download GWT4NB:

For downloading the plugin go to https://gwt4nb.dev.java.net/servlets/ProjectDocumentList?folderID=7081&expandFolder=7081&folderID=0 and download the latest stable version.

Install GWT4NB in NetBeans:

1. Go to Tools | Plugins | Downloaded
2. Click Add Plugins...
3. Open the plugin file which you downloaded earlier. Plugin file name is org-netbeans-modules-gwt4nb.nbm.

4. Then click install.| Next
5. Accept the terms in license agreement and press Install
6. If the Validation Warning is shown press Continue.
7. Press Finish | Close.

After installing the plugin you will get Google Web Toolkit Framework option will be added in the framework list. Now you can start building GWT application in NetBeans easily.
Read More

April 14, 2010

Published April 14, 2010 by

Create JPA Entity Classes from Database

This is a straight forward tutorial for creating Java Persistence API (JPA) Entity Classes in NetBeans IDE based on an existing relational database.

Entity classes are used to represent objects whose lifespan is longer than a typical program execution. This feature in NetBeans creates an entity class for each selected table, complete with named query annotations, fields representing columns, and relationships representing foreign keys.

1. Go to File | New File...
2. Select your Project (Inventory Management System in this example). Select Persistence form Categories and Entity Classes from Database from File Types.


3. Press Next.
4. Select the Database Connection. If you want to know how to create the connection, read the post Create Database Connection in NetBeans.
5. After selecting the connection, available database tables will be listed from which you just add the tables by pressing Add or Add All.


6. Press Next.
7. Class Names are listed. You can change the names if you want.Give a package name (ims.beans in this example).


8. Press the button Create Persistence Unit. Give a Persistence Unit Name or leave it for the default name. In this example the name is Inventory_Management_SystemPU. To know about the persistence unit and associated concepts read Managing Entities - the Java EE 5 Tutorial.
9. Select EclipseLink from the Persistence Library. Other library options are Hibernate, TopLink etc.
10. Select None from the Table Generation Strategy.


11. Press Create.
12. Press Next to Specify Mapping Options. Set default as the Association Fetch and java.util.List as the Collection Type. Alternative collection types are java.util.Collection and java.util.Set.



13. Press Finish and see all the entity classes are generated in the selected package.
Read More
Published April 14, 2010 by

Create Database Connection in NetBeans

This is a very straight forward and step by step tutorial for creating a new MySQL database connection in NetBeans IDE.

1. Go to the Services window, click right mouse button and press New Connection. If the Services window is not available in the NetBeans window, go to Window menu and select Services.



2. Provide the following information in the new dialog appeared.
    Driver Name: MySQL (Connector/J Driver)
    Host: localhost (if the host is on the local computer otherwise the URL of the host)
    Port: 3306 (it is the default port for the MySQL server, if it is changed in your computer use that one)
    Database: name of the database (inventory in this example)
    User Name: name of the user (root in this example)
    Password: password of the MySQL server



3. Press OK. Database connection is now created.



Now you can use this connection for further tasks.
Read More

March 20, 2010

Published March 20, 2010 by

iReport 3.7 Book


Introduction to iReport


iReport is a program that helps users and developers that use the JasperReports library to visually design reports.

Through a rich and very simple to use GUI, iReport provides all the most important functions to create nice reports in little time. iReport can help people that don't know the JasperReports library create complex reports and learn the XML syntax, taking a look to the generated code. iReport can help skilled report designers compose very complex pages, saving a lot of time. iReport is written in Java.

iReport is a visual designer for JasperReports. But What's JasperReports? JasperReports is the best open source reporting engine available for java community. It is developed by a small big genius called Teodor Danciu. JasperReports has always had one lack: it doesn't provide an adapted tool to visually design reports. JasperReports has hundred of features; possibilities of use are infinitely... a person that does not have much confidence with the XML could have some problems to take fully advantage from the JasperReports library.

iReport 3.7 Book

-Learn how to use iReport to create, design, format, and export reports

-A step-by-step, example-oriented tutorial with lots of screenshots to guide the reader seamlessly through the book
-Generate enterprise-level reports using iReport 3.7
-Give your reports a professional look with built in templates
-Create master/detail reports easily with the sub-report feature
-Produce summary data and present them in a dynamic crosstab report
In More Detail



What you will learn from this book
  • Using iReport for creating reports
  • Using special kinds of data operations to generate more powerful reports
  • Combining data to produce master/detail reports
  • Adding images and controlling the layout and formatting of your report
  • Using report variables to store data during the execution of the report
  • Representing business data in the form of pie charts, bar charts, line charts and so on
  • Calling iReport from a Java desktop or web application
  • Creating reports from the NetBeans IDE
  • Creating JDBC connections from iReport to connect to different data sources.
Download the sample chapter here.

View the book details at PACKT Publishing Book Store


References:

1. iReport Documentation, http://www.jasperforge.org/sf/wiki/do/viewPage/projects.ireport/wiki/IReportManualV1.2.1, Accessed on 15 July 2008

2. Getting Started, http://www.jasperforge.org/jaspersoft/opensource/business_intelligence/ireport/page.php?id=5 , Accessed on 15 July 2008

3. iReport 3.7, http://www.packtpub.com/ireport-3-7/book, Accessed on 19 March 2010.

Read More