SharePoint Blogs / SharePoint University
SharePoint Blogs and SharePoint University - all in one place!
Need SharePoint Training? Attend a SharePoint Bootcamp!

Please delete cookies related to sharepointblogs.com and sharepointu.com to resolve login issues!

Sharepoint Solution Syntax Part 2

INTRODUCTION

Continuing from my previous post http://www.sharepointblogs.com/tommysegoro/archive/2008/09/14/sharepoint-solution-syntax.aspx I will discuss further on the syntax required for creating other elements of Sharepoint. In my previous posting, I've mentioned to you about how to create site definition, master pages, page layouts, content types and fields using feature. In this posting, I will mention about creating web parts, event receivers and feature receivers.

 

WEB PARTS

To create web parts you will need the following structure:

 

Inside HelloWorldWebPart.webpart you have:

<webParts>
<
webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
<
metaData>
<
type name="WSPBuilder.WebParts.HelloWorldWebPart, WSPBuilder, Version=1.0.0.0, Culture=neutral, PublicKeyToken=6109cdf7233db6c5" />
<
importErrorMessage>Cannot import this Web Part.</importErrorMessage>
</
metaData>
<
data>
<
properties>
<!--
standard Web Part properties -->
<
property name="ChromeType" type="chrometype">Default</property>
<
property name="Title" type="string">Hello World Web Part</property>
<
property name="Description" type="string">Use to create classic Hello World excitement</property>
<
property name="CatalogIconImageUrl" type="string">/_layouts/images/IMAGE.GIF</property>
</
properties>
</
data>
</
webPart>
</
webParts>

Inside Elements.XML:

<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<
Module Name="WSPBuilderWebParts"
List="113"
Url="_catalogs/wp"
Path="dwp"
RootWebOnly="true">
<
File Url="HelloWorldWebPart.webpart" Type="GhostableInLibrary" >
<
Property Name="Group" Value="WSPBuilder Web Parts" />
</
File>
</
Module>
</
Elements>

Inside Feature.xml:

<Feature
Id="8E7D1D5E-4A07-4857-AD5A-EAC3D1A20391"
Title="WSPBuilder Web Parts"
Description=""
Hidden="FALSE"
Scope="Site"
xmlns="http://schemas.microsoft.com/sharepoint/">
<
ElementManifests>
<
ElementManifest Location="elements.xml"/>
</
ElementManifests>
</
Feature>

 

FEATURE RECEIVERS

For feature receivers you will need the following syntax:

 

Inside Feature.xml:

<!-- _lcid="1033" _version="12.0.4518" _dal="1" -->
<!--
_LocalBinding -->
<
Feature Id="6873B8E8-848D-461d-9494-9422E354AE6B"
Title="Test Site Feature Receiver"
Description="This is the feature that sets the CompleteSharepoint.NET publishing lists without approval."
Version="1.0.0.0"
Scope="Web"
Hidden="False"
DefaultResourceFile="core"
ReceiverAssembly="SPTemplateLand, Version=1.0.0.0, Culture=neutral, PublicKeyToken=a829755eafa973db"
ReceiverClass="SPTemplateLand.FeatureReceivers.MyFeatureReceiver"
xmlns="http://schemas.microsoft.com/sharepoint/">
</
Feature>

You will then need to create your feature receiver class.

 

EVENT RECEIVERS

With event receiver, you need to have the following syntax:

The first feature is the feature that deploys your custom list. You can get the syntax from CustomList feature that Microsoft has deployed inside the FEATURE folder of your 12 hive.

Inside Feature.XML:

<?xml version="1.0" encoding="utf-8"?>
<
Feature Id="EAD2A016-DB17-4f7b-94CE-A3EC6CF5D815"
Title="My Custom List Feature"
Description=""
Version="1.0.0.0"
Scope="Web"
DefaultResourceFile="core"
xmlns="http://schemas.microsoft.com/sharepoint/">
<ElementManifests>
<
ElementManifest Location="CustomList.xml" />
</
ElementManifests>
</
Feature>

Inside CustomList.XML (note the Type property):

<?xml version="1.0" encoding="utf-8"?>
<
Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<
ListTemplate
Name="CustomList"
Type="10050"
BaseType="0"
OnQuickLaunch="TRUE"
SecurityBits="11"
Sequence="410"
DisplayName="$Resources:core,custList;"
Description="$Resources:core,custList_Desc;"
Image="/_layouts/images/itgen.gif"/>
</
Elements>

The second feature is then the feature that deploys the Event Receiver feature.

Inside Feature.XML:

<?xml version="1.0" encoding="utf-8" ?>
<
Feature Id="9EF6A5A1-AF0A-494e-BB78-93BA3730E6EC"
Title="Custom List Event Receiver"
Description="An Event handler that supports the addition/modification/deletion of list items throughout various sites in the collection."
Version="1.0.0.0"
Hidden="FALSE"
Scope="Web"
xmlns="http://schemas.microsoft.com/sharepoint/">
<ElementManifests>
<
ElementManifest Location="Elements.xml"/>
</
ElementManifests>
</
Feature>

Inside Elements.xml (note the ListTemplateId and the Type property of the event):

<?xml version="1.0" encoding="utf-8" ?>
<
Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<
Receivers ListTemplateId="10050">
<Receiver>
<
Name>SPTemplateLandEventReceivers</Name>
<
Type>ItemDeleted</Type>
<
SequenceNumber>10000</SequenceNumber>
<
Assembly>SPTemplateLand, Version=1.0.0.0, Culture=neutral, PublicKeyToken=3ea47656c35c3a98</Assembly>
<
Class>SPTemplateLand.EventReceivers.CustomListEventReceiver</Class>
<
Data></Data>
<
Filter></Filter>
</
Receiver>
<
Receiver>
<
Name>SPTemplateLandEventReceivers</Name>
<
Type>ItemUpdated</Type>
<
SequenceNumber>10000</SequenceNumber>
<
Assembly>SPTemplateLand, Version=1.0.0.0, Culture=neutral, PublicKeyToken=3ea47656c35c3a98</Assembly>
<
Class>SPTemplateLand.EventReceivers.CustomListEventReceiver</Class>
<
Data></Data>
<
Filter></Filter>
</
Receiver>
<
Receiver>
<
Name>SPTemplateLandEventReceivers</Name>
<
Type>ItemAdded</Type>
<
SequenceNumber>10000</SequenceNumber>
<
Assembly>SPTemplateLand, Version=1.0.0.0, Culture=neutral, PublicKeyToken=3ea47656c35c3a98</Assembly>
<
Class>SPTemplateLand.EventReceivers.CustomListEventReceiver</Class>
<
Data></Data>
<
Filter></Filter>
</
Receiver>
</
Receivers>
</
Elements>

You will then need to build your custom event receiver class that inherits from SPItemEventReceiver.

 

CONCLUSION

So there you go. Hope this helps. To be continued.


Posted 10-10-2008 3:18 PM by tommysegoro

Comments

Hernan Veiras wrote re: Sharepoint Solution Syntax Part 2
on 10-10-2008 3:34 PM

Hi,

Thanks for developing the templates, I'm currently implementing your solution template and adapting it to my needs.

Great work!!

Links (10/12/2008) « Steve Pietrek - Everything SharePoint wrote Links (10/12/2008) &laquo; Steve Pietrek - Everything SharePoint
on 10-12-2008 7:01 PM

Pingback from  Links (10/12/2008) &laquo; Steve Pietrek - Everything SharePoint

Sezai Komur wrote re: Sharepoint Solution Syntax Part 2
on 10-16-2008 1:14 AM

Nice work Tommy !

Your blog is getting better every day.

Stephanie Zielenski wrote re: Sharepoint Solution Syntax Part 2
on 11-14-2008 10:54 AM

This is really helpful. What does the DWP folder stand for? Is it project specific or a standard SharePoint name? I don't believe I've seen it before.

tommysegoro wrote re: Sharepoint Solution Syntax Part 2
on 11-14-2008 3:10 PM

Hi Steph,

DWP is a file that is used to display the web-part details in web-part selection (and you can also set your web-part part properties in there). In the old version of Sharepoint, we're using .DWP file extension while in the newer version (WSS 3.0 and MOSS 07), we can use both .webpart or .DWP extensions.

Hope this helps,

TOmmy

Add a Comment

(required)  
(optional)
(required)  
Remember Me?
Need SharePoint Training? Attend a SharePoint Bootcamp!
Posts (c) their respective authors. Everything else (c) 2009 SharePoint Experts, Inc.