Book Image

Microsoft SharePoint 2010 Developer's Compendium: The Best of Packt for Extending SharePoint

Book Image

Microsoft SharePoint 2010 Developer's Compendium: The Best of Packt for Extending SharePoint

Overview of this book

The SharePoint platform is ideal for developers looking to build exciting solutions, and SharePoint 2010 is more equipped than ever for the task. While plenty of SharePoint titles will help you understand general SharePoint development techniques or spend time focusing on one method or tool, "Microsoft SharePoint 2010 Developer's Compendium: The Best of Packt for Extending SharePoint" offers you the option of using four different tools and platforms to achieve exceptional end user experience. This book fills the gap for a comprehensive SharePoint title which describes the end goal of a SharePoint developer. So often books focus on development techniques for one tool; this will get you on your way to developing a good business website with a great user experience, however, you choose to get there, be it using PowerShell, Visual Studio, Silverlight, Windows 7 Phone, or a combination of all four. "Microsoft SharePoint 2010 Developer's Compendium: The Best of Packt for Extending SharePoint" draws from five separate titles from Packt's existing collection of excellent SharePoint titles: Microsoft SharePoint 2010 and Windows PowerShell 2.0: Expert Cookbook Microsoft Silverlight 4 and SharePoint 2010 Integration Microsoft SharePoint 2010 Development with Visual Studio 2010 Expert Cookbook Microsoft SharePoint 2010 Enterprise Applications on Windows Phone 7 Microsoft SharePoint 2010 Business Application Development Blueprints "Microsoft SharePoint 2010 Developer's Compendium: The Best of Packt for Extending SharePoint" is an exciting mash-up of five existing Packt SharePoint titles for extending development techniques. It begins with two never before seen Packt chapters from an exciting new title, giving you a quick overview of the options available for extending SharePoint. It then moves on quickly to building a community site and discusses PowerShell scripting, as well as integrating Silverlight animations and helping you get to grips with SharePoint development on Windows Phone. With this book in hand you won't just find techniques for one development tool, you'll learn how to reach your end goal of developing a site with great user experience using a number of options at your fingertips.
Table of Contents (15 chapters)
Microsoft SharePoint 2010 Developer's Compendium: The Best of Packt for Extending SharePoint
Credits
About the Contributors
www.PacktPub.com
Preface

Client-side development


Client-side development can be leveraged to provide rich, dynamic content and experiences. With Client-side development all of the code runs from the client which in most cases is the end user's web browser. The code is written in a scripting language like JavaScript, ECMAScript, or in the case of Silverlight, using XOML and references script libraries instead of server based objects.

There are two common options for interacting with SharePoint from client-side solutions; the Client Object Model and jQuery.

Client Object Model

The Client Object Model (Client OM) is an application programming interface that supports extensive, but not full interaction with the SharePoint configuration and data. It was added with the SharePoint 2010 release to provide an easy way to interact with SharePoint configuration and data without the need for code deployed to the server. It puts a simple wrapper around the previously discussed web services simplifying the interaction and removing the need to create and parse the XML needed to interact with the Web services. The client-side code can be called from Silverlight, ECMAScript, or via your .Net code.

The Client OM can be used to include the Ajax enabled features allowing content and data refreshes or loads without the need for a page post back which reloads or redirects the page.

The Client OM is limited in that it cannot connect or perform calls outside of the site context that it is called from. This means that it cannot be used for cross-site calls or aggregating content from multiple web applications or site collections.

There are also some functions available in the Server OM that are not supported in the Web services and therefore not supported in the Client OM due to security boundaries.

Frequently Used Objects and Collections include:

Object

Description

ClientContext

Represents current Context, and is used as the main entry point for interacting with the Client OM.

Site

Represents a Site Collection

Web

Represents a Web or Sub-site

WebCollection

Represents the collection of Webs within the Site Collection

List

Represents a List or Library

ListCollection

Represents the collection of lists within the Site Collection

ListItemCollection

Represents the items within a list or library

Field

Represents a single field

FieldCollection

Represents the collection of fields

ListItem

Represents a single list item

Good candidates for Client OM solutions include:

  • Modular visualizations or content, similar to a web part

  • Enhancing DataForm Web Parts

  • Silverlight solutions

  • Page level customizations and enhancements

Using jQuery

The jQuery library (http://jquery.com/) can be leveraged to support client-side development and Ajax enabled functions. This JavaScript based library is completely cross-browser compliant and offers a rich set of selectors and advanced support for animations that can be used to provide a much richer interface than static HTML. This library is completely platform independent, and there is nothing SharePoint specific about this library. Since there are a number of Ajax methods that make it easy to consume web services, you can use the library to interact with SharePoint through its web services.

In its base format, you would need advanced knowledge of all of SharePoint's web services. To help simplify the development effort the SPServices library (http://spservices.codeplex.com/) was created to provide a wrapper around SharePoint's web services. This library was created in the Sumer of 2009 originally for the SharePoint 2007 version, but it is also fully functional with SharePoint 2010. While it conceptually offers the same functionality as the Client OM, it could be used for solutions that need to be backward compatible with 2007 or in cases where there is a SPServices method not supported in the current Client OM.

Good candidates for jQuery Solutions include:

  • Modular visualizations or content, similar to a web part

  • Enhancing DataForm Web Parts

  • Page level customizations

Deploying and managing client-side customizations

There are a number of ways to deploy and manage client-side code inside of SharePoint. You can add it directly to your SharePoint page using a tool like SharePoint Designer, or you can add it to a container such as the Content Editor Web Part that is included with each of the SharePoint versions. In cases where you use the Content Editor Web Part, you also have the option of linking to your content or script stored in any network accessible location.

It is important to consider how changes and versions will be managed. If you are adding code and functionality to pages, you should have versioning configured for the library the pages are in, as well as any libraries used to store your scripts. This will allow you to compare versions or to recover a prior version if things go wrong.

Many environments have very strict change management or deployment guidelines for any code that is deployed to the server by administrators. One of the big advantages to the client-side development approach is that system users with appropriate access can deploy their customizations themselves without the involvement of the administrators or change control group. This typically means that customizations can be created and deployed very quickly without all of the formality needed for the more advanced customizations. While there is some risk that a defective customization will cause an error or unexpected results, the impact is typically localized to the page the customization is used on or the content it interacts with.