apress comet and reverse ajax, the next-generation ajax 2.0 (2008)

142 304 0
apress comet and reverse ajax, the next-generation ajax 2.0 (2008)

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

[...]... Comet and Reverse Aiax firstPress 13 We won't run through the entire codebase of the Magnetic Poetry appHcation in detail here; you'll just cover the basic CRUD methods The full source code is available from the Source Code/Download link on the Apress web site, and we want to get back to the topic at hand in pretty short order 14 firstPress Comet and Reverse Ajax Creating New Words The user of the appHcation... box on the left provides a drop-down form that allows users to add new words to the workspace and specify the text and the color When first created, each word will be placed randomly on the workspace Users position words (those they create themselves or those created by others—^there's no permissions system!) using drag and drop Finally, users can remove words from the 12 firstPress Comet and Reverse. .. it will affect other users' views of the model, as illustrated in Figure 1-4 Figure l-A: Mixing conventional Ajax and Reverse Ajax in a collaborative application 8 firstPress Comet and Reverse Max The sequence of events in this situation combines conventional Ajax HTTP calls with reverse Ajax When one user submits an update, in a clientinitiated exchange, the server may decide that other clients need... creating the drag -and- drop features We've chosen to send data between the client and server using the JavaScript Object Notation (JSON) format, because Grails and Prototype both support it very well and because it is simple to use We also cheated and read the rest of this book first, so we know that the Comet community is standardizing on JSON for the Bayeux protocol, which we discuss in Chapters 6 and 7 Comet. .. at the same time You'll see the implementation details of our application in more detail as we proceed For now Figure 2-1 presents a screenshot of the application Comet and Reverse Ajax firstPress 11 j Figure 2 - 1 User interface of the magnetic poetry application The UI of the application is fairly simple The shared workspace on which the words appear occupies the majority of the screen space The. .. that Comet can be made to work Before starting to look at the technical details, we should perhaps ask why you're considering Comet at all As you'll see in Chapter 2, there are several technical ways to address the problem, and you need to understand the nature of the problem correctly in order to pick the most suitable solution Why, then, should you want the server to be able to contact the client? There... receive that update immediately Reverse Ajax is then used to communicate these updates You don't always need Comet to deal with this situation If the urgency of communicating the changes to the other users is low, you can simply wait for them to refresh their views and issue a waming if they try to commit updates that are no longer appropriate Altemately, you may elect to notify them by an alternate route,... resort to Comet In Chapter 3, you'll move on to look at simple implementations of Comet itself If you want to really understand Comet, then you'll need to evaluate the alternatives and recognize the situations in which Comet is the best solution The Magnetic Poetry Application As you're starting to delve into the nitty-gritty aspects of coding at this point, an example application would be useful The application... Figure 2-1, the user supplies the text and color for the word, and the word's initial position is randomly allocated by the client The server will return a JSON expression that evaluates to an object that contains the full set of data for our new word, including the database ID You can use this to define a client-side word object that then renders itself onscreen using Prototype's DOM helper and string... () in the callback function that you pass to the al Aj ax Request () when you create i t Comet and Reverse Ajax firstPress 21 This function also introduces the change that you need to make to your domain model and to the data you send in the request and response When you ask the server for updates, it needs to know how much you already know In a very naive implementation, you could send all the information . firstPress Comet and Reverse Ajax Comet and Reverse Ajax: The Next-Generation Ajax 2. 0 by Dave Crane and Phil McCarthy This is a small book about a big subject. As a technology, Ajax was. within the web development community and to provide a name for it. To understand the phenomenon of Comet and Reverse Ajax, we need to consider why there is a need for it and why it is so out of the. Are Comet and Reverse Ajax? The term " ;Comet& quot; was coined by Alex Russell of the Dojo project to describe exchanges between a client and a server in which the server, rather than the

Ngày đăng: 27/03/2014, 13:34

Từ khóa liên quan

Mục lục

  • cover-large.tif

  • front-matter.pdf

  • fulltext.pdf

  • fulltext_2.pdf

  • fulltext_3.pdf

  • fulltext_4.pdf

  • fulltext_5.pdf

  • fulltext_6.pdf

  • fulltext_7.pdf

  • back-matter.pdf

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan