DWR Java AJAX Applications
()
About this ebook
Sami Salkosuo
Sami Salkosuo is an indie author and IBM Client Technical Professional. He is the author of several science fiction stories, including The Kaitian War and Truths,Half-Truths and Lies, and the author of DWR Java Ajax Applications and many articles at IBM developerWorks. He's also written poetry. Besides writing, he enjoys programming.
Read more from Sami Salkosuo
The Kaitian War Rating: 0 out of 5 stars0 ratingsSleeping, a Dreamer Rating: 0 out of 5 stars0 ratingsTruths, Half-Truths and Lies Rating: 0 out of 5 stars0 ratingsThe Vampire Rating: 0 out of 5 stars0 ratingsBrief are the Stories II Rating: 0 out of 5 stars0 ratings2016: 2013 Rating: 0 out of 5 stars0 ratingsBrief are the Stories Rating: 0 out of 5 stars0 ratingsStories from the Strangers' Universe Rating: 0 out of 5 stars0 ratingsThe Angel Rating: 0 out of 5 stars0 ratings
Related to DWR Java AJAX Applications
Related ebooks
Java Web Development: Java Unleashed: Crafting Enterprise-Level Solutions Rating: 0 out of 5 stars0 ratingsEasy Web Development with WaveMaker Rating: 0 out of 5 stars0 ratingsMockito Essentials Rating: 3 out of 5 stars3/5Advanced Java Rating: 0 out of 5 stars0 ratingsGlassFish Administration Rating: 0 out of 5 stars0 ratingsBuilding Web Services with Microsoft Azure Rating: 0 out of 5 stars0 ratingsRESTful Java Web Services, Second Edition: Design scalable and robust RESTful web services with JAX-RS and Jersey extension APIs Rating: 0 out of 5 stars0 ratingsJava for Web Development: Create Full-Stack Java Applications with Servlets, JSP Pages, MVC Pattern and Database Connectivity Rating: 0 out of 5 stars0 ratingsJasmine JavaScript Testing - Second Edition Rating: 0 out of 5 stars0 ratingsRESTful Java Web Services Security Rating: 0 out of 5 stars0 ratingsModern Web Development with Go: Build real-world, fast, efficient, and scalable web server apps using Go programming language Rating: 0 out of 5 stars0 ratingsCybersecurity Blue Team Toolkit Rating: 2 out of 5 stars2/5LPI Web Development Essentials Study Guide: Exam 030-100 Rating: 0 out of 5 stars0 ratingsNode Web Development, Second Edition Rating: 0 out of 5 stars0 ratingsJakarta EE for Java Developers: Build Cloud-Native and Enterprise Applications Using a High-Performance Enterprise Java Platform Rating: 0 out of 5 stars0 ratingsHTML5, JavaScript, and jQuery 24-Hour Trainer Rating: 2 out of 5 stars2/5Spring MVC Blueprints Rating: 0 out of 5 stars0 ratingsInstant Yii 1.1 Application Development Starter Rating: 5 out of 5 stars5/5JavaScript Made Easy: A Practical Guide with Examples Rating: 0 out of 5 stars0 ratingsMastering Java: Building Robust Applications: A Comprehensive Guide to Java Programming Rating: 0 out of 5 stars0 ratingsCode with Java 21: A practical approach for building robust and efficient applications (English Edition) Rating: 0 out of 5 stars0 ratingsAJAX and PHP: Building Responsive Web Applications Rating: 4 out of 5 stars4/5Google BigQuery Analytics Rating: 3 out of 5 stars3/5Modern JavaScript Applications Rating: 0 out of 5 stars0 ratingsJavaScript for Beginners Rating: 5 out of 5 stars5/5Learning Ext JS - Fourth Edition Rating: 0 out of 5 stars0 ratingsThe Future of JavaScript: Coding Interactive Websites: A Beginner's Guide to JavaScript Rating: 0 out of 5 stars0 ratingsIBM WebSphere Application Server v7.0 Security Rating: 0 out of 5 stars0 ratings
Information Technology For You
An Ultimate Guide to Kali Linux for Beginners Rating: 3 out of 5 stars3/5CompTia Security 701: Fundamentals of Security Rating: 0 out of 5 stars0 ratingsDevOps Handbook: What is DevOps, Why You Need it and How to Transform Your Business with DevOps Practices Rating: 4 out of 5 stars4/5Creating Online Courses with ChatGPT | A Step-by-Step Guide with Prompt Templates Rating: 4 out of 5 stars4/5CompTIA ITF+ CertMike: Prepare. Practice. Pass the Test! Get Certified!: Exam FC0-U61 Rating: 5 out of 5 stars5/5CompTIA A+ CertMike: Prepare. Practice. Pass the Test! Get Certified!: Core 1 Exam 220-1101 Rating: 0 out of 5 stars0 ratingsData Analytics for Beginners: Introduction to Data Analytics Rating: 4 out of 5 stars4/5AWS Certified Cloud Practitioner: Study Guide with Practice Questions and Labs Rating: 5 out of 5 stars5/5CompTIA Network+ CertMike: Prepare. Practice. Pass the Test! Get Certified!: Exam N10-008 Rating: 0 out of 5 stars0 ratingsLinux Command Line and Shell Scripting Bible Rating: 3 out of 5 stars3/5Health Informatics: Practical Guide Rating: 0 out of 5 stars0 ratingsChatGPT: The Future of Intelligent Conversation Rating: 4 out of 5 stars4/5Unlocking the Power of Agentic AI: Transforming Work and Life Rating: 5 out of 5 stars5/5Practical Ethical Hacking from Scratch Rating: 5 out of 5 stars5/5How Computers Really Work: A Hands-On Guide to the Inner Workings of the Machine Rating: 0 out of 5 stars0 ratingsCOMPUTER SCIENCE FOR ROOKIES Rating: 0 out of 5 stars0 ratingsPersonal Knowledge Graphs: Connected thinking to boost productivity, creativity and discovery Rating: 5 out of 5 stars5/5Blockchain Revolution: How the Technology Behind Bitcoin Is Changing Money, Business, and the World Rating: 3 out of 5 stars3/5Agile Business Architecture for Digital Transformation - V2 Rating: 5 out of 5 stars5/5Introduction to Information Systems: Information Technology Essentials, #1 Rating: 0 out of 5 stars0 ratingsCyber Security Consultants Playbook Rating: 0 out of 5 stars0 ratingsWindows 11 For Beginners: The Ultimate Step-By-Step Guide To Learning How To Use Windows Like A Pro Rating: 0 out of 5 stars0 ratingsAWS Certified Cloud Practitioner - Practice Paper 1: AWS Certified Cloud Practitioner, #1 Rating: 5 out of 5 stars5/5How to Write Effective Emails at Work Rating: 4 out of 5 stars4/5Hacking Essentials - The Beginner's Guide To Ethical Hacking And Penetration Testing Rating: 3 out of 5 stars3/5CompTIA Security+: Network Attacks Rating: 5 out of 5 stars5/5
Reviews for DWR Java AJAX Applications
0 ratings0 reviews
Book preview
DWR Java AJAX Applications - Sami Salkosuo
Table of Contents
DWR Java AJAX Applications
Credits
About the Author
About the Reviewers
Preface
What This Book Covers
What You Need for This Book
Who is This Book For
Conventions
Reader Feedback
Customer Support
Downloading the Example Code for the Book
Errata
Piracy
Questions
1. Introduction
What is AJAX?
DWR: AJAX for Java Developers
The DWR Community
Summary
2. DWR Features
Ease of Use
Reverse AJAX
Piggyback
Polling
Comet
DWR JavaScript Libraries
engine.js
util.js
gi.js
Converters
Creators, Filters, and Signatures
Integration with Other Projects
Security
Minimize Risks
Summary
3. Getting Started
Supported Browsers and Environments
Configuration
web.xml
dwr.xml
Using Creator and Its Attributes
Using the Converter Element
Working with Annotations
Using Fluent Configuration with DWR
Setting up a Development Environment
Development Environment with DWR and Firefox
Development Environment with Eclipse
Apache Geronimo
Testing and Debugging
Error Handling
Packaging and Deployment
Deployment Using the Administration Console
Deployment Using the Deployer Tool
Deployment Using Hot Deployment
Summary
4. User Interface: Basic Elements
Creating a Dynamic User Interface
Creating a New Web Project
Configuring the Web Application
Developing the Web Application
Testing the Web Application
Developing Web Pages
Callback Functions
Afterword
Implementing Tables and Lists
Server Code for Tables and Lists
Client Code for Tables and Lists
Testing Tables and Lists
Afterword
Implementing Field Completion
Server Code for Field Completion
Client Code for Field Completion
Afterword
Summary
5. User Interface: Advanced Elements
Creating Forms
Developing the User Interface
Creating the FormHandler Class
Testing the Form
Afterword
Building a Navigation Tree
Developing the User Interface
Creating the NavigationTree Class
Developing the User Interface, Part 2
Testing the Navigation Tree
Afterword
Map Scrolling Using DWR
Developing the User Interface
Creating the MapScroller Java Class
Testing the Map Scroller
Afterword
Summary
6. Backend Integration
Integrating a Database with DWR
Configuring the Database in Geronimo
Creating a CountryDerbyDB Java Class
Testing the Database Integration
Afterword
Integrating with Web Services
Developing the Web Service Client
Implementing the Web Service Call
Testing Web Services Integration
Afterword
Integrating with a Messaging System
Setting up Queues in Geronimo
Developing the OrderSystem Java Class
Setting up the Application for Messaging
Testing with the Backend OrderSystem
Afterword
Summary
7. Sample Applications
Collaborative Book Authoring
Starting the Project
Developing the User Interface
index.jsp
loginFailed.html
mainpage.jsp
Configuring the Web Application
Developing the Java Classes
Login.java
UserDatabase.java
Util.java
Book.java
BookDatabase.java
Testing Collaborative Book Authoring
Afterword
Chatroom
Starting the Project and Configuration
Developing the User Interface
Developing the Java Code
Testing the Chat
Afterword
Summary
Index
DWR Java AJAX Applications
Sami Salkosuo
DWR Java AJAX Applications
Copyright © 2008 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, Packt Publishing, nor its dealers or 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 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: October 2008
Production Reference: 1151008
Published by Packt Publishing Ltd.
32 Lincoln Road
Olton
Birmingham, B27 6PA, UK.
ISBN 978-1-847192-93-6
www.packtpub.com
Cover Image by Parag Kadam (<Paragvkadam@gmail.com>)
Credits
Author
Sami Salkosuo
Reviewers
Jason Crow
Matthew Henry
Sujit Pal
Acquisition Editor
Adil Ahmed
Development Editor
Usha Iyer
Technical Editor
Darshana D. Shinde
Copy Editor
Sumathi Sridhar
Editorial Team Leader
Mithil Kulkarni
Project Manager
Abhijeet Deobhakta
Project Coordinator
Rajashree Hamine
Indexer
Rekha Nair
Proofreader
Chris Smith
Production Coordinator
Rajni R. Thorat
Cover Work
Rajni R. Thorat
About the Author
Sami Salkosuo is a Software IT Architect at IBM Software Group, Finland. He has over ten years of experience in Java, Web, and integration technologies.
Sami has written several articles for IBM developerWorks, and is also the co-author of an IBM Redbook: Portalizing Domino Applications.
I am thankful to the reviewers Sujit Pal, Matthew Henry, and Jason Crow for their comments that helped me improve my writing. My thanks to Rajashree Hamine, Usha Iyer, Darshana Shinde, and others at Packt Publishing for making this book come true.
My sincere thanks also for my family for their patience and support.
About the Reviewers
Jason Crow is the lead Java Developer for Office Depot, Inc. in Delray Beach, Florida. He specializes in blending his expertise in Java, DWR, HTML, CSS, and jQuery to enhance usability and to bring dynamic features to officedepot.com. He actively contributes back to the community through his blog http://greatwebguy.com.
Matthew Henry is the Programming Services Manager at LeTourneau University. Matthew has worked in IT and computer related fields as a programmer for 30 years. Matthew co-authored Upgrading to Lotus Notes 7 and has written various articles for specific computer industry magazines.
Sujit Pal started programming some 20 years ago, and has never looked back since. He currently works at Healthline Networks, Inc., a search vertical focused on health, as part of its Research and Development team. Apart from his work, his favorite pastime is to explore new software technologies, techniques, and languages, and he writes about his experiments at sujitpal.blogspot.com.
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