Latest

Loading...

Friday, December 2, 2011

Information Architecture and Faceted Navigation in SharePoint 2010

SharePoint 2010 has new features included (such as Taxonomy, Document Sets) and search improvements (such as Refiners). This has brought in a whole lot of changes to the thought process related to information architecture.

In MOSS 2007, we dealt with a linear guided navigation. SPS2010 improvements and new features introduced faceted navigation. It is also referred as faceted search or (free form) guided navigation. The faceted search presents users with a list of relevant suggestions for refining the search results by document type, site, author, modified date, tags etc.

Information architecture is the key in designing the content management systems, knowledge management portals, e-Commerce sites and so on. Consider below points while deciding on Information architecture.

• Content Roll up: Using Content Query web part, relevant and related content can be made available on content pages, document set welcome pages etc. Content Query web part has few improvements related to managed metadata (taxonomy) columns. Read here what’s new in content query web part.
• Refiners: This is a key to faceted search. The refinement web part can be used to narrow the search results.
• Extensibility of Search Web part: SPS 2010 has search web parts which can be extended. In MOSS 2007, these web parts are sealed. Scenario based search functionality can be extended and used on various pages, document set pages.

I have listed here few of the points. There are many features in SPS 2010 which we can exploit for the better information architecture and good navigation providing better user experience.
Few links about faceted search and information architecture.
Building Information Architecture in SPS 2010
Faceted Navigation
How Microsoft is leveraging the features in Infopedia and Microsoft Academy Mobile
Case Study: Microsoft Infopedia

Tuesday, August 2, 2011

SharePoint: Site Columns and Content Types

There are various posts on the internet describing the site columns and content types. In this post I am co-relating these with concepts of objects and classes. This will help the developer visualize these concepts differently.

Content and Object

Object has data. Class provides the set of attributes to detail the object instances.

Content is data. Content has two categories: Structured and Unstructured.

Content comprises of documents and list items. Content does not include list or library itself. List or library helps user to organize the content.

Structured content is the one which separates its storage from its display. e.g. List Items can be sorted/filtered and viewed in List web part or data row in a SQL data table.

Unstructured content is the one which cannot be viewed separately the format in which they are stored. e.g. Word document cannot be viewed without the MS Office Word.

Content type provides the set of attributes to define the metadata about content. The attributes are provided in the form of columns/fields in the list or at the site level.

Site Column

When the column is defined at site level, it is a site column. The site column is reusable across all lists and libraries in the site.

This is very similar to have property declared in an interface and will be available across all objects implementing the interface.

Content Type

Content type is a set of site columns. The site column helps in describing the content. The content type can be used across the lists and libraries in the site.

This is just like a complex data type. The data types/ classes has properties to describe the object.

Wednesday, April 13, 2011

Document Library Creation with Specific Document Template Using Server Object Model

Introduction: There is no way in SharePoint UI to create a document library with blank Excel/PowerPoint document template. But it is possible to create a document library with such document templates programmatically.

Technicalities:
I will first take you through the classes involved in development.


  • SPListCollection

  • SPListTemplateType

  • SPListTemplate

  • SPDocTemplate


SPListCollection has Add method with 7 overloads. Look for the method signatures here.



We will concentrate on the following signature:



public virtual Guid Add(
string title, //Title for the library
string description,//Description about the library
SPListTemplate template,//The list template. We are interested in Document Library.
SPDocTemplate documentTemplate //The document template for library.e.g. Excel, Word or Powerpoint etc.
)

SPListTemplateType is a enumeration. The enumeration has underlying integer values which match the Type attribute of ListTemplate element. Please visit here for details.


SPListTemplate represents the list definition or list template for the list. The list definition/template has the views and fields defined. SPWeb.ListTemplates returns the list definitions for the web site. SPSite.GetCustomListTemplates method returns the list template collection for the site collection. More details.



SPDocTemplate represents the document template. Whenever we create a document library, it is created by using blank Word Document template. There are many document templates available in SharePoint 2010 OOB. The document templates have IDs. The ID is used to filter the document template collection presented by SPWeb.DocTemplates property. Document Template IDs list follows:












Document Template IDDescription
101A blank Microsoft Word 97-2003 document.
103A blank Microsoft Excel 97-2003 document.
104A blank Microsoft PowerPoint 97-2003 document.
105A blank Microsoft basic page ASPX document.
106A blank Microsoft Web Part Page ASPX document.
111A basic Microsoft OneNote 2010 Notebook.
121A blank Microsoft Word document.
122A blank Microsoft Excel document.
123A blank Microsoft PowerPoint document.


Code:

using (SPSite site = new SPSite(serverUrl)) {
using (SPWeb web = site.OpenWeb()) {
SPListTemplate lstTemplate = web.ListTemplates["Document Library"];
SPDocTemplate docTemplate =(from SPDocTemplate dt in web.DocTemplates
where dt.Type == 122
select dt).FirstOrDefault();
Guid newLibID =
web.Lists.Add("Expense Claims", "Excel Expenses", lstTemplate, docTemplate);
SPDocumentLibrary newLib = web.Lists[newLibID] as SPDocumentLibrary;
newLib.OnQuickLaunch = true;
newLib.Update();
}
}



The code is for console application.(I know you are aware, just for clarity).

Saturday, June 12, 2010

Visibility Of Quick Launch Bar in Web Part Page of SP2010

Introduction:
Web part pages are usually have only web part zones for web parts. They lack the quick launch navigation bar.
In MOSS 2007, it was easy to have web part pages with quick launch by tweaking few lines in the page.

Team Site:
I used the same technique to show quick launch in web part page of SP Server 2010 publishing portal site. But it did not work for me. I googled for the same but was helpless.



While working on some other site collection with a team site, I created a web part page & I found few additional CSS statements blocking the visibility of quick launch. I modified the line & wow, it worked there. I detailed the steps below for the same.
Step I:
Open the web part page in SharePoint Designer 2010. Comment the following lines.




Step II:
Scroll up & locate the below shown lines.

Modify the line and set the display to ‘block’.



That’s it. It worked for me.


Publishing Portal:
Then I used same technique at the publishing portal. But it did not work there. Again, I googled specific to Publishing Portal and again without relevant search results.



Then I started going through the page source and found that the CSS line, which I modified, is inside a VersionedContentPlaceHolder with an ID as “WebPartPageHideQLStyles”.



I just commented it and it worked for me.

Saturday, April 10, 2010

SharePoint 2010 - Silverlight Client Object Model

Introduction:

Recently, I worked on a project based on SharePoint 2010 Beta. While providing solution to client, we came across Silverlight Client Object Model (OM). Microsoft SharePoint Foundation 2010 has it as part of new Client API.


As it is new to us, few questions come to our mind: How to use it? What are the basic steps to make it work? What objects, properties and methods available for use? We dig out the answer for the same & made use of it in our project successfully. I’m not the only one to have such questions, hence this post. Hope this will help others also.


Silverlight Client OM helps us develop client-side solutions. To use Silverlight Client OM, one needs to refer two DLL files (assemblies) in the application: Microsoft.SharePoint.Client.Silverlight.dll and Microsoft.SharePoint.Client.Silverlight.Runtime.dll. The assemblies are located on SharePoint Server machine at “C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS\ClientBin” folder.


To start coding, one must add “using” statement for Microsoft.SharePoint.Client namespace. This core namespace provides types and members for working with SharePoint site-collection, sites, list data, and security. The Client API does not provide any admin objects or objects with scope higher than site collection.


All client objects inherit Microsoft.SharePoint.Client.ClientObject class & collections are inherited from Microsoft.SharePoint.Client.ClientObjectCollection class.

Client Object and Value Object:

All types, inheriting from ClientObject class, are referred as client objects whereas types, inheriting from ClientValueObject class, are value objects. Value objects have only properties & no methods. Do not conflict with Value Type concept of .NET Framework.

Scalar Property:

Property, returning value object is referred as scalar property.

Frequently Used Types:



All these types belong to “Microsoft.SharePoint.Client” namespace. “ClientContext” is the central object to gain access to Client OM.

Initializing Client Context:

ClientContext object requires the URL of site as a parameter to the constructor.


e.g. ClientContext context=new ClientContext(“http://www.somesite.com/”);


Silverlight web part when host the Silverlight application, they pass the URL of site as a initialization parameter (InitParams) to the application.


Properties of ClientContext:





PropertyDescription
SiteRetrieves site-collection associated with current context
WebRetrieves context specific site.
CurrentStatic property representing current context object.


By using these properties, one can access client objects up to the site-collection level.

Methods of ClientContext:
Below are the three important methods of ClientContext.




MethodDescription
LoadUsed to load the query for the action.
LoadQueryUsed to load the LinQ query & to perform queryable load. (see below)
ExecuteQueryAsyncUsed to send the query to the server. This is an asynchronous operation.



Client Objects do not have associated data until data retrieval is performed. Data retrieval is done using the Load & Execute methods of ClientContext. Data retrieval can be executed in two ways: In-place load & queryable load.


Queryable load uses “LoadQuery” method of context object & returns enumerable generic collection. It means, retrieved data goes to result collection. It does not load the data in the object itself.


In-place load uses “Load” method of context & loads data to client objects. That means, retrieved data will be loaded to client objects.


LinQ has two forms of data projection syntax: query syntax & method syntax. “LoadQuery” should be used when using query syntax. For method syntax, either of the load methods works. LinQ in Client OM is LinQ-to-Object.


Once the query is loaded to the context, use ExecuteQueryAsync method to send the action query to server to get data. ExecuteQueryAsync has two parameters as delegate objects: ClientRequestSucceededEventHandler & ClientRequestFailedEventHandler.

ClientRequestSucceededEventHandler specifies the method to be executed after successful completion of ExecuteQueryAsync whereas ClientRequestFailedEventHandler invokes method on failure of query execution.

Steps for Data Retrieval

1. Get ClientContext object.
2. Specify the object to retrieve data using object model.
3. Load the object either using in-place load or queryable load.
4. Execute the query.
5. Write code to process object in a method which will execute after successful invocation query.

Data Retrieval Example:




using System;
using Microsoft.SharePoint.Client;

namespace Example.Silverlight.ClientOM
{
ClientContext context;
Web site;

public MainPage()
{
InitializeComponent();
}

private void Button_Click(object sender, RoutedEventArgs e)
{
context = ClientContext.Current;
site = context.Web;

context.Load(site,website=>website.Title);

context.ExecuteQueryAsync(OnSuccess, null);
}
private void OnSuccess(object sender, ClientRequestSucceededEventArgs e)
{
MessageBox.Show(“Site Title:”+site.Title);
}
}



I know that this post requires few more examples. But due to time-constraint it is not possible. I'll update the post with few more samples and updates in few days. So visit again!!!

Friday, November 20, 2009

Sorting List of Custom Objects

“System.Collections” and “System.Collections.Generic “ namespaces have classes for collections. Collection objects are the specialized objects which can hold multiple objects of other classes. Other classes also refer to collection classes along with non-collection classes. The two different namespaces have non-generic and generic versions of collection classes.
My discussion is focusing on the ArrayList collection class. This discussion also covers the generic version “List<T>"class.

What is ArrayList?
ArrayList is a non-generic collection class. Object of this class can hold list of homogeneous objects. Homogeneous objects means objects of any class (data type). This collection may not have necessarily objects of same type.

ArrayList grows dynamically with addition of new objects. It does not have any fixed length. Initially, empty ArrayList object has capacity of 0 objects. As we add first object, the capacity grows to hold 4 objects. When we add the fifth object, it grows by double to hold 8 objects in it. ArrayList capacity doubles when its capacity is crossed.

List<T> is just the generic version of ArrayList. Generic collection object can have objects of same type only.

Sorting:

ArrayList and List have the sort method already implemented. This sort method works very well for primitive system data types (e.g. int, long etc.). But what about the user-defined types (viz. Class, Struct,Enum)? To order the objects you should know how to compare them. How to acquaint .NET Framework about comparing user-defined data types?


public class Person
{
public string Name;
public int Age;
}
List<person> plist=new <Person>();
… //Add few person objects.
plist.Sort();

Consider we’ve the list of person objects. How sorting will happen, based on Name or Age? What it’ll compare (name or age of persons)? Try it.


Comparison of Person object is possible only if we implement IComparable or IComparer interface. The IComparable interface has single method, CompareTo. See the code below with IComparable interface implementation.


public class Person : IComparable //Change it to IComparable<Person>
{
public string Name;
public int Age;

#region IComparable Members
//Argument will be of Person type if IComparable<Person> is //implemented.
public int CompareTo(Object obj)
{
Person p=obj as Person //Not required if generic IComparable implemented.
return this.Name.CompareTo(p.Name);
}
#endregion
}

IComparable interface has generic variant, IComparable<T> interface. The CompareTo method of IComparable<T> takes object of T as argument. So type-casting of argument is avoided.


Now it’ll sort the Person list with respect to their names. What if we’d like to have the sorting by Age? Change the code.


What if we’d like to have sorting by Age as well as by Name? Then IComparable interface implementation is not sufficed. We’ve to create two implementations (classes) of IComparer interface : NameComparer and AgeComparer. IComparer interface has Compare method accepting two objects. Cast the objects to appropriate type & then compare. Generic version of IComparer is IComparer<T> can be implemented in similar way. It avoids need of type-casting.


NameComparer will have implementation of Compare method based on Name whereas AgeComparer will have implementation based on Age. These classes will not have any other code.


Sort method overload accepts object of IComparer implementation (class) as argument. If our requirement is to compare by Age use object of AgeComparer, or else NameComparer for alphabetical sorting.


public class NameComparer : IComparer
{
#region IComparer Members

public int Compare(object x, object y)
{
Person p = x as Person;
Person q = y as Person;
return p.Name.CompareTo(q.Name);
}

#endregion
}
public class AgeComparer : IComparer
{
#region IComparer Members

public int Compare(object x, object y)
{
Person p = x as Person;
Person q = y as Person;
return p.Age.CompareTo(q.Age);
}

#endregion
}

plist.Sort(new AgeComparer());

That’s all folks!!! Reuse the .NET functionality.

Tuesday, November 3, 2009

Response.Redirect and Server.Transfer

Response.Redirect:

Response is the object which accumulates the HTML/Javascript for the page requested. Each response has an associated Request object. Request object has the information about HTTP request headers and request body. Request body contains posted parameters.



I've used Web Developer helper tool to show you the details of HTTP Request & Response. HTTP request is comprised of HTTP command(e.g. GET,POST HEAD etc.) alongwith HTTP Headers (e.g. User-Agent) and the request body,if any. Request body appears only if user is posting some selections / values back to HTTP server. Diagram (1) shows you the details of HTTP Request.


The image below shows the GET Request body.



The images below show the POST request with Request body





If Response.Redirect is used to change the page to be shown, there is no access method available to access the posted values on second page. The reason : Response.Redirect involves round-trip to redirect the browser to new page. Browser redirection to new page has new request. Request body of first request of the round-trip lost unprocessed.



Response.Redirect helps to redirect to different server. Page on test.com can be redirected to google.com.



In essence, Response.Redirect involves one round-trip with two different requests. Response.Redirect loose the first-request body. Use Response.Redirect to redirect the browser to some page of different server. For same server, my suggestion is to use hyperlink or Server.Transfer.


Server.Transfer:

Server object represents the server processing request. Server.Transfer cannot transfer to the page of different server. Server.Transfer does not involve any round-trip. Request body is available to new page (of same server)as no round-trip involves.