The XMLHttpRequest Object - Springer978-1-4302-0189-2/1.pdfThe XMLHttpRequest Object M ... Some of...

25
The XMLHttpRequest Object More often than not, chances are you will use some sort of library to do your Ajax work. Some of the libraries out there—only a handful of which we talked about in this book—really do make it far easier to work the “Ajax way.” That being said, there are times when you will want to go “bare metal,” so to speak, and use the XMLHttpRequest object yourself. In those instances, this appendix will be an invaluable aid to you. What Is the XMLHttpRequest Object? XMLHttpRequest is an object (an ActiveX object in Microsoft Internet Explorer, a native component in most other browsers) that allows a web page to make a request to a server and get a response back without reloading the entire page. The user remains on the same page, and more important, they will not actually see the processing occur—that is, they will not see a new page loading, not by default at least. Using the XMLHttpRequest object makes it possible for a developer to alter a page previously loaded in the browser with data from the server without having to request the entire page from the server again. What Browsers Support the XMLHttpRequest Object? XMLHttpRequest is present in Internet Explorer 5.0 and higher, Apple’s Safari 1.2 and higher, Mozilla’s Firefox 1.0 and higher, Opera 7.6 and higher, and Netscape 7 and higher. Other browsers may or may not support it, so you should check for the capability before attempting to use it if you intend to support alternative browsers. Also of note is a little JavaScript library by Andrew Gregory that allows for cross-browser Ajax support without dealing with the details of what browsers support the object and how. There are some limitations, but it is of interest nonetheless. You can find information on it here: www.scss.com.au/family/andrew/webdesign/xmlhttprequest. 479 APPENDIX A ■ ■ ■

Transcript of The XMLHttpRequest Object - Springer978-1-4302-0189-2/1.pdfThe XMLHttpRequest Object M ... Some of...

Page 1: The XMLHttpRequest Object - Springer978-1-4302-0189-2/1.pdfThe XMLHttpRequest Object M ... Some of the libraries out there—only a handful of which we talked about in this book—really

The XMLHttpRequest Object

More often than not, chances are you will use some sort of library to do your Ajax work.Some of the libraries out there—only a handful of which we talked about in this book—reallydo make it far easier to work the “Ajax way.” That being said, there are times when you willwant to go “bare metal,” so to speak, and use the XMLHttpRequest object yourself. In thoseinstances, this appendix will be an invaluable aid to you.

What Is the XMLHttpRequest Object?XMLHttpRequest is an object (an ActiveX object in Microsoft Internet Explorer, a native componentin most other browsers) that allows a web page to make a request to a server and get a responseback without reloading the entire page. The user remains on the same page, and more important,they will not actually see the processing occur—that is, they will not see a new page loading, notby default at least. Using the XMLHttpRequest object makes it possible for a developer to alter apage previously loaded in the browser with data from the server without having to request theentire page from the server again.

What Browsers Support the XMLHttpRequestObject?XMLHttpRequest is present in Internet Explorer 5.0 and higher, Apple’s Safari 1.2 and higher,Mozilla’s Firefox 1.0 and higher, Opera 7.6 and higher, and Netscape 7 and higher. Otherbrowsers may or may not support it, so you should check for the capability before attemptingto use it if you intend to support alternative browsers.

Also of note is a little JavaScript library by Andrew Gregory that allows for cross-browserAjax support without dealing with the details of what browsers support the object and how.There are some limitations, but it is of interest nonetheless. You can find information on ithere: www.scss.com.au/family/andrew/webdesign/xmlhttprequest.

479

A P P E N D I X A

■ ■ ■

Page 2: The XMLHttpRequest Object - Springer978-1-4302-0189-2/1.pdfThe XMLHttpRequest Object M ... Some of the libraries out there—only a handful of which we talked about in this book—really

Is the XMLHttpRequest Object a W3C Standard?(Or Any Other Kind of Standard for That Matter!)No, the XMLHttpRequest object is not a W3C standard, or a standard of any other standards body. TheW3C DOM Level 3 specification’s “Load and Save” capabilities would provide similar functionality,but currently no browsers implement the Level 3 specification. Therefore, until that specification iswidely adopted, if you need to send an HTTP request from a browser and get a response from aserver, aside from the normal page navigation mechanism, the XMLHttpRequest object is the onlyviable option, along with some of the lesser-used (nowadays) alternatives like Java applets andActiveX controls.

How Do I Use the XMLHttpRequest Object?In Mozilla, Firefox, Safari, and Netscape, you create an instance of the XMLHttpRequest objectby doing the following:

<script>var xhr = new XMLHttpRequest();</script>

For Internet Explorer:

<script> var xhr = new ActiveXObject("Microsoft.XMLHTTP");</script>

Here is an example of using the XMLHttpRequest object:

<script>

var xhr = null;if (window.XMLHttpRequest){xhr = new XMLHttpRequest();

} else {xhr = new ActiveXObject("Microsoft.XMLHTTP");

}if (xhr) {var url = "/someURI";xhr.onreadystatechange = xhrCallback;xhr.open("get", url, true)xhr.send()

}

function xhrCallback() {if (xhr.readyState == 4) {if (xhr.status == 200) {alert("Ok");

APPENDIX A ■ THE XMLHTTPREQUEST OBJECT480

Page 3: The XMLHttpRequest Object - Springer978-1-4302-0189-2/1.pdfThe XMLHttpRequest Object M ... Some of the libraries out there—only a handful of which we talked about in this book—really

} else {alert("Problem retrieving Ajax response");

}}

}

</script>

XMLHttpRequest Object Method and PropertiesReferenceTables A-1 and A-2 outline the methods and properties available on the XMLHttpRequest object,representing the full API interface to that object through which you will interact with it.

Table A-1. XMLHttpRequest Object Methods

Method Description

abort() Stops the request that the object is currentlyprocessing. Note that like clicking the Stop button inyour browser, the server will not be notified and willcontinue to process the request.

getAllResponseHeaders This method returns all of the headers, both keysand values, as a string.

getResponseHeader("key") This method returns the specified header value as astring.

open("method", "url" [,asyncFlag Contrary to its name, this does not appear to literally [,"username" [,"password"]]] open anything. Instead, it just sets the parameters for

the pending request. The value of method may be anyvalid HTTP method, get and post being the mostcommon. asyncFlag is either true or false. Setting thisto false will cause all JavaScript on the page to haltuntil the request returns. This is generally notdesirable because if the server is unavailable, or theoperation simply takes a long time, the user interfacewill seem to freeze to the user. Use with caution!username and password are used to make requests toURLs protected with Basic Auth security. Note thatthese two parameters, as well as asyncFlag, areoptional, while method and url are required.

send(content) This method transmits the pending request, andoptionally sends a POST body or serialized DOMobject (i.e., XML document). If POSTing simpleparameters, content should be a string in the form“name1=value1&name2=value2”—in other words, aquery string minus the initial question mark.

setRequestHeader("key", "value") Sets an HTTP header that will be set on the outgoingresponse.

APPENDIX A ■ THE XMLHTTPREQUEST OBJECT 481

Page 4: The XMLHttpRequest Object - Springer978-1-4302-0189-2/1.pdfThe XMLHttpRequest Object M ... Some of the libraries out there—only a handful of which we talked about in this book—really

Table A-2. XMLHttpRequest Object Properties

Property Description

onReadyStateChange This is a pointer to the function that will serve as the event handler forthe request this object instance is processing. Note that this functionwill be called multiple times during the lifecycle of the request.

readyState This is an integer representing the status of the request. Possible valuesare 0 (uninitialized), 1 (loading), 2 (loaded), 3 (interactive), and 4(complete).

responseText This is a textual string version of the response from the server. Even ifthe response was XML, you will still find the actual text of the responsehere.

responseXML If the response from the server was XML, the object will do the extrawork of parsing it and generating a real DOM-compatible object thatyou can manipulate with DOM methods.

status This is the numeric HTTP result code returned by the server, such as404 if the resource is not found, or 200 if the result was OK.

statusText This is a textual message string describing the status code.

XMLHttpRequest Object Status CodesTable A-3 lists the status codes that can show up in the readystate field of the XMLHttpRequestobject during the lifecycle of a request as your callback function is repeatedly called.

Table A-3. XMLHttpRequest Object readystate Status Codes

Numeric Code Description

0 Uninitialized. This is the value the readystate field will have initially before anyoperation is begun.

1 Loading. This means the open() method has been successfully called, but send()has not yet been called.

2 Loaded. This means send() has been called, and the object has completed therequest, but no data has been received yet. Headers and status, however, areavailable at this point.

3 Receiving (or Interactive). This means the response is being chunked back to theclient. responseText at this point will hold the response as received thus far.

4 Loaded (or Completed). The request has completed and the full response hasbeen received.

APPENDIX A ■ THE XMLHTTPREQUEST OBJECT482

Page 5: The XMLHttpRequest Object - Springer978-1-4302-0189-2/1.pdfThe XMLHttpRequest Object M ... Some of the libraries out there—only a handful of which we talked about in this book—really

Libraries, Websites, and Books,Oh My!

Throughout this book, we’ve referenced a number of libraries, websites, and books for you toget further information or see examples. Here is a concise list of all those references for yourconvenience, even for those libraries that are used as part of an application but not specifi-cally described (but, uh, please do still read this book, OK?).

Libraries/Toolkits/Products• Adobe (formerly Macromedia) Flash (www.adobe.com/products/flash/flashpro): Flash is

not just a vector animation tool; it is truly a full-fledged development environment allow-ing you to create multimedia-rich websites that will run identically across most modernplatforms (if a supported Flash player is available, which is mostly the case these days).

• Adobe (formerly Macromedia) Flex (www.adobe.com/flex): A rich client developmentframework that can greatly simplify creation of dynamic web applications.

• Apache Ant (ant.apache.org): The de facto standard in Java build tools.

• Apache Geronimo (geronimo.apache.org): An Apache application server.

• Apache Jakarta Commons (jakarta.apache.org/commons): Under the Commons banneryou will find a number of very useful libraries, including Commons Logging, BeanUtils,FileUpload, Commons Chain, and much more. In short, if you aren’t using Commonstoday, you should be tomorrow!

• BEA WebLogic (www.bea.com): Another of the big players in the application server mar-ket; provides much the same capabilities as WebSphere (although both vendors havetheir advantages and disadvantages).

• Caucho’s Resin (www.caucho.com): Another application server, fairly popular with webhosts.

• Dojo (dojotoolkit.org): A popular Ajax toolkit that, in addition to its Ajax functionality,provides a lot of nifty client-side functions such as collections and client-side sessionstorage, as well as a number of excellent GUI widgets.

483

A P P E N D I X B

■ ■ ■

Page 6: The XMLHttpRequest Object - Springer978-1-4302-0189-2/1.pdfThe XMLHttpRequest Object M ... Some of the libraries out there—only a handful of which we talked about in this book—really

• DWR, or Direct Web Remoting (getahead.ltd.uk/dwr): A very popular Ajax library thatprovides a syntax in JavaScript to call objects on the server, making them appear to berunning locally (in terms of the JavaScript you write).

• Eclipse (www.eclipse.org): Probably the most popular Java IDE out there, and free to boot!

• FreeMarker (freemarker.sourceforge.net): A Java-based template engine, used bydefault by WebWork.

• HSQLDB (www.hsqldb.org): Free, lightweight (but not in terms of functionality!), pure-Java database engine.

• IBM WebSphere (www-306.ibm.com/software/websphere): A full-blown Java applicationserver providing many services, including servlets, JSP, JNDI, EJB, and so on.

• IntelliJ IDEA (www.jetbrains.com/idea): If you want an IDE and don’t mind paying for it,this is probably the best available.

• Java Web Parts (javawebparts.sourceforge.net): A collection of handy classes and utili-ties such as servlets, filters, taglibs, a Chain of Responsibility (CoR) implementation,and much more, to help web developers working in Java.

• jEdit (www.jedit.org): A fantastic text editor, this one is free and open source, and moreimportant, features a large number of plug-ins that perform a great deal of tasks, bring-ing it closer to a full-blown IDE than just a text editor.

• Jetty (http://mortbay.org/jetty/index.html): Jetty is a 100 percent Java HTTP server andservlet container. This means that you do not need to configure and run a separate webserver (like Apache) in order to use Java, servlets, and JSPs to generate dynamic content.

• JSLib (http://jslib.mozdev.org): A JavaScript library from the Mozilla Foundation thatincludes such features as an SAX XML parser.

• JSTL (java.sun.com/products/jsp/jstl): JavaServer Pages Standard Tag Library, a set ofsimple, common tags to be used in JSPs to make your life easier and your pages cleaner.

• Macromedia JRun (www.macromedia.com/software/jrun): Another entry in the servermarket.

• Maven (maven.apache.org): An increasingly popular build tool, Maven is designed to domost things for you without you having to write build scripts as you do with Ant.

• OpenEJB (http://sourceforge.net/projects/openejb): An open source, modular, con-figurable, and extendable Enterprise JavaBeans (EJB) container system and EJB server.

• Prototype (prototype.conio.net): JavaScript library for doing Ajax, as well as someother handy things.

• ROME (https://rome.dev.java.net): A Java library for working with RSS feeds.

• Sarissa (http://sourceforge.net/projects/sarissa): Billed as a general-purpose XMLprocessing tool for JavaScript, it includes XSLT processing and much more.

APPENDIX B ■ LIBRARIES, WEBSITES, AND BOOKS, OH MY!484

Page 7: The XMLHttpRequest Object - Springer978-1-4302-0189-2/1.pdfThe XMLHttpRequest Object M ... Some of the libraries out there—only a handful of which we talked about in this book—really

• Spring Framework (www.springframework.org): A massive framework that covers a greatmany of the bases J2EE developers need, including an Inversion of Control (IoC) con-tainer, Aspect-Oriented Programming (AOP) support, and JDBC utility classes.

• Struts Action Framework (struts.apache.org): Perhaps the most popular web frame-work out there utilizing the Model-View-Controller (MVC) pattern.

• Tomcat (tomcat.apache.org): The reference implementation of the servlet and JSPspecs, Tomcat is a fast, simple, standards-compliant, and powerful servlet containerfavored by many developers and hosting environments alike.

• UltraEdit (www.ultraedit.com): In my opinion, the best text editor available for Windows.

• Velocity (jakarta.apache.org/velocity): A Java-based template engine; an alternativeto JSPs.

• WebWork (www.opensymphony.org/webwork): A popular MVC framework, which is, as ofthis writing, the future of Struts.

• Xara Webstyle (www.xara.com/products/webstyle/): For those of us who can do somegraphics work but are far from artists ourselves, Webstyle is a fantastic tool to creategraphics for the Web that make us look like we know what we’re doing!

• XML4Script (http://xmljs.sourceforge.net/website/documentation-w3cdom.html):Another JavaScript library for parsing XML.

Websites• Adaptive Path (www.adaptivepath.com): The company that Jesse James Garrett works for.

• “Ajax: A New Approach to Web Applications,” by Jesse James Garrett (www.adap-tivepath.com/publications/essays/archives/000385.php): The article where Ajax gotits name.

• BackBase (www.backbase.com): Providers of excellent Ajax applications and toolkits.

• CSS Zen Garden (www.csszengarden.com): If you want to see what is possible with CSSlayout, look no further than this site.

• Excite (www.excite.com): A great example of a portal site.

• Flickr (www.flickr.com): Ajax-enabled photo sharing.

• Fotki (www.fotki.com): Another Ajax-enabled photo-sharing site.

• Google Maps (maps.google.com): One of the Ajax applications that brought the tech-nique to the attention of developers the world over.

• Google Suggest (www.google.com/webhp?complete=1&hl=en): Probably the most famousexample of a type-ahead Ajax application.

APPENDIX B ■ LIBRARIES, WEBSITES, AND BOOKS, OH MY! 485

Page 8: The XMLHttpRequest Object - Springer978-1-4302-0189-2/1.pdfThe XMLHttpRequest Object M ... Some of the libraries out there—only a handful of which we talked about in this book—really

• Google’s GMail (gmail.google.com): One of the other great examples of Ajax usage fromGoogle.

• Google’s RSS reader (www.google.com/reader): A web-based RSS reader from Googleutilizing Ajax.

• iBiblio (www.ibiblio.org): iBiblio has a modest goal: to back up the entire Internet! Well,that might be exaggerating a bit, but it is billed as a public library and archives. Mostimportant for the purposes of this book is the Maven repository(www.ibiblio.org/maven) they maintain, where many of the most popular open sourcelibraries and toolkits can be downloaded automatically by Maven as well as Ant scripts.

• The JSON home page (http://json.org): All about JavaScript Object Notation (JSON).

• Mappr (www.mappr.com): An excellent example of a Flash site done well.

• MSNBC (www.msnbc.com): The website of the news channel MSNBC.

• Num Sum (www.numsum.com): An Ajax-based spreadsheet.

• OpenSymphony (http://opensymphony.com): An organization, along the lines of Apache,that supplies a number of open source products, including WebWork and XWork.

• PBase (www.pbase.com): Yes, yet another Ajax-enabled photo-sharing site.

• Prototype documentation by Sergio Pereira (www.sergiopereira.com/articles/prototype.js.html#Enumerating).

• Shadow Gallery (www.shadowgallery.com): One of the bands I have made reference to inthis book. Check them out—you’ll love them!

• Slashdot (www.slashdot.org): News for nerds, stuff that matters!

• Sun (http://java.sun.com): The place for all things Java.

• W3Schools (www.w3schools.com): An excellent all-around reference site for all thingsHTML. You can learn about CSS, HTML, DOM scripting, and even Ajax itself there.

• WebShots (www.webshots.com): Another Ajax-enabled photo-sharing site.

• Wikipedia (www.wikipedia.com): The free, online dictionary that everyone can helpmake better!

• Yahoo! (www.yahoo.com): One of the oldest search sites around; now they do just abouteverything.

Books• Beginning CSS Web Development: From Novice to Professional, by Simon Collison. An

excellent book to get your CSS knowledge up to snuff (Apress, 2006).

APPENDIX B ■ LIBRARIES, WEBSITES, AND BOOKS, OH MY!486

Page 9: The XMLHttpRequest Object - Springer978-1-4302-0189-2/1.pdfThe XMLHttpRequest Object M ... Some of the libraries out there—only a handful of which we talked about in this book—really

• Beginning JavaScript with Ajax and DOM Scripting: From Novice to Professional, byChris Heilmann. A great book for JavaScript and Ajax novices, with a slightly differentscope than Jeremy Keith’s book (Apress, 2006).

• Beginning XML with DOM and Ajax: From Novice to Professional, by Sas Jacobs.Another great web development book, showing how XML can be used effectively forweb applications, including DOM scripting and Ajax (Apress, 2006).

• CSS Mastery, by Andy Budd, with Simon Collison and Cameron Moll. If you’re alreadyfamiliar with CSS, then this book will take you up to the next level, with invaluable tech-niques and good practices (friends of ED, 2006).

• DOM Scripting: Web Design with JavaScript and the Document Object Model, by JeremyKeith. This book will give you a good grounding in DOM scripting (friends of ED, 2005).

• Pro Ajax and Java: From Professional to Expert, by Nathaniel Schutta and Ryan Asleson.A great companion book to the one you’re reading now, this book also looks at thefusion of Java and Ajax, but from a more technology/workflow perspective rather thanlooking at complete projects. It covers setting up the perfect development environ-ment, testing and debugging, using Ajax libraries, and understanding the Ajaxcapabilities of Java frameworks such as Spring and JSF (Apress, 2006).

APPENDIX B ■ LIBRARIES, WEBSITES, AND BOOKS, OH MY! 487

Page 10: The XMLHttpRequest Object - Springer978-1-4302-0189-2/1.pdfThe XMLHttpRequest Object M ... Some of the libraries out there—only a handful of which we talked about in this book—really

■Aabort() method, 481accessibility, 15account.js file, for The Organizer sample

webapp, 339AccountAction.java, for The Organizer

sample webapp, 346accountCreate() method, 343accountCreate.jsp file, for The Organizer

sample webapp, 330accountCreateOK.jsp file, for The

Organizer sample webapp, 330AccountDAO.java, for The Organizer

sample webapp, 343accountDelete() function, 339, 343accountEdit.jsp file, for The Organizer

sample webapp, 332AccountObject.java, for The Organizer

sample webapp, 341accountRetrieve() method, 343accountUpdate() function, 339, 343action mappings, AjaxChat and, 371Action.java, for PhotoShare sample

webapp, 301ActionContext object, 318, 346ActionDispatcher.java, for PhotoShare

sample webapp, 297ActionForm, 357–359, 369

DynaActionForm and, 371LobbyActionForm and, 384

Action class, WebWork and, 317, 346ActivityScroll.js file, for AJAX Warrior

sample webapp, 435Adaptive Path, 12addCollection() method, 293, 300, 303AddCollection.java, for PhotoShare

sample webapp, 301addCollection.jsp file, for PhotoShare

sample webapp, 276addCollectionDigester() method, 300

addPhoto() function, 293, 295AddPhoto.java, for PhotoShare sample

webapp, 303addPhoto.jsp file, for PhotoShare sample

webapp, 278AddressBookManager class, 182–187addRoom() method, 404addRows() function, 170addToInventory() method, 460addUser() method, 385addUserToRoom() method, 389, 404Adobe, 483Ajax (Asynchronous JavaScript and XML)

alternatives to, 27–30disadvantages of, 15pure, sample webapps and, 407–477URL for, 485way of thinking and, 14

<ajax:enable /> tag, 118<ajax:event> tag, 118<ajax:manual> tag, 206, 224Ajax object, 316<ajax:timer> tag, 206, 224AJAX Warrior sample application, 407–477

approach to building, 408–413client-side code for, 421–446displayed in action, 413enhancing, exercises for, 476maps/conversations and, 420sample Ajax function and, 409server-side code for, 446–476structure of, 417–421

AjaxChat sample application, 353–406approach to building, 354–365client-side code for, 370–383displayed in action, 365enhancing, exercises for, 406server-side code for, 383–405structure of, 367

AjaxChatConfig.java, for AjaxChat samplewebapp, 383

Index

489

Page 11: The XMLHttpRequest Object - Springer978-1-4302-0189-2/1.pdfThe XMLHttpRequest Object M ... Some of the libraries out there—only a handful of which we talked about in this book—really

AjaxChatDAO.java, for AjaxChat samplewebapp, 394–405

ajaxError() function, 337AjaxReader sample application, 203–253

client-side code for, 212–231displayed in action, 207exercises for, 253server-side code for, 231–253structure of, 211

ajaxRef attribute, 118ajaxRequestSender() function, 121, 134AjaxTags, 27, 115, 116–121

AjaxReader sample webapp and, 204API documentation for, 116

ajaxwarrior package, 446ajax_config.xml file, 118

for AjaxReader sample webapp,215–217

for Karnak sample webapp, 135–137alert() pop-ups, 16altRow variable, 169Amazing Karnak, 115anonymous functions, JavaScript and, 48Ant, 84–93, 483ant-dependencies, 90<antcall> task, 90Apache, 483Apache Jakarta Commons, 483Apache Software Foundation

Ant. See AntDigester, 107–111Geronimo, 97Tomcat, 93, 485

app-config.xml file, for AjaxChat samplewebapp, 372, 383

AppConfigContextListener, 370appConfigured variable, 162appendChild() method, 66applicationContext.xml file, for The

Organizer sample webapp, 327applications, 84–93, 96. See also sample

applicationsapplyElement() method, 66AppointmentAction.java, for The Organizer

sample webapp, 347–352AppointmentDAO.java, for The Organizer

sample webapp, 343

appointmentEdit.jsp file, for The Organizersample webapp, 333

appointmentList.jsp file, for The Organizersample webapp, 335

AppointmentObject.java, for The Organizersample webapp, 341

appointmentRetrieve() function, 339appointments.js file, for The Organizer

sample webapp, 339arrayIndex property, 275arrays, JavaScript and, 41arrow keys, 129, 132associative arrays, 256, 412assureUnique variable, 375assureUniqueGetMessages variable, 379AssureUniqueUsersInRoom variable, 379Asynchronous JavaScript and XML. See

AjaxAtom feeds, 204

■Bbackground-color style attribute, 80background style attribute, 80backslash (\), JavaScript and, 45Banfield, Steve, 14basedir attribute, 89battleEnemyMove() function, 446BattleEnemyMoveCommand.java, for

AJAX Warrior sample webapp, 466BattleFuncs.js file, for AJAX Warrior

sample webapp, 445battleMove() function, 445BattleMoveCommand.endBattle()

method, 467BattleMoveCommand.java, for AJAX

Warrior sample webapp, 464–466BEA’s WebLogic, 97, 483<bean:write> tag, 373beanPropertySetter rule, 295Berglund, Anders, 62Berners-Lee, Tim, 62bindArgs variable, 256<body> tag, 22booleans, JavaScript and, 46border style attribute, 80Bresenham line-drawing algorithm, 292

■INDEX490

Page 12: The XMLHttpRequest Object - Springer978-1-4302-0189-2/1.pdfThe XMLHttpRequest Object M ... Some of the libraries out there—only a handful of which we talked about in this book—really

browsers, 14cross-browser Ajax support and, 479event handlers and, 130XMLHttpRequest object and, 479

buttonsAndTabs.js file, for The Organizersample webapp, 329, 336, 338

■C<c:forEach> tag, 374<c:out> tag, 374, 378, 381<c:param> tag, 374<c:url> tag, 374, 377calcLine() function, 292calculateDamage() method, 465callback handler function, 25captureEvents() function, 130Carson, Johnny, 115Cascading Style Sheets. See CSScastSpell() function, 439CastSpell.js file, for AJAX Warrior sample

webapp, 439CastSpellCommand.java, for AJAX Warrior

sample webapp, 467Caucho’s Resin, 97, 483Chain of Responsibility (CoR)

implementation, 116charPickLocation() method, 450, 452, 466chat sample application. See AjaxChat

sample applicationcheckboxNumber variable, 162, 169checkGameWon() method, 460, 470checkName() function, 425class members, JavaScript and, 54classes directory, 98clean target, 89clearAttributes() method, 66clearHistory() function, 382client-side code

for AJAX Warrior sample webapp,421–446

for AjaxChat sample webapp, 370–383for AjaxReader sample webapp,

212–231for InstaMail sample webapp, 177–201for Karnak sample webapp, 125–134for PhotoShare webapp, 265–296for The Organizer sample webapp,

326–340

client-side scripting, classic webdevelopment and, 10

ClientSideGameState.java, for AJAXWarrior sample webapp, 456

cloneNode() method, 66close() method, 200Collapse Sidebar button, 209, 226collapseExpandSidebar() function, 226,

230Collection.js file, for PhotoShare sample

webapp, 281CollectionDTO.java, for PhotoShare

sample webapp, 298color style attribute, 80colors, CSS and, 76, 80comma-separated value (CSV), 62, 64Command.java, for AJAX Warrior sample

webapp, 463CommandResult.java, for AJAX Warrior

sample webapp, 463commands package, 446commands, for AJAX Warrior sample

webapp, 463–476comments, JavaScript and, 40Commons Digester, 68, 107, 243

AjaxChat sample webapp and, 384PhotoShare sample webapp and, 295,

299Commons FileUpload component, 201Commons Logging, 327, 385, 389commons-logging.properties file, for The

Organizer sample webapp, 327compareTo() method, 388compile target, 88configClass context parameter, 370configFile context parameter, 370ConfigInfo.java, for PhotoShare sample

webapp, 296configuration files, XML and, 63ContactAction.java, for The Organizer

sample webapp, 347–352ContactDAO.java, for The Organizer

sample webapp, 343contactEdit.jsp file, for The Organizer

sample webapp, 333contactList.jsp file, for The Organizer

sample webapp, 335

■INDEX 491

Find it faster at http://superindex.apress.com/

Page 13: The XMLHttpRequest Object - Springer978-1-4302-0189-2/1.pdfThe XMLHttpRequest Object M ... Some of the libraries out there—only a handful of which we talked about in this book—really

ContactObject.java, for The Organizersample webapp, 341

contacts.js file, for The Organizer samplewebapp, 339

context parameters, 100contextInitialized() method, 296, 462ContextListener.java

for AJAX Warrior sample webapp, 462for AjaxChat sample webapp, 369, 404for The Organizer sample webapp, 340

control.jsp file, for PhotoShare samplewebapp, 269–272

ControlEvents.js file, for PhotoSharesample webapp, 293–296

Conversation.js file, for AJAX Warriorsample webapp, 440

<convert> tag, 146CoR (Chain of Responsibility)

implementation, 116create() method, 346, 348Create, Retrieve, Update, Delete (CRUD),

340, 343, 346createBattleMap() method, 454createCharacter() method, 450, 466createDocument() function, 66createElement() method, 66createRolloverImages() function, 329, 336,

338createTable() method, 341createTextNode() method, 66CRUD (Create, Retrieve, Update, Delete),

340, 343, 346CSS (Cascading Style Sheets), 72–82

classic web development and, 10CSS Zen Garden, 78CSS/CSS2, 77cssFeedHover selector, 231cssInfoRowHeader, 269cssTextboxActive selector, 231CSV (comma-separated value), 62, 64currentCollection variable, 293currentSuggestion variable, 130currentView variable, 162, 172, 336cursor attribute, 80, 231

for AjaxReader sample webapp, 230for InstaMail sample webapp, 163for PhotoShare sample webapp, 272

custom handlers, 120CustomQueryString request handler, 130,

136CustomQueryString.js, 124

for Karnak sample webapp, 126–134

■DData Transfer Objects (DTOs), 357,

384–388data types, JavaScript and, 42–48database engines, HSQLDB and, 319dayAtAGlance.jsp file, for The Organizer

sample webapp, 331DayAtAGlanceAction.java, for The

Organizer sample webapp, 347decreaseChatScrollFontSize() function,

383default attribute, 87Delete Feed button, 217delete keyword, JavaScript and, 49delete() method, 346, 350<delete> task, 88deleteCollection() function, 294DeleteCollection.java, for PhotoShare

sample webapp, 304deleteContact() method, 175DeleteFeedServlet, 249–253deleteMessages() method, 172, 200deletePhoto() function, 294DeletePhoto.java, for PhotoShare sample

webapp, 306deleteTempFiles() method, 311dependency injection, 320depends attribute, 88description attribute, 88development environment, 83died.jsp file, for AJAX Warrior sample

webapp, 427Digester, 107–111Direct Web Remoting (DWR), 144–147, 484DirectX filters, 276display style attribute, 80, 230displayInventory() function, 439displayInventory.jsp file, for AJAX Warrior

sample webapp, 428, 468DisplayInventoryCommand.java, for AJAX

Warrior sample webapp, 467

■INDEX492

Page 14: The XMLHttpRequest Object - Springer978-1-4302-0189-2/1.pdfThe XMLHttpRequest Object M ... Some of the libraries out there—only a handful of which we talked about in this book—really

<div> tag, 23, 28CSS and, 74selector styles and, 77

Document Object Model. See DOMdoDelete() function, 172doesPlayerHaveSpell() function, 440doFilter() method, 462doGet() method, 102, 140, 462Dojo, 27, 254–258, 483

event handlers and, 257, 289Dojo packages, 255, 258dojo.connect() function, 257dojo.io package, 255dojo.io.bind() function, 255, 294DOM (Document Object Model), 22,

56–61DOM manipulation methods, 66DOM nodes, 56, 58doMonthView() function, 340doNewNote() function, 339doPost() method, 102, 462doRedirect() method, 462doRefreshHeadlines() function, 206, 229doScroller() function, 424doWeekView() function, 340downloads

Ant, 85JDK, 83projects in this book, 111Tomcat, 93

doYearView() function, 340drop shadows, 275dsSelectorChange() function, 340DTOs (Data Transfer Objects), 357,

384–388DWR (Direct Web Remoting), 144–147, 484dwr.xml file, InstaMail sample webapp

and, 145–147DynaActionForm, 357–359, 369, 371, 394

■EEclipse, 84editContact() function, 165EJB. See Enterprise JavaBeanselements, 117–120

adding to web.xml file, 117Elipse, 484

e-mail, webmail sample webapp and,143–201

enableButtons() function, 164endBattle() method, 466EndConversationCommand.java, for AJAX

Warrior sample webapp, 468Enter key, 131enterCommunity() function, 442EnterCommunityCommand.java, for AJAX

Warrior sample webapp, 468Enterprise JavaBeans (EJB), 17, 96escape sequences, JavaScript and, 45escape() function, 378, 382escapeXml() method, 390eval() function, 226event bubbling, 257event handlers, 119

browsers and, 130custom, 120Dojo and, 257, 289

events, 117–120exec() method, 462

BattleEnemyMoveCommand.java and,466

Command.java and, 464EndConversationCommand.java and,

468SwitchWeaponCommand.java and,

472ToggleTalkAttackCommand.java and,

474execute() method, 301, 318, 345Expand Sidebar button, 226Extensible Markup Language. See XML

■Ffat clients, 5

as alternative to Ajax, 30FeedDescriptor DTO class, 231feedForm, 224, 228feeds.properties file, 217, 236, 249filter package, 446<filter-mapping> tag, 101filters, 100finish() method, 462, 464firstColumn variable, 428Flash (Adobe), 483

as alternative to Ajax, 27

■INDEX 493

Find it faster at http://superindex.apress.com/

Page 15: The XMLHttpRequest Object - Springer978-1-4302-0189-2/1.pdfThe XMLHttpRequest Object M ... Some of the libraries out there—only a handful of which we talked about in this book—really

Flex (Adobe), 483Flickr, 253float-overs, 157, 168

PhotoShare sample webapp and, 272,290

font-family style attribute, 80font-size style attribute, 80font-style style attribute, 80font-weight style attribute, 80Form.serialize() function, 316<form> tag, 22ForwardAction.java, for The Organizer

sample webapp, 345Fotki, 253fraControl frame, 279frames

classic web development and, 10hidden, 28

framework package, 446FreeMarker, 484FrontServlet.java, for AJAX Warrior sample

webapp, 462fullTrim() function, 382functions, JavaScript and, 36, 48

■Ggame sample application. See AJAX

Warrior sample applicationGameCharacter.java, for AJAX Warrior

sample webapp, 456GameConversation.java, for AJAX Warrior

sample webapp, 457GameConversations.java, for AJAX Warrior

sample webapp, 457GameFuncs.js file, for AJAX Warrior

sample webapp, 441–445GameItem.java, for AJAX Warrior sample

webapp, 457GameMaps.java, for AJAX Warrior sample

webapp, 458GameMaps.loadMap() method, 462gameobjects package, 446gameState.getBattleCharacter() method,

467GameState.java, for AJAX Warrior sample

webapp, 459–461GameState.js file, for AJAX Warrior sample

webapp, 432

GameTalkNode.java, for AJAX Warriorsample webapp, 461

GameTalkReply.java, for AJAX Warriorsample webapp, 461

Garrett, Jesse James, 12, 485Generalized Markup Language (GML), 62Geronimo, 97, 483Getahead, 144getAllResponseHeaders() method, 481getAsString() method, 456getAsXML() method, 298, 300getAttribute() function, 230getBaseMapChunk() method, 448getBattleMap() method, 455getBodyContent() method, 470getCenterTile() method, 449getCheckbox() function, 169getChunk() method, 448, 469getCollection() method, 310getCollectionList() method, 309getConversation() method, 457getDescFromCode() method, 428, 447getElementById() method, 58getElementsByTagName() function, 381getHeight() function, 290getInboxContents() method, 168, 196getInstance() method, 299getItem() method, 452getMessages() function, 379getMessages() method, 388, 404GetMessagesAction.java, for AjaxChat

sample webapp, 388getMessagesDelay variable, 379getMessagesHandler() function, 381getNoteObject() method, 350getPlayerTile() method, 469getResponseHeader() method, 481getRoomList() method, 404getRoomsUserCounts() method, 389getRoomUserCounts() method, 404getSentMessagesContents() method, 197getSize() method, 304getUserList() method, 389, 404getWidth() function, 290getXXXX functions, 163getXXXXObject() method, 348

■INDEX494

Page 16: The XMLHttpRequest Object - Springer978-1-4302-0189-2/1.pdfThe XMLHttpRequest Object M ... Some of the libraries out there—only a handful of which we talked about in this book—really

global variables, 285, 336AJAX Warrior sample webapp and, 433

Globals.javafor AJAX Warrior sample webapp, 446for The Organizer sample webapp, 340

Globals.js filefor AJAX Warrior sample webapp, 429for PhotoShare sample webapp, 285

globals.js file, for The Organizer samplewebapp, 336

Gmail, 18GML (Generalized Markup Language), 62Goldfarb, Charles, 62Goodwin, Mark, 144Google, Ajax and, 19Google Suggest, 13, 115gotoAddressBook() function, 174gotoComposeMessage() function, 166gotoComposeReply() function, 166gotoHelp() function, 166gotoInbox() function, 166, 171gotoOptions() function, 175gotoSentMessage() function, 171, 173gotoSentMessages() function, 172gotoViewMessage() function, 172graphics, classic web development and, 10greeting.jsp file, for simple struts sample

application, 362Gregory, Andrew, 479growHeightStep variables, 292growImage() function, 292growWidthStep variable, 292

■HhadChildNodes() method, 66headerFile variable, 333height style attribute, 80help.htm file, for AJAX Warrior sample

webapp, 428hidden frames, 28

hideAllLayers() function, 164hidePleaseWait() function, 165, 290

hidePleaseWait() function, 290highlighting changed information, 16Hotmail, 18HSQLDB, 319, 341, 484

HTML (Hypertext Markup Language)as alternative to Ajax, 28classic web development and, 10, 62vs. CSS, 74

<html:link> tag, 363<html:messages> tag, 373<html:rewrite> tag, 376, 382HttpServlet class, 102Hypersonic SQL, 319Hypertext Markup Language. See HTML

■IiBiblio, 90IBM’s WebSphere, 97, 484IDE (integrated development

environment), 84IDs, 58if attribute, 90image preloads, 161, 227

PhotoShare sample webapp and, 271The Organizer sample webapp and,

329, 336ImageGrowing.js file, for PhotoShare

sample webapp, 292increaseChatScrollFontSize() function,

383index.htm file, for PhotoShare sample

webapp, 266index.jsp file

for AJAX Warrior sample webapp, 422,462, 471

for AjaxChat sample webapp, 373for AjaxReader sample webapp, 217–230for InstaMail sample webapp, 153,

158–161for Karnak sample webapp, 124for simple struts sample application,

360for The Organizer sample webapp, 329

index1.htm file, for PhotoShare samplewebapp, 267

inEvent parameter, 228info.jsp file, for PhotoShare sample

webapp, 268inheritance, JavaScript and, 53init target, 87, 89init() method, 102

■INDEX 495

Find it faster at http://superindex.apress.com/

Page 17: The XMLHttpRequest Object - Springer978-1-4302-0189-2/1.pdfThe XMLHttpRequest Object M ... Some of the libraries out there—only a handful of which we talked about in this book—really

init.js filefor AJAX Warrior sample webapp, 430for The Organizer sample webapp, 336

initConfigInfo() function, 296innerHTML property, 26insertBefore() method, 66InstaMail sample application, 143–201

client-side code for, 153–177displayed in action, 147–152enhancing, exercises for, 201HTTP servlet objects and, 187server-side code for, 177–201structure of, 152

instance members, JavaScript and, 54integrated development environment

(IDE), 84IntelliJ IDEA, 84, 484internationalization support, 370IoC (Inversion of Control), 320isAdd variable, 249isCharacterNoWalkTile() method, 453isItemSafeTile() method, 450, 453isItemTile() method, 453, 469isNoWalkTile() method, 453isTileAlreadyOccupied() method, 454isUsernameInUse() method, 404

■JJ2SE Development Kit (JDK), 83Jakarta Commons JARs, 90Jakarta Commons Logging (JCL), 327, 385,

389JAR files, 98

adding to webapps, 117for AJAX Warrior sample webapp, 419for AjaxChat sample webapp, 369for AjaxReader sample webapp, 212for InstaMail sample webapp, 153for Karnak sample webapp, 124for PhotoShare sample webapp, 264for The Organizer sample webapp, 325

<jar> task, 89, 92jarfile attribute, 89Java, 83, 96

vs. JavaScript, 34parsing XML in, 107–111

Java applets, as alternative to Ajax, 29Java Runtime Environment (JRE), 96

Java Web Parts (JWP), 116, 484Java Web Parts project, 68JavaBeans, 17, 96<javac> task, 89JavaScript, 34–56

disadvantages of, 55memory management and, 49object-oriented techniques and, 49–56parsing XML in, 64–72vs. Java, 34

JavaScript file, for Karnak sample webapp,126–134

JavaScript Object Notation (JSON), 407,411–413, 447

JavaServer Pages. See JSPsjavax.servlet.jsp.jstl.fmt.localization-

Context parameter, 370JCL (Jakarta Commons Logging), 327, 385,

389JDBC, 320JdbcTemplate class, 320, 343JDK (J2SE Development Kit), 83

Tomcat and, 94jEdit, 84, 484Jetty, 96, 484JoinRoomAction.java, for AjaxChat sample

webapp, 389JRE (Java Runtime Environment), 96JRun (Macromedia), 97, 484JSDigester, 68–72

PhotoShare sample webapp and, 295,299

JSLib library, 67, 484JSON (JavaScript Object Notation), 407,

411–413, 447JSP source files, for AJAX Warrior sample

webapp (list), 419JSPs (JavaServer Pages), 17, 104

for Karnak sample webapp, 125reasons for using/not using, 244rendering markup/XML and, 281

JSTL, 484JWP (Java Web Parts), 116, 484

■KKarnak sample application, 115–142

client-side code for, 125–134displayed in action, 121

■INDEX496

Page 18: The XMLHttpRequest Object - Springer978-1-4302-0189-2/1.pdfThe XMLHttpRequest Object M ... Some of the libraries out there—only a handful of which we talked about in this book—really

exercises for, 142server-side code for, 134–142structure of, 123

KarnakServlet class, 124KarnetServlet.java file, 124, 137–142keyCodePressed variable, 129, 142keyDown() function, 130KeyHandler.js file, for AJAX Warrior sample

webapp, 438keyUp() function, 438keywords, JavaScript and, 38

■LlastClickedLink variable, 227, 230lastDateTime attribute, 388layerCenterH() function, 423, 432layerCenterV() function, 432leaveRoom() method, 382LeaveRoomAction.java, for AjaxChat

sample webapp, 389left style attribute, 80lib directory, 98libraries, 26, 483

AjaxTags. See AjaxTagsDWR, 144–147Prototype, 315

linkClicked() function, 230, 244list() method, 329, 348, 350listAppointments() method, 344listCollections() function, 290ListCollections.java, for PhotoShare sample

webapp, 308listCollections.jsp file, for PhotoShare

sample webapp, 279, 290listener package, 446listeners, 100ListFeedsServlet, 237ListHeadlinesServlet, 239–244listTasks() method, 344ListUsersInRoomAction.java, for AjaxChat

sample webapp, 389listUsersInRoomDelay variable, 379listUsersInRoomHandler() function, 380literal values, JavaScript and, 41loadCollection() function, 294LoadCollection.java, for PhotoShare

sample webapp, 309

loadCollection.jsp file, for PhotoSharesample webapp, 280

loadHandler() function, 29loadImage() function, 285loadMap() method, 458loadPhotoImages() function, 283lobby.jsp file, for AjaxChat sample

webapp, 374–378LobbyAction.java, for AjaxChat sample

webapp, 389LobbyActionForm.java, for AjaxChat

sample webapp, 384lobbyUpdateStatsDelay variable, 375lobbyUpdateStatsHandler() function, 376locateDDValue() function, 336logging, The Organizer sample webapp

and, 327<logic:messagesPresent> tag, 373LoginAction.java, for AjaxChat sample

webapp, 390–393logoff() function, 337LogoffAction.java, for The Organizer

sample webapp, 346LogonAction.java, for The Organizer

sample webapp, 345LogoutAction.java, for AjaxChat sample

webapp, 393logUserId() method, 404logUserOut() method, 404Lorie, Ray, 62Losher, Ed, 62

■M<macrodef > task, 90Macromedia’s JRun, 97, 484MailDeleter class, 173, 197–201MailRetriever class, 191–197MailSender class 173, 188–191main.jsp file

for AJAX Warrior sample webapp, 425for PhotoShare sample webapp,

272–276for simple struts sample application,

360for The Organizer sample webapp, 330

mainContent ID, 331mainframes, 4

■INDEX 497

Find it faster at http://superindex.apress.com/

Page 19: The XMLHttpRequest Object - Springer978-1-4302-0189-2/1.pdfThe XMLHttpRequest Object M ... Some of the libraries out there—only a handful of which we talked about in this book—really

Make, 85make_jar target, 89manual event, 206, 217, 224MapHandler.java, for AJAX Warrior sample

webapp, 447–455Mappr, 27margin attributes, 81Maven, 484Maven iBiblio repository, 90McMahon, Ed, 115mergeAttributes() method, 66<message> tag, 64MessageDTO.java, for AjaxChat sample

webapp, 384method attribute, 318misc.js file

for PhotoShare sample webapp,287–290

for The Organizer sample webapp, 337<mkdir> task, 88Model-View-Controller (MVC), 320mouse events

AJAX Warrior sample webapp and, 425AjaxReader sample webapp and, 239handlers for, 162PhotoShare sample webapp and, 257The Organizer sample webapp and,

331, 338moveCharacters() method, 453, 476MVC (Model-View-Controller), 320

■Nname attribute, 88naming conventions, for JavaScript, 37, 39NoteAction.java, for The Organizer sample

webapp, 347–352noteCreate() function, 339NoteDAO.java, for The Organizer sample

webapp, 343noteDelete() function, 339noteEdit.jsp file, for The Organizer sample

webapp, 333noteList.jsp file, for The Organizer sample

webapp, 335NoteObject.java, for The Organizer

sample webapp, 341noteRetrieve() function, 339

notes.js file, for The Organizer samplewebapp, 339

noteUpdate() function, 339null data type, JavaScript and, 46numbers, JavaScript and, 42numSuggestions variable, 130, 141

■Oobject initializers, JavaScript and, 41object-oriented JavaScript, 49–56Object-Relational Mapping (ORM), 320objectCreate rule, 295offsetHeight, 228oldUserListHTML variable, 379onClick event handler, 226, 239

The Organizer sample webapp and,331, 336

onLoad event handler, The Organizersample webapp and, 336

onreadystatechange property, 25, 482onSubmit handler, 225Open In New Window button, 209, 226open() method, 25, 481OpenEJB, 96, 484openInNewWindow() function, 226OpenSymphony, 255, 317openWindow() function, 267opResponse.jsp file, for The Organizer

sample webapp, 332OptionsManager class, 145, 177–182<option> tag, 22Organizer. See The Organizer sample

applicationORM (Object-Relational Mapping), 320overflow style attribute, 81

■Ppadding style attributes, 81page-scoped variables, 374, 379, 423<param-name> tag, 100<param-value> tag, 100parseInt() function, 446PBase, 253personal information manager (PIM)

sample application, 313–352Photo.js file, for PhotoShare sample

webapp, 283

■INDEX498

Page 20: The XMLHttpRequest Object - Springer978-1-4302-0189-2/1.pdfThe XMLHttpRequest Object M ... Some of the libraries out there—only a handful of which we talked about in this book—really

PhotoDTO.java, for PhotoShare samplewebapp, 298

PhotoShare sample application, 253–312client-side code for, 265–296displayed in action, 258enhancing, exercises for, 312server-side code for, 296–312structure of, 262

PhotoShareDAO.java, for PhotoSharesample webapp, 299

pickUpItem() function, 409–411, 442PickUpItemCommand.java, for AJAX

Warrior sample webapp, 469PIM (personal information manager)

sample application, 313–352placeCharacter() method, 448placeCharacters() method, 450placeItems() method, 448Please Wait float-over, 157, 164, 168

PhotoShare sample webapp and, 272,290

pleaseWait ID, 331PleaseWait.js file, for PhotoShare sample

webapp, 290polymorphism, 49POP3, 143port 8080, 147position style attribute, 81postedDateTime, 388postMessage() function, 382, 387, 404PostMessageAction.java, for AjaxChat

sample webapp, 394previousSuggestion variable, 129Prototype, 27, 315, 339

$() function and, 336website for, 484

proxyHost parameter, 214, 243proxyPort parameter, 214, 243purchaseItem() function, 436PurchaseItemCommand.java, for AJAX

Warrior, 470push() method, 435queryForList() method, 343

■QQueryString request handler, 130

■RreadObject() method, 471readystate, 24, 482Really Simple Syndication (RSS), 203reconstitute() function, 432, 456Refresh Headlines button, 226, 228removeAllRows() function, 168removeCharacter() method, 450, 466removefromInventory() method, 460removeInactiveUsers() method, 394, 404removeItem() method, 453, 470removeNode() method, 67removeRoom() method, 404removeUser() method, 404removeUserFromAllRooms() method, 404removeUserFromRoom() method, 389,

404repeat() method, 455replaceNode() method, 67replyGetInboxContents() function, 166,

168request attributes, 105request handlers, 119Request() function, 316, 339reserved words, JavaScript and, 38resetLandingPad() function, 290resetScroller() function, 423resetVars() function, 290Resin (Caucho), 97, 483resources for further reading, 483–487

Bresenham line-drawing algorithm, 292CSS, 78DirectX filters, 276DOM scripting, 59JSON, 413Spring, 321W3C Schools, 82

response handlers, 119responseText property, 482responseXML property, 482retrieve() method, 346, 348retrieveContact() method, 187retrieveMessage() function, 197retrieveMethod() method, 172retrieveOptions() method, 176, 181Return key, 131

■INDEX 499

Find it faster at http://superindex.apress.com/

Page 21: The XMLHttpRequest Object - Springer978-1-4302-0189-2/1.pdfThe XMLHttpRequest Object M ... Some of the libraries out there—only a handful of which we talked about in this book—really

RIAs (Rich Internet Applications), 17, 27rollover effects

AjaxReader sample webapp and, 225,227

The Organizer sample webapp and,329, 331, 336, 338

rolloverImages variable, 329, 336ROME (Rss and atOM utilitiEs) library,

204, 243, 484room.jsp file, for AjaxChat sample

webapp, 378–383RoomDTO.java, for AjaxChat sample

webapp, 384–387rooms-config.xml file, for AjaxChat

sample webapp, 372rotate() method, 311rotateArrayDown() function, 283rotateArrayUp() function, 283rotatePhoto() function, 294RotatePhoto.java, for PhotoShare sample

webapp, 310rowClass custom attribute, 163RSS (Really Simple Syndication), 203Rss and atOM utilitiEs (ROME) library,

204, 243, 484RSS feed reader sample application,

203–253RSS feeds, 203

■Ssample applications, 19

AJAX Warrior, 407–477AjaxChat, 353–406AjaxReader, 203–253downloading, 111InstaMail, 143–201Karnak type-ahead suggestions,

115–142PhotoShare, 253–312The Organizer, 313–352

Sarissa, 72, 484Save Feed button, 216saveContact() method, 174SaveErrors() method, 394SaveFeedsServlet, 244–249saveGame() function, 442SaveGameCommand.java, for AJAX

Warrior sample webapp, 470

saveOptions() function, 176, 182SAX (Simple API for XML), 67, 109sax.js file, 67scope, JavaScript and, 36<script> tag, 37script.js file, for InstaMail sample webapp,

152, 161scroll bars, 423scrollChatFontSize variable, 379<select> tag, 22semicolon (;), JavaScript and, 40send() method, 25, 481sendAJAX() function, 409–411, 434, 436SendAJAX.js file, for AJAX Warrior sample

webapp, 434sendAjaxRequest variable, 375sendMessage() method, 173, 190serialize() function, 432, 443server-based technologies/techniques,

83–112server-side code

for AJAX Warrior sample webapp,446–476

for AjaxChat sample webapp, 383–405for AjaxReader sample webapp,

231–253for InstaMail sample webapp, 177–201for Karnak sample webapp, 134–142for PhotoShare webapp, 296–312for The Organizer sample webapp,

340–352service-oriented architecture (SOA), 314servlet filters, 100<servlet-mapping> tag, 101<servlet> tag, 101servlets, 102session attributes, 105SessionCheckerFilter.java

for AJAX Warrior sample webapp, 462for AjaxChat sample webapp, 370, 405

setAttackMode() method, 474setAttribute() function, 67, 230setDimensions() function, 285setFreezeTime() method, 467setGreenKeymaster() method, 452setImmobile() method, 451setInCommunity() method, 469setMessage() method, 301, 303

■INDEX500

Page 22: The XMLHttpRequest Object - Springer978-1-4302-0189-2/1.pdfThe XMLHttpRequest Object M ... Some of the libraries out there—only a handful of which we talked about in this book—really

setNext rule, 295setPassword() method, 318setProperties rule, 295setRedKeymaster() method, 452setRequestHeader() method, 481setShadowActualSize() function, 290setShadowDefaultSize() function, 290, 293setupSidebarButtons() function, 338setUsername() method, 318setValidating() function, 300setXXXX functions, 163SGML (Standardized Generalized Markup

Language), 62shadows, 275shift() function, 435showAppointments() function, 340ShowCastSpellCommand.java, for AJAX

Warrior sample webapp, 470showDayAtAGlance() function, 336showFeedHeadlines() function, 226, 228,

239showGameEnd() function, 439showHelp() function, 439showMapView() function, 439showMyAccount() function, 339showNodeReplies() function, 440showNotes() function, 339showPleaseWait() function, 164, 290, 337showProjectile() function, 445showScreen() method, 297showSecondaryView() function, 439showSpellCasting() function, 439showStore() function, 436, 445ShowSwitchWeaponCommand.java, for

AJAX Warrior sample webapp, 470showVars()function, 37showView() function, 165showWeaponSwitching() function, 439Simple API for XML (SAX), 67, 109Simple Mail Transfer Protocol (SMTP), 143SimpleLog, 327simplelog.properties file, for The Organizer

sample webapp, 327SMTP (Simple Mail Transfer Protocol), 143snapImageToLandingPad() function, 293SOA (service-oriented architecture), 314SomeWebapp directory, 98

spellCasting.jsp, for AJAX Warrior samplewebapp, 428

Spring Framework, 485Spring JDBC, 320SQLExceptions, Spring JDBC and, 321Standardized Generalized Markup

Language (SGML), 62StartGameCommand.java, for AJAX

Warrior sample webapp, 471startOnLoad attribute, 206startScroller() function, 424startTalking() function, 440StartupConfigurator.java, for PhotoShare

sample webapp, 296StartupServlet, 234status property, 482statusText property, 482std:CodeExecutor response handler, 216

DeleteFeedServlet and, 252SaveFeedsServlet and, 249

std:IFrameDisplay response handler, 217std:SimpleRequest handler, 217std:SimpleXML request handler, 216stopScroller() function, 423stopTalking() function, 440store.jsp file, for AJAX Warrior sample

webapp, 429StoreFuncs.js file, for AJAX Warrior sample

webapp, 435strings, JavaScript and, 43Struts, 101, 253, 353–365

WebWork and, 317, 319Struts Action Framework, 485struts sample application, sequence of

events and, 364struts-config.xml file, 328

for AjaxChat sample webapp, 371for simple struts sample application,

356style attributes, 73, 77styles.css file, 75

for AJAX Warrior sample webapp, 426for AjaxChat sample webapp, 383for AjaxReader sample webapp, 230for InstaMail sample webapp, 155–157for Karnak sample webapp, 126for The Organizer sample webapp, 329

■INDEX 501

Find it faster at http://superindex.apress.com/

Page 23: The XMLHttpRequest Object - Springer978-1-4302-0189-2/1.pdfThe XMLHttpRequest Object M ... Some of the libraries out there—only a handful of which we talked about in this book—really

subView variable, 336swapNode() method, 67switchContents() function, 423switchMap() method, 449, 469SwitchWeapon.js file, for AJAX Warrior

sample webapp, 440SwitchWeaponCommand.java, for AJAX

Warrior sample webapp, 472

■TTableDAO.java, for The Organizer sample

webapp, 341tabsButtonsEnabled variable, 329, 336taglib declaration, 117talkReply() function, 440TalkReplyCommand.java, for AJAX Warrior

sample webapp, 472targetFunc() function, 333targets, 87TaskAction.java, for The Organizer sample

webapp, 347–352TaskDAO.java, for The Organizer sample

webapp, 343taskEdit.jsp file, for The Organizer sample

webapp, 333taskList.jsp file, for The Organizer sample

webapp, 335TaskObject.java, for The Organizer sample

webapp, 341tasks, 88tasks.js file, for The Organizer sample

webapp, 339text color definitions, in CSS, 76The Organizer sample application, 313–352

client-side code for, 326–340displayed in action, 321enhancing, exercises for, 352server-side code for, 340–352structure of, 324

this keyword, JavaScript and, 51timer event, 206, 217, 224timerGetMessages variable, 379timerListUsersInRoom variable, 379timerLobbyUpdateStats variable, 375TN3270 screens, 4toBufferedImage() method, 311toggleTalkAttack() function, 441

ToggleTalkAttackCommand.java, for AJAXWarrior sample webapp, 474

Tomcat, 93, 485tools, 26, 483

Ant. See AntCommons Digester, 68, 107Digester, 107–111Geronimo, 97jEdit, 84JSDigester, 68–72Make, 85Maven iBiblio repository, 90Sarissa, 72Tomcat, 93, 485UltraEdit, 84XML4Script, 72

top style attribute, 81toString() method, 341, 383, 454, 457touchingCharacter() method, 454, 476try, catch block, 244TSO/ISPF, 4type-ahead suggestions sample

application, 115–142

■UUDDI directories, 17UIs (user interfaces), web development

history and, 3–9UltraEdit, 84, 485undefined data type, JavaScript and, 46unescape() function, 378unique resource locators (URLs), as style

attributes, 77update() method, 346, 349updateActivityScroll() function, 435, 438,

443updateCharacters()function, 22updateCollection() function, 290updateCollections() function, 280updateCollectionsList() function, 277updateMap() function, 434, 438, 441UpdateMapCommand.java, for AJAX

Warrior sample webapp, 474updatePics() function, 295updatePlayerInfo() function, 441Updater() function, 316, 337URLs (unique resource locators), as style

attributes, 77

■INDEX502

Page 24: The XMLHttpRequest Object - Springer978-1-4302-0189-2/1.pdfThe XMLHttpRequest Object M ... Some of the libraries out there—only a handful of which we talked about in this book—really

user interfaces (UIs), web developmenthistory and, 3–9

UserClearerDaemonThread.java, forAjaxChat sample webapp, 388,394, 404

UserDTO.java, for AjaxChat samplewebapp, 388

users, Ajax advantages for, 16Utils.java, for AJAX Warrior sample

webapp, 447Utils.js file, for AJAX Warrior sample

webapp, 432Utils.writeJSON() method, 463, 469

■VvalidateNote() function, 339variables

JavaScript and, 36for vertical scroll bars, 422

Vars.js file, for AJAX Warrior samplewebapp, 432

Velocity, 485ViewChangeFuncs.js file, for AJAX Warrior

sample webapp, 438viewState variable, 227visibility style attribute, 81vs_ prefixing vertical scroll bar variables,

422vs_container_height variable, 424vs_contents_height variable, 424vs_contents_top variable, 424vs_milliseconds variable, 424vs_pause variable, 425vs_scroll_speed variable, 424

■WW3C (World Wide Web Consortium), 63<ww:else>, 332<ww:form>, 330<ww:if>, 330<ww:iterator>, 332<ww:property>, 330, 332<ww:select>, 335<ww:submit>, 330<ww:textfield>, 330Walker, Joe, 144

<war > task, 92weaponSwitching.jsp file, for AJAX Warrior

sample webapp, 429Web 2.0, 17web browsers. See browsersweb development, 3–12web services, 17WEB-INF directory, 98web.xml file, 98

for AjaxChat sample webapp, 370for AjaxReader sample webapp, 212elements, adding to, 117for InstaMail sample webapp, 153for Karnak sample webapp, 134for PhotoShare sample webapp, 265for The Organizer sample webapp, 326

webapps. See also sample applicationsdeploying, Tomcat and, 95JAR files, adding to, 117pure Ajax and, 407–406, 477structure of, 96–102vs. web sites, 9

webapps directory, 95WebLogic (BEA), 97webmail sample application, 143–201Webshots, 253websites

list of, 485vs. webapps, 9

WebSphere (IBM), 97, 484Webstyle (Xara), 485WebWork, 317, 345, 485

Dojo and, 255WebWork tags, 330, 332, 335webwork.properties file, for The Organizer

sample webapp, 327welcome file, 101whatItem variable, 333whatOp variable, 333whichButton attribute, 226, 230whitespace, JavaScript and, 39width style attribute, 81World Wide Web Consortium (W3C), 63writeCollectionsFile() method, 300writeJSON() method, 447writeObject() method, 470

■INDEX 503

Find it faster at http://superindex.apress.com/

Page 25: The XMLHttpRequest Object - Springer978-1-4302-0189-2/1.pdfThe XMLHttpRequest Object M ... Some of the libraries out there—only a handful of which we talked about in this book—really

■XXandor, AJAX Warrior sample webapp

and, 407Xara’s Webstyle, 147, 485xhr variable, 24xhr.clearXHRVars() function, 435, 445XhrGetMessages variable, 379xhrListUsersInRoom variable, 379xhrLobbyUpdateStats variable, 375XHRObject.js file, for AJAX Warrior sample

webapp, 433XML (Extensible Markup Language), 62–72

disadvantages of, 64Java, parsing in, 107–111

JavaScript, parsing in, 64–72SAX, parsing in, 67

XML4Script, 72, 485xmlDoc variable, 67XMLHttpRequest object, 24, 479–482

JavaScript, parsing XML and, 65xwork.xml file, for The Organizer sample

webapp, 328xxxList() method, The Organizer sample

webapp and, 343

■Zz-index style attribute, 81, 274<zip> task, 91

■INDEX504