Minneapolis Office Developer Interest Group (MODIG)

Download Report

Transcript Minneapolis Office Developer Interest Group (MODIG)

Minneapolis Office Developer Interest
Group (MODIG)
December 10, 2009
Client Object Model Development
Neil Iversen
http://sharepointmn.com/modig
The Plan


Introduction
 You are here
SharePoint 2010 Developer Overview
User Group Goals



Provide a community for SharePoint Developers
Share development knowledge
Exchange tips/tricks/other/free pizza
User Group Format

Presentations



Presentations are good
Demos are better
QA/Discussion/Random Things
Sharepointmn.com/modig/


Our current home
Meeting information



Usually has the right time
Previous presentations
Running on SharePoint

As required by SharePoint
User Group Law
Upcoming

Next Meeting




Jan 26, 2010
Topic: TBD
Location: Where you are
MNSPUG


Jan 12 (9:00am – Noon)
Topic : Composite Applications in SharePoint 2010
Events of Note


SharePoint 2010 in Wider Availability
SharePoint 2010 Developer Center

http://msdn.microsoft.com/en-us/sharepoint/ee514561.aspx


What is the Client Object Model
Working with the COM




.NET
Silverlight
Javascript
Questions
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?




You use its DLL
It bundles your calls
It calls a webservice
You get pretty objects back
Client Object Model
Runs on Remote Machine


Simple API to Add, Retrieve, Update
and Manage Data in SharePoint
Commands batched for Performance
SharePoint Data
Consistent
.NET CLR
Efficient
Silverlight CLR
JavaScript
Getting Started – Where Am I?

ClientContext


Sets up the Environment your calls will be in
The Web you’ll be working with



AuthenticationMode




Web and SilverLight have a Current context
.NET Requires you to specify a location
Uses currently logged in User by default
Set to FormsAuth
Example:
clientContext = new ClientContext(txtUrl.Text);
web = clientContext.Web;
Retrieving Items

Item Collections can be retrieved by ‘calling’ them


LINQ is available for some objects


web.Lists
var query = from l in web.Lists where l.Title = “Tasks”
CAML is preferred for ListItems

CamlQuery object
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)
Why can’t I see all my fields?



SharePoint is trying to conserve resources
It only brings back what it has to
Use Load to override this behavior



Load(myLists, lists=>lists.Include(list
=>list.Title,list=>list.Author)
Or
Load(myLists, “Include(Title,Author)”)
Demo - .NET Client Object Model
Adding a new Item

ListItemCreationInformation


collection.Add(listItemCreationInformation)



Sets the context for the Add
Returns Item
Ex: ListItem item = list.Add(lici)
Then


item.Update()
clientContext.ExecuteQuery()
Updating an Item

Item.Update!

clientContext.ExecuteQuery()
Deleteing an Item

Item.DeleteObject

clientContext.ExecuteQuery()
Demo - .NET CRUD
ECMAScript Object Model


Commonly called ‘javascript’ by humans
Requires:




Needs SP.js to be loaded


MSIE 7+
Firefox 3.5+
Safari 4.0+
<SharePoint:ScriptLink runat="server" Name="sp.js"
Localizable="false" LoadAfterUI="true" />
Stored in /LAYOUTS

SP.js – SP.debug.js
Demo – Javascript Demo
SilverLight



Probably the funnest of the options
Give you rich visualization options
Has Client Object Model like JS/.NET
Demo – SilverLight Demo
Questions?
Next Meeting

Topic / Time Selection




Client Model – Deeper Dive
Web Part Development
PowerShell
BCS
Random Stuff
Feedback Forms
Mingle, Eat, Feedback
See you next time!
Neil Iversen
Inetium
http://justaddcode.com