Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
DWR Java AJAX Applications

You're reading from   DWR Java AJAX Applications A step-by-step example-packed guide to learning professional application development with Direct Web Remoting

Arrow left icon
Product type Paperback
Published in Oct 2008
Publisher
ISBN-13 9781847192936
Length 232 pages
Edition Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Sami Salkosuo Sami Salkosuo
Author Profile Icon Sami Salkosuo
Sami Salkosuo
Arrow right icon
View More author details
Toc

Preface

AJAX enables a rich desktop-like user interface in the browser and enables interactive interfaces that can even replace traditional user interfaces. Communication between browser and server is done in the background and because only the data is transferred between the browser and the server, AJAX applications seem to be, and are actually, fast and responsive to the users.

DWR, Direct Web Remoting, is an Open Source Java framework, licensed under the commercial-friendly Apache Software License v2 for building AJAX applications. DWR's main idea is to hide AJAX implementation details, like XMLHttpRequest and such, from developers. Developers can concentrate on developing the application and business objects and leave the AJAX details behind the scenes where they belong.

DWR allows server-side Java classes to be used in the browser (it's like an RPC between JavaScript functions and the server-side Java) and also allows JavaScript functions to be used in the server (Reverse AJAX). DWR dynamically generates JavaScript functions from Java classes via XML-based configuration, which can be called from browser via the DWR JavaScript library. A DWR servlet on the server side receives requests and calls the actual Java implementation. DWR includes a couple of JavaScript libraries that are required for DWR to work, and are also helpful for developers.

The term Reverse AJAX is used when a server is used to query and/or control the client browser behavior. DWR supports three different methods to do reverse AJAX in applications: Piggyback, Polling (by the client), and Comet (server push).

You may have an on-going project where you may want to use a framework such as JSF or Spring for building the whole solution. In these cases, AJAX and DWR are just a part of the overall picture, and so DWR needs to integrate with other frameworks nicely, and does that successfully!

The DWR project has thought about security very thoroughly. The DWR framework has taken into account many security issues and there is a lot of discussion about security at the DWR website.

This book is written for professional Java developers who are interested in learning DWR and AJAX framework. It starts with a tutorial on DWR's main features and functions. Then it covers setting up the development environment. It concludes with some sample applications.

The later chapters are full of example code for sample applications, to aid comprehension.

What This Book Covers

Chapter 1 is a brief introduction to AJAX technology and DWR. It also discusses the DWR community and describes briefly what information can be found about DWR on the Internet.

Chapter 2 describes DWR features that we use in the samples of this book—a high-level view of how DWR makes a developer's life easier. It discusses reverse AJAX, DWR JavaScript libraries, converters, creators, filters, and signatures. It also contains a section on integrating DWR with other projects and another on security.

Chapter 3 sets the stage for development by describing how to set up the development environment and how to test and debug our sample applications. It covers DWR-supported browsers and environments, configuration, error handling, packaging, and deployment.

Chapter 4 is the first chapter dedicated to sample code. The examples in this chapter include typical user interface elements such as tables and lists, and how they can be implemented using DWR. It also has an example for field completion.

Chapter 5 discusses how to use DWR in more advanced user interface elements such as forms, navigation tree, and scrolling a map.

Chapter 6 shows how DWR applications are integrated to a database, a web service, or a messaging system.

Chapter 7 includes two sample applications: Collaborative Book Authoring, which shows how DWR is used to create a web based multi-user authoring environment, and Chatroom—a typical multi-user chat room application using DWR.

What You Need for This Book

This book is for professional Java developers and architects who want to learn about DWR by examples. Several skills are needed or are beneficial to get the most out of this book.

First of all, Java development skills are needed. Especially web development using Java technologies like Java Enterprise Edition (JEE), Servlets, and JSPs. Experience about other web technologies like JavaScript, HTML, and CSS is also useful.

Eclipse tooling should be familiar and other useful skills are knowledge about JEE application servers and experience about common technologies like XML.

Knowledge about the basics of AJAX technology is helpful. However, the basics of AJAX are introduced in this book.

Who is This Book For

This book is written for competent Java developers and assumes that you are a professional rather than a hobbyist. You should be familiar with the concepts of programming, Web 2.0, and AJAX.

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 will be set as follows:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE dwr PUBLIC
"-//GetAhead Limited//DTD Direct Web Remoting 2.0//EN"
"http://getahead.org/dwr/dwr20.dtd">
<dwr>
<allow>
<create creator="new" javascript="HorizontalMenu">
<param name="class" value="samples.HorizontalMenu" />
</create>
</allow>
</dwr>

When we wish to draw your attention to a particular part of a code block, the relevant lines or items will be made bold:

public boolean submitOrder(String name, String address, String creditCardNumber, String expiryDate) {
CreditCardValidatorSoapProxy ccValidatorProxy = new CreditCardValidatorSoapProxy();
int rv = -1;
try {
rv = ccValidatorProxy.validCard(creditCardNumber, expiryDate.replace("/", ""));
if (rv != 0) {
System.out.println("Credit card check failed: " + rv);
}
} catch (RemoteException e) {
e.printStackTrace();
}
if(rv==0)

{
//credit card valid, submit to order system
new OrderSystem(name,address,creditCardNumber,expiryDate);
}
return rv == 0;
}

Any command-line input and output is written as follows:

deploy -user system -password manager deploy d:\temp\HelloWorldServlet.war

New terms and important words are introduced in a bold-type font. Words that you see on the screen, in menus or dialog boxes for example, appear in our text like this: "clicking the Next button moves you to the next screen".

Note

Warnings or important notes appear in a box like this.

Note

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 drop an email to , making sure to mention the book title in 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 email .

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.

Customer Support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the Example Code for the Book

Visit http://www.packtpub.com/files/code/2936_Code.zip to directly download the example code.

Note

The downloadable files contain instructions on how to use them.

Errata

Although we have taken every care to ensure the accuracy of our contents, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in text or code—we would be grateful if you would report this to us. By doing this you can save other readers from frustration, and help to improve subsequent versions of this book. If you find any errata, report them by visiting http://www.packtpub.com/support, selecting your book, clicking on the let us know link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata added to the list of existing errata. The existing errata can be viewed by selecting your title from http://www.packtpub.com/support.

Piracy

Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide the location address or website name immediately so we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.

Questions

You can contact us at if you are having a problem with some aspect of the book, and we will do our best to address it.

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image