Client Side Object Model

advertisement
SharePoint 2010
Client Side Object Model
Agenda
•
Introduction
•
The Problem
•
Client side vs Server Side
•
Client Side Object Model
–
–
–
–
How it works
What can it do?
Limitations
Possibilities
•
REST Interface
•
Demonstration – REST + CSOM
•
Questions
Introductions
• Who am I?
• Who are you?
• “Customisation Possibilities”
The Problem
• SharePoint does so much!
• But not exactly what I want 
• I know – I’ll customise it!
The Problem
• Custom development
– Too Risky ?
• Data issues?
– Too Expensive ?
• Initial development
• Maintenance
• Upgrade?
• More often than not, custom development requires
installation of components on the Server
– Promotion through environments
– Time and costs associated with downtime
The Problem
Customise!
The Problem
$@#%$*&!
The Problem
• A lot of organisations simply don't allow server side coding
• A lot of hosting situations don’t allow server side coding
– BPOS / Office 360 / SharePoint Online
– Web Central
– Shared Tenancy / Security Issues
• Team based SharePoint development rarely performed
– TFS
– Proper Build Servers
Client side vs Server Side
Server Side
Client side
Client side vs Server Side
Server Side
Client Side
• Code running on server
• Can use SharePoint object
model directly
• Code running on client
computer
• Can only interact with
SharePoint via web services
• Requires installation on
server
• Hard to do anything of any
complexity
Client side vs Server Side
Server Side
Designer *
Web Part Development
Generic Feature Development
UI Menu Feature Development
SharePoint Event Handlers
Custom Web Services
Custom Field Types
Custom Page Development / Code behind
Custom Windows Applications / Utilities
Branding / Design
User controls
Workflows
Advanced configuration
…
Custom STSADM commands
Business Connectivity Services (BCS)(2010)
InfoPath Forms
Custom Timer Jobs
Custom Workflows / Custom Workflow Actions
Client side vs Server Side
Client Side
?
Client side vs Server Side
• So previously the ‘real’ client side options were:
– Web Services
• Very low level
• A bit complex (security)
– Scripts on page
• Mainly for UI change (hiding fields, UI improvements)
• “Can call web services” – yuck
• VB can do some interesting things
– SharePoint designer modifications
• OK – if you don’t delete everything
• Customisations not as portable as would like
• Know your boundaries!
Client side vs Server Side
• Some client side work-arounds got quite popular:
– JPoint – series of JavaScript functionality in web parts
– HTML Calculated column –using the ‘calculated column’ to
conditionally output HTML
– JavaScript web-service libraries – still yuck
What’s New Already?!
• SharePoint 2010 has two major areas of functionality in this
area
1.
Client Side Object Model (CSOM)
2.
REST Services
Client Side Object Model
16
Client Side Object Model
• In a nutshell - the client side object model provides an ‘object
model’ to client technologies
– .Net Applications
– Silverlight
– JavaScript (
)
• Each of these have a separate .dll to work with, but have very
similar code
Client Side Object Model
• Each of these have work with the Client web-service under
the hood to provide the functionality on the server
CSOM
Client Side Object Model
Client Side Object Model
• Example - Delete List ( .net ):
Client Side Object Model
• Example - Delete List ( JavaScript ):
Client Side Object Model
Demo – CSOM
Client Side Object Model
• JavaScript?
–
–
–
–
–
–
Yes – JavaScript
SharePoint 2010 Ribbon
Custom Links
Content Editor Web Parts
Added into Forms pages for lists and libraries
Scriptlets
Client Side Object Model
Demo – JS
Client Side Object Model
• Security
– Windows Credentials by Default
– Can use Forms Authentication
– Permission level setting
Client Side Object Model
Tips and Tricks?
– Minimise what you need to retrieve
–
–
–
–
Know what is loaded in context and what isn’t…
Beware of IQueryable with ListItem
JavaScript only has a-sync calls…. Ouch
Use the JavaScript “Item Table”
• Holds data for the current item context
Summary
• Before
– Client side coding was very difficult
– Either via web services or very limited in functionality
• After
–
–
–
–
–
Client side coding much easier
“Object Model” - like coding on the server
Similar for JavaScript, Silverlight, .Net Applications
Don’t need to develop on the server!
New Possibilities with Rest and the CSOM
Reading:
Using the SharePoint Foundation 2010 Managed Client Object Model
http://msdn.microsoft.com/en-us/library/ee857094.aspx
Managed Client Object Model
http://msdn.microsoft.com/en-us/library/ee537247.aspx
Common Programming Tasks
http://msdn.microsoft.com/en-us/library/ee537013.aspx
Praveen Battula
http://praveenbattula.blogspot.com/
Questions?
Download