Deitel® Developer Series AJAX, Rich Internet Applications, and Web Development forProgrammers by Paul J.. Then proceed to server-side development withweb servers, databases, PHP, Ruby on
Trang 1Deitel® Developer Series AJAX, Rich Internet Applications, and Web Development for
Programmers
by Paul J Deitel - Deitel & Associates, Inc.; Harvey
M Deitel - Deitel & Associates, Inc
Publisher: Prentice Hall Pub Date: January 29, 2008 Print ISBN-10: 0-13-158738-2 Print ISBN-13: 978-0-13-158738-0 eText ISBN-10: 0-13-714230-7 eText ISBN-13: 978-0-13-714230-9 Pages: 1040
Start with a concise introduction to XHTML, CSS, and JavaScriptbefore rapidly moving on to more advanced client-side
development with DOM, XML, AJAX, JSON, and other RIA
technologies Then proceed to server-side development withweb servers, databases, PHP, Ruby on Rails, ASP.NET,
JavaServer Faces, and web services When you're finished,
you'll have everything you need to build Web 2.0 applications
The DEITEL ® Developer Series is designed for practicing
Trang 2emerging technologies, including NET, Java™, web services,Internet and web development, and more
Trang 3programming." Anand Narayanaswamy, ASPAlliance.com
"Excellent for learning to develop standards-compliant web
applications takes you from the browser to the server and the database, covering web development across many
programming languages." Paul Vencill, MITRE, Inc.
"Cements the browser as a first-class development platform." Johnvey Hwang, Splunk, Inc
"Congratulations on this excellent work The [Dive Into Web 2.0] chapter is simply astonishing! It's one of the better if not the best references on Web 2.0." José Antonio González Seco,
Trang 4Compatibility Issues' is fantastic This book and your web sites will be often-visited resources (if not best practices in
development with database, Virtual Forms, and Google Maps." John Peterson, Insync and V.I.O Inc
"Excellent coverage of developing ASP.NET applications, with plenty of sample code." Peter Bromberg, VOIP, Inc.
"The web services chapter concludes a comprehensive
education on Web 2.0 The examples go a long way to support the Web 2.0 mission of this book." George Semeczko,
Independent Consultant
Trang 5Deitel® Developer Series AJAX, Rich Internet Applications, and Web Development for
Trang 7Section 4.7 Decision Making: Equality and RelationalOperators
Section 5.8 Formulating Algorithms: Nested ControlStatements
Trang 9Chapter 10 Document Object Model (DOM): Objects andCollections
Section 10.1 Introduction
Section 10.2 Modeling a Document: DOM Nodes andTrees
Trang 10Section 11.2 Registering Event Handlers
Section 11.3 Event onload
Section 11.4 Event onmousemove, the event Object andthis
Section 11.5 Rollovers with onmouseover and
onmouseout
Section 11.6 Form Processing with onfocus and onblurSection 11.7 Form Processing with onsubmit and onresetSection 11.8 Event Bubbling
Section 13.5 "Raw" Ajax Example Using the
Trang 11Section 15.2 Object-Oriented Programming
Section 15.3 Objects in Flash
Section 15.4 Cannon Game: Preliminary Instructions andNotes
Trang 12Section 15.14 ActionScript 3.0 Elements Introduced inThis Chapter
Chapter 16 Adobe® Flex™ 2 and Rich Internet ApplicationsSection 16.1 Introduction
Section 16.2 Flex Platform Overview
Section 16.3 Creating a Simple User Interface
Section 16.4 Accessing XML Data from Your ApplicationSection 16.5 Interacting with Server-Side ApplicationsSection 16.6 Customizing Your User Interface
Section 17.5 Accessing Web Servers
Section 17.6 Microsoft Internet Information Services(IIS)
Section 17.7 Apache HTTP Server
Section 17.8 Requesting Documents
Section 17.9 Web Resources
Chapter 18 Database: SQL, MySQL, ADO.NET 2.0 and JavaDB
Section 18.1 Introduction
Section 18.2 Relational Databases
Trang 13Section 18.4 SQL
Section 18.5 MySQL
Section 18.6 Instructions for Installing MySQL
Section 18.7 Instructions for Setting Up a MySQL UserAccount
Trang 14Section 21.3 Web Controls
Section 21.4 Session Tracking
Section 21.5 Case Study: Connecting to a Database inASP.NET
Section 23.4 AutoComplete Text Field and Virtual FormsSection 23.5 Google Maps Map Viewer Component
Trang 15Section 24.7 Consuming a Database-Driven Web Servicefrom a Web Application
Trang 16Many of the designations used by manufacturers and sellers todistinguish their products are claimed as trademarks Wherethose designations appear in this book, and the publisher wasaware of a trademark claim, the designations have been printedwith initial capital letters or in all capitals
The authors and publisher have taken care in the preparation ofthis book, but make no expressed or implied warranty of anykind and assume no responsibility for errors or omissions Noliability is assumed for incidental or consequential damages inconnection with or arising out of the use of the information orprograms contained herein
The publisher offers excellent discounts on this book when
ordered in quantity for bulk purchases or special sales, whichmay include electronic versions and/or custom covers and
content particular to your business, training goals, marketingfocus, and branding interests For more information, please
Trang 17reproduction, storage in a retrieval system, or transmission inany form or by any means, electronic, mechanical,
photocopying, recording, or likewise For information regardingpermissions, write to:
Del.icio.us and Flickr are trademarks of Yahoo! Inc
Digg is a trademark of Digg Inc
Firefox is a registered trademark of the Mozilla Foundation.Google is a trademark of Google, Inc
JavaScript, Java and all Java-based marks are trademarks orregistered trademarks of Sun Microsystems, Inc in the UnitedStates and other countries
Trang 18MySpace is a registered trademark of MySpace.com
UNIX is a registered trademark of The Open Group
Ruby on Rails is a trademark of David Heinemeier Hansson.MySQL is a registered trademark of MySQL AB
Second Life is a registered trademark of Linden Research, Inc.Skype is a trademark of eBay, Inc
Web 2.0 is a service mark of CMP Media
Wikipedia is a registered trademark of WikiMedia
Throughout this book, trademarks are used Rather than put atrademark symbol in every occurrence of a trademarked name,
we state that we are using the names in an editorial fashiononly and to the benefit of the trademark owner, with no
intention of infringement of the trademark
Dedication
To Jesse James Garrett:
For recognizing that "something special was in the air" in web applications development; for coining the term "Ajax" (Asynchronous JavaScript and XML) to name that
phenomenon; and for your tireless efforts in promoting Ajax
—a key set of technologies defining Web 2.0.
Paul and Harvey Deitel
Trang 19Deitel Developer Series
Trang 20AJAX, Rich Internet Applications and Web Development forProgrammers
Trang 21deitel@deitel.com
For continuing updates on Prentice Hall/Deitel publications visit:www.deitel.com
www.prenhall.com/deitel
www.InformIT.com/deitel
Check out our Resource Centers for valuable web resources thatwill help you master C++, other important programming
languages, software and Web 2.0 topics:
www.deitel.com/ResourceCenters.html
Trang 22Our Resource Centers focus on the vast amounts of free contentavailable online Find resources, downloads, tutorials,
documentation, books, e-books, journals, articles, blogs, RSSfeeds and more on many of today's hottest programming andtechnology topics For the most up-to-date list of our ResourceCenters, visit:
Trang 23Java
Java Certification and Assessment TestingJava Design Patterns
Trang 27Computer GamesComputing Jobs
Gadgets and GizmosRing Tones
Sudoku
Trang 28the challenges are for the designers of these
applications: to forget what we think we know about the
limitations of the Web, and begin to imagine a wider, richer range of possibilities It's going to be fun.
worldwide and develop Web 2.0 Internet businesses This bookreflects today's Web 2.0, Ajax-based, Rich Internet Application-development methodologies
The technologies you'll learn here are appropriate for
experienced professionals who build substantial informationsystems You'll find "industrial-strength" code examples Wehave attempted to write in a clear and straightforward mannerusing best practices
Perhaps most important, the book presents hundreds of
working code examples and shows the outputs produced whenthese examples are rendered in browsers or run on computers
We present all concepts in the context of complete workingprograms We call this the "live-code approach." All of the
source code is available for download from
www.deitel.com/books/ajaxfp/
Trang 29Premium Content for Registered Users," once you've registeredand logged on to our site
The early chapters present a carefully paced introduction to
"client-side" web programming, using the popular JavaScriptlanguage and the closely related technologies of XHTML
(Extensible HyperText Markup Language), CSS (Cascading StyleSheets) and the DOM (Document Object Model) The material inthe JavaScript chapters presents a solid foundation for the
deeper treatment of scripting in the Adobe Flash, Adobe Flex,PHP and Ruby on Rails chapters later in the book Experiencedprogrammers will read the early chapters quickly and find thetreatment of scripting in the later chapters to be rigorous andchallenging
Today's users are accustomed to desktop applications with richgraphical user interfaces (GUIs), such as those used on Apple'sMac OS X systems, Microsoft Windows systems, various Linuxsystems and more Users want applications that employ themultimedia capabilities of graphics, images, animation, audioand video They want applications that can run on the Internetand the web and communicate with other applications Userswant to apply database technologies for storing and
manipulating their business and personal data They want
applications that are not limited to the desktop or even to somelocal computer network, but that can integrate Internet andweb components, and remote databases Programmers want touse all these capabilities in a truly portable manner so that
as Mozilla's Firefox or Microsoft's Internet Explorer), using
Trang 30databases, PHP, Ruby on Rails, ASP.NET, ASP.NET Ajax and
JavaServer Faces (JSF) to build the server side of web-basedapplications These portions of applications typically run on
Focus on Web 2.0 technologies and concepts
Chapter on Web 2.0 and Internet Business (reviewed byleaders in the Web 2.0 community)
Trang 31Two chapters on Adobe Flash CS3, including building a
computer game
Significant treatment of client-side scripting with JavaScript.Significant treatments of XHTML DOM manipulation and
JavaScript events
Significant treatment of XML DOM manipulation with
JavaScript
Chapter on building SOAP-based web services with Java andREST-based web services with ASP.NET (using Visual Basic).Chapter on PHP 5
Coverage of ASP.NET, featuring ASP.NET Ajax
enabled JSF applications
JavaServer Faces (JSF) coverage emphasizing building Ajax-Client-side case studies that enable you to interact with
preimplemented server-side applications and web servicesthat we host at test.deitel.com
Trang 32(JavaScript/DOM), Address Book (Ajax), Cannon Game
(Flash), Weather/Yahoo! Maps Mashup (Flex), Mailing List(PHP/MySQL), Message Forum and Flickr Photo Viewer
(Ruby on Rails), Guest Book and Secure Books Database(ASP.NET), Address Book with Google Maps (JavaServerFaces) and Blackjack (JAX-WS web services)
Figure 1 shows the architecture of AJAX, Rich Internet
Applications and Web Development for Programmers The book
is divided into several parts Chapter 1 introduces Web 2.0 fromthe technical, business and social perspectives, and provides afoundation for understanding Rich Internet Application
development If you are a serious web developer, you'll want totest your web applications across many browsers and platforms.The examples for the book execute correctly on both Microsoft'sInternet Explorer 7 (IE7) and Mozilla's Firefox 2 (FF2) browsers.Most of the examples will also work in other browsers such as
Trang 332–13 cover "raw" Ajax programming, where you'll handle the
Trang 34easily build Ajax-based applications that operate across a widevariety of browsers and browser versions without your having to
be concerned with the low-level details
The third part of the book, Chapters 13–24, focuses on both theclient and server sides of the GUI and the graphical part of RIAdevelopment Here we cover client-side technologies such asAdobe Flash and Adobe Flex that use, or can be combined with,Ajax or Ajax-like capabilities to develop RIAs Each of these
technologies also can consume web services Next, we presentthe server side of web application development with discussions
of web servers (IIS and Apache), databases, server-side
scripting languages such as PHP and Ruby on Rails, and severalserver-side frameworks such as ASP.NET 2.0 and Java-ServerFaces We complete our server-side discussion with a chapter
on building both SOAP-based and REST-based web services.You may have noticed that Chapter 13, Ajax-Enabled Rich
Internet Applications, overlaps the second and third parts of thebook Chapter 13 serves as a bridge from "raw" Ajax
development to "encapsulated" Ajax development with the Dojolibraries
Dependency Chart
Figure 2 illustrates the dependencies that exist among chapters
in the book An arrow pointing into a chapter indicates that itdepends on the content of the chapter from which the arrowpoints For example, Chapter 24, Web Services, depends onboth Chapters 21 and 23 We recommend that you read all of agiven chapter's dependencies before reading that chapter,
though other orders are possible We've also commented onsome additional dependencies in the diagram's footnotes
Figure 2 AJAX, Rich Internet Applications and Web
Development for Programmers chapter dependency
chart.
Trang 351 Chapters 22 – 23 require knowledge of Java Standard Edition 6 2 Sections 24.2 – 24.8 require Chapters 22 – 22
Section 24.9 requires Chapter 21
[View full size image]
Teaching Approach
AJAX, Rich Internet Applications and Web Development for Programmers contains a rich collection of examples The book
Trang 37Objectives Each chapter begins with a statement of
objectives This lets you know what to expect and gives you anopportunity to determine if you have met the objectives afterreading the chapter
Quotations The learning objectives are followed by
quotations Some are humorous; some are philosophical; othersoffer interesting insights We hope that you enjoy relating thequotations to the chapter material
Outline The chapter outline helps you approach the material in
a top-down fashion, so you can anticipate what is to come andset a comfortable learning pace
Illustrations/Figures Abundant charts, tables, line drawings,
programs and program output are included
Programming Tips We include programming tips to help you
focus on important aspects of program development These tipsand practices represent the best we have gleaned from a
combined six decades of programming and teaching experience.One of our readers told us that she feels this approach is likethe highlighting of axioms, theorems and corollaries in
mathematics books—it provides a basis on which to build good
Trang 38Good Programming Practices
Good Programming Practices call attention
to techniques that will help you produce programs that are clearer, more
understandable and more maintainable.
Common Programming Errors
Programmers tend to make certain kinds of errors frequently Pointing out these
Common Programming Errors reduces the likelihood that you'll make the same
mistakes.
Error-Prevention Tip
These tips contain suggestions for exposing bugs and removing them from your
programs; many describe aspects of programming that prevent bugs from getting into programs in the first place.
Performance Tip
Trang 39These tips highlight opportunities for making your programs run faster or minimizing the amount of memory that they occupy.
Portability Tip
We include Portability Tips to help you write code that will run on a variety of platforms and to explain how to achieve a high
degree of portability.
Software Engineering Observation
The Software Engineering Observations highlight architectural and design issues that affect the construction of software systems, especially large-scale systems.
Thousands of Index Entries We have included an extensive
index which is especially useful when you use the book as areference
"Double Indexing" of Live-Code Examples For every
source-code program in the book, we index the figure captionboth alphabetically and as a subindex item under "Examples."This makes it easier to find examples using particular features
Trang 40information on our corporate instructor-led training courses andmore It's also a good way for you to keep posted about issues