introduction to client object model development l.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Introduction To: Client Object Model Development PowerPoint Presentation
Download Presentation
Introduction To: Client Object Model Development

Loading in 2 Seconds...

play fullscreen
1 / 28

Introduction To: Client Object Model Development - PowerPoint PPT Presentation


  • 213 Views
  • Uploaded on

Introduction To: Client Object Model Development. March 20, 2009 SharePoint Saturday Neil Iversen. http ://justaddcode.com/blog. The Plan. Introduction  You are here SharePoint 2010 Developer Overview. What is the Client Object Model Working with the COM .NET Silverlight

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Introduction To: Client Object Model Development' - Jimmy


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
introduction to client object model development

Introduction To: Client Object Model Development

March 20, 2009

SharePoint Saturday

Neil Iversen

http://justaddcode.com/blog

the plan
The Plan
  • Introduction  You are here
  • SharePoint 2010 Developer Overview
slide3

What is the Client Object Model

  • Working with the COM
    • .NET
    • Silverlight
    • Javascript
  • Questions
what s a client object model
What’s a Client Object Model?
  • Run code against SharePoint…only remotely
  • Its like a Web Service call, only prettier
  • Why use it?
    • ‘No Code’ solutions
    • Fancy AJAX
    • Rich Internet Applications (RIA)
    • Integrate with WinForm/WPF Apps
    • (Potentially) Get around Solution Limits
so how s it work
So, how’s it work?
  • You use its .dll/.js
  • It bundles your calls
  • It calls a web service
  • You get pretty objects back
client object model runs on remote machine
Client Object ModelRuns on Remote Machine
  • Simple API to Add, Retrieve, Updateand Manage Data in SharePoint
  • Commands batched for Performance

SharePoint Data

Consistent

Efficient

Client Application

.NET CLR

Silverlight CLR

JavaScript

what s the big advantage
What’s the big advantage?
  • Uses calls similar to the Server Object Model (aka ‘The Object Model’
  • Compared to the eye-blinding XML for the web services
getting started where am i
Getting Started – Where Am I?
  • ClientContext
    • Sets up the Environment your calls will be in
    • The Web you’ll be working with
      • Web and SilverLight have a Current context
      • .NET Requires you to specify a location
    • AuthenticationMode
      • Uses currently logged in User by default
      • Set to FormsAuth
    • Example:

clientContext= new ClientContext(“http://myurl”);

  • web = clientContext.Web;
retrieving items
Retrieving Items
  • Item Collections can be retrieved by ‘calling’ them
    • web.Lists
  • LINQ is available for some objects
    • var query = from l in web.Lists where l.Title = “Tasks”
    • Not everything is Enumerable
      • There is no list.Items
  • CAML is preferred for ListItems
    • CamlQuery object
nothing happened
Nothing Happened!
  • Everything is async
  • Nothing happens until you clientContext.ExecuteQuery
  • But first you need to tell it the objects to Load
      • clientContext.Load(lists)
know when to load them
Know when to Load them
  • Two methods for getting data: Load and LoadQuery
  • Load
    • Loads an instance of an object
  • LoadQuery
    • Returns a collection of objects
    • Can return multiple levels of objects (parent.child.child)
    • Can be more memory efficient
why can t i see all my fields
Why can’t I see all my fields?
  • SharePoint is trying to conserve resources
  • It only brings back what it has to
  • Use Include to override this behavior
    • Load(myLists, lists=>lists.Include(list =>list.Title,list=>list.Author)
    • Or
    • Load(myLists, “Include(Title,Author)”)
adding a new item
Adding a new Item
  • ListItemCreationInformation
    • Sets the context for the Add
  • collection.Add(listItemCreationInformation)
    • Returns Item
    • Ex: ListItem item = list.Add(lici)
  • Then
    • item.Update()
    • clientContext.ExecuteQuery()
updating an item
Updating an Item
  • Item.Update!
    • clientContext.ExecuteQuery()
deleteing an item
Deleteing an Item
  • Item.DeleteObject
    • clientContext.ExecuteQuery()
ecmascript object model
ECMAScript Object Model
  • Commonly called ‘javascript’ by humans
  • Requires:
    • MSIE 7+
    • Firefox 3.5+
    • Safari 4.0+
  • Needs SP.js to be loaded
    • <SharePoint:ScriptLinkrunat="server" Name="sp.js" Localizable="false" LoadAfterUI="true" />
  • Stored in /LAYOUTS
    • SP.js – SP.debug.js
async what
Async what?
  • Javascript and SilverLight only have async web calls
  • This means you’ll get your results…sometime
  • Line 1
  • WS Call
  • Line 3
  • Line 1
  • WS Call
  • Line 3
silverlight
SilverLight
  • Probably the funnest of the options
  • Give you rich visualization options
  • Has Client Object Model like JS/.NET
how about something you can use
How about something you can use?
  • Auto Complete a list item
  • We’ll use jQuery and a plugin conveniently called ‘autocomplete’
  • 3 Components
    • Get the Context, List and run the ‘All Item’s query
    • Bind the Autocomplete Data
    • Bind the Result Action
a note about wp7
A Note about WP7
  • Currently the SilverLight Client Object Model doesn’t run against WP7
  • WP7 currently doesn’t support Active Directory authentication with Web services
  • Forms Authentication is currently the only way to access SP content from the phone
thanks
Thanks!

Neil Iversen

Inetium

http://justaddcode.com