Ajax in Action

Free Download

Authors:

Edition: 1

ISBN: 1932394613, 9781932394665, 9781932394610

Size: 9 MB (9707994 bytes)

Pages: 680/680

File format:

Language:

Publishing Year:

Category:

Dave Crane, Eric Pascarello, Darren James1932394613, 9781932394665, 9781932394610

It’s practically the holy grail: applications that run in web browsers, use standard web technologies, yet have the richness, responsiveness, and usability of today’s best desktop applications. But this quest has a destination: Ajax. If you’ve used Gmail, or Google Maps, or Flickr, you’ve seen Ajax at work. If you read Ajax in Action, you can put it to work, too. Ajax requires you to think about web development in very different ways. Forget the page-based metaphor; start thinking about design patterns, refactoring, and managing client codebases. Dave Crane and Eric Pascarello cover all that, and much more, including architecture, security, and performance. Their sample applications prove you can use Ajax for both large and small projects – and add value to existing web applications in surprising ways.

Table of contents :
preface……Page 19
acknowledgments……Page 21
about this book……Page 24
Roadmap……Page 25
Code downloads……Page 28
About the title……Page 29
About the cover illustration……Page 30
Rethinking the web application……Page 31
A new design for the Web……Page 33
1.1.1 Comparing the user experiences……Page 35
1.1.2 Network latency……Page 39
1.1.3 Asynchronous interactions……Page 42
1.1.4 Sovereign and transient usage patterns……Page 45
1.1.5 Unlearning the Web……Page 46
1.2.1 The browser hosts an application, not content……Page 47
1.2.2 The server delivers data, not content……Page 49
1.2.3 User interaction with the application can be fluid and continuous……Page 51
1.2.4 This is real coding and requires discipline……Page 53
1.3.1 Surveying the field……Page 54
1.3.2 Google Maps……Page 55
1.4.2 Java Web Start and related technologies……Page 58
1.5 Summary……Page 59
1.6 Resources……Page 60
First steps with Ajax……Page 61
2.1 The key elements of Ajax……Page 62
2.2 Orchestrating the user experience with JavaScript……Page 64
2.3 Defining look and feel using CSS……Page 66
2.3.1 CSS selectors……Page 67
2.3.2 CSS style properties……Page 69
2.3.3 A simple CSS example……Page 70
2.4 Organizing the view using the DOM……Page 75
2.4.1 Working with the DOM using JavaScript……Page 77
2.4.2 Finding a DOM node……Page 79
2.4.3 Creating a DOM node……Page 80
2.4.4 Adding styles to your document……Page 81
2.5 Loading data asynchronously using XML technologies……Page 83
2.5.1 IFrames……Page 84
2.5.2 XmlDocument and XMLHttpRequest objects……Page 86
2.5.3 Sending a request to the server……Page 88
2.5.4 Using callback functions to monitor the request……Page 91
2.5.5 The full lifecycle……Page 92
2.6 What sets Ajax apart……Page 95
2.7 Summary……Page 97
2.8 Resources……Page 98
Introducing order to Ajax……Page 99
3.1.1 Patterns: creating a common vocabulary……Page 101
3.1.2 Refactoring and Ajax……Page 102
3.1.4 Refactoring in action……Page 103
3.2.1 Cross-browser inconsistencies: Façade and Adapter patterns……Page 107
3.2.2 Managing event handlers: Observer pattern……Page 110
3.2.3 Reusing user action handlers: Command pattern……Page 113
3.2.4 Keeping only one reference to a resource: Singleton pattern……Page 117
3.3 Model-View-Controller……Page 121
3.4.1 The Ajax web server tier without patterns……Page 123
3.4.2 Refactoring the domain model……Page 126
3.4.3 Separating content from presentation……Page 130
3.5 Third-party libraries and frameworks……Page 133
3.5.1 Cross-browser libraries……Page 134
3.5.2 Widgets and widget suites……Page 138
3.5.3 Application frameworks……Page 141
3.6 Summary……Page 144
3.7 Resources……Page 145
Core techniques……Page 147
The page as an application……Page 149
4.1.1 Repeating the pattern at different scales……Page 150
4.1.2 Applying MVC in the browser……Page 152
4.2.1 Keeping the logic out of the View……Page 154
4.2.2 Keeping the View out of the logic……Page 160
4.3.1 Classic JavaScript event handlers……Page 164
4.3.2 The W3C event model……Page 167
4.3.3 Implementing a flexible event model in JavaScript……Page 168
4.4 Models in an Ajax application……Page 173
4.4.1 Using JavaScript to model the business domain……Page 174
4.4.2 Interacting with the server……Page 175
4.5.1 Reflecting on a JavaScript object……Page 177
4.5.2 Dealing with arrays and objects……Page 181
4.5.3 Adding a Controller……Page 184
4.6 Summary……Page 187
4.7 Resources……Page 188
The role of the server……Page 189
5.1 Working with the server side……Page 190
5.2.1 Popular implementation languages……Page 191
5.2.2 N-tier architectures……Page 192
5.2.3 Maintaining client-side and server-side domain models……Page 193
5.3.1 Naive web server coding without a framework……Page 194
5.3.2 Working with Model2 workflow frameworks……Page 196
5.3.3 Working with component-based frameworks……Page 197
5.3.4 Working with service-oriented architectures……Page 200
5.4 The details: exchanging data……Page 204
5.4.2 Introducing the planet browser example……Page 205
5.4.3 Thinking like a web page: content-centric interactions……Page 208
5.4.4 Thinking like a plug-in: script-centric interactions……Page 212
5.4.5 Thinking like an application: data-centric interactions……Page 218
5.5.1 Using HTML forms……Page 223
5.5.2 Using the XMLHttpRequest object……Page 225
5.5.3 Managing user updates effectively……Page 227
5.6 Summary……Page 236
5.7 Resources……Page 237
Professional Ajax……Page 239
The user experience……Page 241
6.1 Getting it right: building a quality application……Page 242
6.1.2 Robustness……Page 243
6.1.3 Consistency……Page 244
6.1.5 Making it work……Page 245
6.2.1 Handling responses to our own requests……Page 246
6.2.2 Handling updates from other users……Page 248
6.3 Designing a notification system for Ajax……Page 252
6.3.1 Modeling notifications……Page 253
6.3.2 Defining user interface requirements……Page 255
6.4.1 Rendering status bar icons……Page 256
6.4.2 Rendering detailed notifications……Page 259
6.4.3 Putting the pieces together……Page 260
6.5 Using the framework with network requests……Page 267
6.6.1 Defining a simple highlighting style……Page 271
6.6.2 Highlighting with the Scriptaculous Effects library……Page 273
6.7 Summary……Page 274
6.8 Resources……Page 275
Security and Ajax……Page 276
7.1 JavaScript and browser security……Page 277
7.1.2 Considerations for Ajax……Page 278
7.1.3 Problems with subdomains……Page 279
7.1.4 Cross-browser security……Page 280
7.2 Communicating with remote services……Page 281
7.2.1 Proxying remote services……Page 282
7.2.2 Working with web services……Page 283
7.3.1 The man in the middle……Page 293
7.3.2 Using secure HTTP……Page 294
7.3.3 Encrypting data over plain HTTP using JavaScript……Page 296
7.4.1 Designing a secure web tier……Page 298
7.4.2 Restricting access to web data……Page 302
7.5 Summary……Page 307
7.6 Resources……Page 308
Performance……Page 309
8.1 What is performance?……Page 310
8.2 JavaScript execution speed……Page 311
8.2.1 Timing your application the hard way……Page 312
8.2.2 Using the Venkman profiler……Page 318
8.2.3 Optimizing execution speed for Ajax……Page 319
8.3.1 Avoiding memory leaks……Page 332
8.3.2 Special considerations for Ajax……Page 336
8.4 Designing for performance……Page 341
8.4.1 Measuring memory footprint……Page 342
8.4.2 A simple example……Page 346
8.4.3 Results: how to reduce memory footprint 150-fold……Page 351
8.5 Summary……Page 353
8.6 Resources……Page 354
Ajax by example……Page 355
Dynamic double combo……Page 357
9.1.1 Limitations of a client-side solution……Page 358
9.1.2 Limitations of a server-side solution……Page 359
9.1.3 Ajax-based solution……Page 360
9.2.1 Designing the form……Page 361
9.2.2 Designing the client/server interactions……Page 363
9.3 Implementing the server: VB .NET……Page 364
9.3.1 Defining the XML response format……Page 365
9.3.2 Writing the server-side code……Page 366
9.4.1 Navigating the XML document……Page 369
9.4.2 Applying Cascading Style Sheets……Page 372
9.5.1 Allowing multiple-select queries……Page 373
9.6 Refactoring……Page 375
9.6.1 New and improved net.ContentLoader……Page 376
9.6.2 Creating a double-combo component……Page 382
9.7 Summary……Page 389
Type-ahead suggest……Page 391
10.1.1 Common type-ahead suggest features……Page 392
10.1.2 Google Suggest……Page 394
10.1.3 The Ajax in Action type-ahead……Page 395
10.2.1 The server and the database……Page 396
10.2.2 Testing the server-side code……Page 398
10.3.1 The HTML……Page 399
10.3.2 The JavaScript……Page 400
10.3.3 Accessing the server……Page 410
10.5 Refactoring……Page 422
10.5.1 Day 1: developing the TextSuggest component game plan……Page 424
10.5.2 Day 2: TextSuggest creation-clean and configurable……Page 427
10.5.3 Day 3: Ajax enabled……Page 431
10.5.4 Day 4: handling events……Page 436
10.5.5 Day 5: the suggestions pop-up UI……Page 443
10.5.6 Refactor debriefing……Page 451
10.6 Summary……Page 452
The enhanced Ajax web portal……Page 453
11.1.1 The classic portal……Page 454
11.1.2 The rich user interface portal……Page 456
11.2 The Ajax portal architecture using Java……Page 457
11.3.1 The user table……Page 459
11.3.2 The server-side login code: Java……Page 460
11.3.3 The client-side login framework……Page 463
11.4.1 The portal windows database……Page 469
11.4.2 The portal window’s server-side code……Page 471
11.4.3 Adding the JS external library……Page 475
11.5.1 Adapting the library……Page 478
11.5.2 Autosaving the information to the database……Page 480
11.6 Refactoring……Page 483
11.6.1 Defining the constructor……Page 485
11.6.2 Adapting the AjaxWindows.js library……Page 486
11.6.3 Specifying the portal commands……Page 488
11.6.4 Performing the Ajax processing……Page 492
11.7 Summary……Page 494
Live search using XSLT……Page 496
12.1.1 Looking at the classic search……Page 497
12.1.2 The flaws of the frame and pop-up methods……Page 499
12.1.3 Examining a live search with Ajax and XSLT……Page 500
12.1.4 Sending the results back to the client……Page 502
12.2.1 Setting up the client……Page 503
12.2.2 Initiating the process……Page 504
12.3.1 Building the XML document……Page 506
12.3.2 Building the XSLT document……Page 509
12.4 Combining the XSLT and XML documents……Page 511
12.4.1 Working with Microsoft Internet Explorer……Page 513
12.4.2 Working with Mozilla……Page 514
12.5.1 Applying a Cascading Style Sheet……Page 515
12.5.2 Improving the search……Page 517
12.5.3 Deciding to use XSLT……Page 519
12.5.4 Overcoming the Ajax bookmark pitfall……Page 520
12.6 Refactoring……Page 521
12.6.1 An XSLTHelper……Page 522
12.6.2 A live search component……Page 526
12.7 Summary……Page 531
Building stand-alone applications with Ajax……Page 533
13.1 Reading information from the outside world……Page 534
13.1.1 Discovering XML feeds……Page 535
13.1.2 Examining the RSS structure……Page 536
13.2 Creating the rich user interface……Page 539
13.2.1 The process……Page 540
13.2.2 The table-less HTML framework……Page 541
13.2.3 Compliant CSS formatting……Page 543
13.3.1 Global scope……Page 548
13.3.2 Ajax preloading functionality……Page 550
13.4.1 Cross-browser opacity rules……Page 554
13.4.2 Implementing the fading transition……Page 555
13.4.3 Integrating JavaScript timers……Page 557
13.5 Additional functionality……Page 558
13.5.1 Inserting additional feeds……Page 559
13.5.2 Integrating the skipping and pausing functionality……Page 561
13.6.1 Overcoming Mozilla’s security restriction……Page 564
13.7.1 RSS reader Model……Page 567
13.7.2 RSS reader view……Page 571
13.7.3 RSS reader Controller……Page 575
13.7.4 Refactoring debrief……Page 588
13.8 Summary……Page 589
The Ajax craftsperson’s toolkit……Page 591
A.1.1 Acquiring tools that fit……Page 592
A.1.2 Building your own tools……Page 593
A.1.3 Maintaining your toolkit……Page 594
A.2.1 What to look for in a code editor……Page 595
A.2.2 Current offerings……Page 597
A.3 Debuggers……Page 601
A.3.2 JavaScript debuggers……Page 602
A.3.3 HTTP debuggers……Page 607
A.3.4 Building your own cross-browser output console……Page 609
A.4 DOM inspectors……Page 612
A.4.1 Using the Mozilla DOM Inspector……Page 613
A.4.2 DOM inspectors for Internet Explorer……Page 614
A.5 Installing Firefox extensions……Page 615
A.6 Resources……Page 618
JavaScript for object-oriented programmers……Page 619
B.1 JavaScript is not Java……Page 620
B.2.1 Building ad hoc objects……Page 622
B.2.2 Constructor functions, classes, and prototypes……Page 627
B.2.3 Extending built-in classes……Page 629
B.2.4 Inheritance of prototypes……Page 630
B.2.5 Reflecting on JavaScript objects……Page 631
B.2.6 Interfaces and duck typing……Page 633
B.3.1 Functions as first-class citizens……Page 636
B.3.2 Attaching functions to objects……Page 637
B.3.3 Borrowing functions from other objects……Page 638
B.3.4 Ajax event handling and function contexts……Page 639
B.3.5 Closures in JavaScript……Page 644
B.5 Resources……Page 647
Ajax frameworks and libraries……Page 649
Ajax JavaServer Faces Framework……Page 650
AjaxAC……Page 651
BackBase……Page 652
CakePHP……Page 653
CPAINT (Cross-Platform Asynchronous Interface Toolkit)……Page 654
f(m)……Page 655
HTMLHttpRequest……Page 656
JSON……Page 657
Oddpost……Page 658
Qooxdoo……Page 659
SAJAX……Page 660
Tibet……Page 661
WebORB for Java……Page 662
XHConn……Page 663
A……Page 665
B……Page 666
C……Page 667
D……Page 668
E……Page 669
F……Page 670
I……Page 671
L……Page 672
N……Page 673
P……Page 674
Q……Page 675
R……Page 676
S……Page 677
T……Page 678
W……Page 679
Z……Page 680

Reviews

There are no reviews yet.

Be the first to review “Ajax in Action”
Shopping Cart
Scroll to Top