TAILIEUCHUNG - Developing Large Web Applications- P23

Developing Large Web Applications- P23:This book presents a number of techniques for applying established practices of good software engineering to web development—that is, development primarily using the disparate technologies of HTML, CSS, JavaScript, and server-side scripting languages. Whereas there are many books on how to use languages, how to use libraries, and how to approach software engineering, this is the first book to codify many of the techniques it presents. These techniques will make the components of your own web applications more reusable, maintainable, and reliable | In the context of Ajax models manage Ajax connections and store the resulting data. Views are notified of those changes and update themselves by modifying the parts of the DOM for which they are responsible. A good granularity for views is to make them correspond to modules see Chapter 7 . Interestingly MVC is also helpful for DHTML applications that don t use Ajax but have other dynamic aspects to manage. The only difference is that changes to the model happen as a result of local data changes rather than from making an Ajax connection. Using Ajax with MVC To better understand how MVC specifically aids Ajax applications let s look at a basic example for testing simple Ajax requests managed using MVC. In this example we ll use one model TestModel to which two views are subscribed. Each view is an instance of TestView. For simplicity the model manages a single piece of data a timestamp that can be set via the server using an Ajax request or locally within the browser. Whenever the time is updated either from the server or locally each view updates itself to reflect the new timestamp in the model. The implementation consists of three classes shown in their entirety in this chapter built on top of some libraries provided by YUI. Naturally you can create the same basic structure using other JavaScript libraries. Figure 8-1 shows the user interface for this application. The shaded area at the top of the figure is the first view the shaded area at the bottom is the second. The lighter area in the middle is a control panel that contains several buttons that let you initiate various actions. In addition to the basic actions for making an Ajax request or local JavaScript call to set the time the application lets you experiment with several other features such as handling communication failures data failures timeouts aborted requests and collisions between concurrent requests. The following provides more detail about each of the actions in the application. Figure 8-1. An .

Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.