Flylib.com

Books Software

 
 
 

- page 29


Summary

In this chapter, we learned the basics of Web Part development as well as advanced Web Part concepts including Editor Parts, Verbs, asynchronous tasks , and connections. We learned the difference in development patterns for WSS Web Parts versus the traditional ASP.NET programming model. At this point, you should be able to write your own Web Parts by using customizable and personalizable properties, connect them using the site context in your Web Parts, and use aggregated controls and asynchronous methods . You also should know how to manipulate Web Parts on Web Part Page instances using SharePoint’s site object model. In the next chapter, we will take these fundamental techniques and learn how to create a rich Internet client interface by using the ASP.NET AJAX framework.



Chapter 5: AJAX Web Parts

Overview

  • Understand the fundamentals of AJAX programming.

  • Learn how to program with the ASP.NET AJAX Framework.

  • Learn how to program and consume a service-oriented API by using XML data streams and Web services.

  • Implement AJAX components within Web Parts.

  • Use the SharePoint AJAX Toolkit to create rich Internet applications on the WSS platform.



Introduction

ASP.NET AJAX is the newest addition to ASP.NET 2.0 and is a supported Microsoft framework for next -generation Web development using AJAX technologies. AJAX is shorthand for “Asynchronous JavaScript + XML,” an approach to Web applications that utilizes asynchronous data requests from the page with a client-side JavaScript engine. It is not one technology, but rather a combination of technologies that enables rich-client responsiveness in the browser when used together. It’s also not a new technology, but rather a new trend that combines old technologies in a new way. The technologies include object-oriented JavaScript, asynchronous data requests utilizing the XMLHttpRequest object, XML data streams, Extensible Stylesheet Language Transformation (XSLT) transforms, and dynamic manipulation of the HTML Document Object Model (DOM). It more closely resembles a recipe for Web applications than a single architecture-it is an approach to Web applications based on rendering and manipulating data in smaller components during the page’s life cycle in response to user actions on the client rather than the processing of the entire page as a whole. Because of this design pattern, Web Parts make an excellent deployment mechanism for AJAX components in Microsoft Windows SharePoint Services (WSS), and many of the built-in WSS APIs can be leveraged in JavaScript code from the browser.

The main benefit of using AJAX techniques in Web applications is an increased level of responsiveness once possible only in rich-client applications. Instead of waiting for a page reload or form post to update the user interface, the browser can send a discrete call to the server by using the XmlHttpRequest object while enabling the user to continue working.

A callback method on the client is then used to handle the Web request when it is completed. Compared to traditional applications, AJAX applications typically make smaller and more frequent data requests, loading data as needed rather than performing large data transfers up front. Figure 5-1 displays the traditional WSS page life cycle, in which the entire page is reprocessed as the user interacts with the data. In this traditional model, the page is requested and sent to the client as a whole. Upon page refresh, all required data must be reprocessed and resent , making data manipulations and navigation a disruptive activity. If multiple Web Parts exist on the page, each Web Part must be refreshed during the page request/response cycle. There is also significant overhead in the WSS page itself that would ideally be processed only once per user context rather than on each user interaction.

image from book
Figure 5-1: The traditional WSS Web page life cycle

{% if main.adsdop %}{% include 'adsenceinline.tpl' %}{% endif %}

In contrast to the traditional processing model, the AJAX approach to WSS programming includes a client runtime based on the ASP.NET AJAX Library, custom controller components patterned after the Model View Controller design pattern, and service-oriented XML data sources. Figure 5-2 illustrates the dynamic nature of the AJAX approach. Instead of one fat data stream being processed in the main request/response, individual components are responsible for their processing and can be individually refreshed and updated in response to user actions, events, or timer components. The user interface and data streams could also evolve over the client life cycle of the page-new components can be spawned from additional data sources and loaded into new components, all without reloading or posting the Web page. The Web page life cycle is much longer in an AJAX application because the page is not refreshed after the initial page load.

image from book
Figure 5-2: The AJAX WSS Web page life cycle

Utilizing the ASP.NET AJAX Framework in WSS and Microsoft Office SharePoint Server allows you to take advantage of AJAX technologies and methods while using a tested and supported framework that is fully integrated with ASP.NET 2.0. Before we learn how to deploy AJAX components in Web Parts, we will first look at AJAX architecture patterns and examine an AJAX application outside of the WSS context.