Quick Start Guide
Create a new SharePoint web site via a Feature
Its simple to call SAF from a SharePoint Feature Receiver by creating the following
Feature.xml file :
<?xml version="1.0" encoding="utf-8"?>
<Feature Id="{156E17A5-A7BA-4e1f-8A48-1BC341A7C658}"
Title="SAF Sample Feature - 'Action.CreateWebAction'"
Description="Sample Feature illustrating how to call and run CreateWeb from a SAF Macro."
Version="12.0.0.0" Hidden="FALSE"
Scope="Web"
DefaultResourceFile="core"
xmlns="http://schemas.microsoft.com/sharepoint/"
ReceiverAssembly="Collaboris.Saf, Version=2.0.0.0, Culture=neutral, PublicKeyToken=182db3eac6a9e195" ReceiverClass="Collaboris.Saf.Adapters.SafFeatureReceiver">
<Properties>
<!-- Defines a SAF Macro containiing Actions to be run on Do and Undo -->
<!-- Please visit http://www.collaboris.co.uk/Saf/Doc/default.html for more information. -->
<Property Key="MacroFile" Value="Collaboris.Saf.Actions.Wss.Web.CreateWeb.macroTemplate" />
<Property Key="InstanceId" Value="{156E17A5-A7BA-4e1f-8A48-1BC341A7C658}" />
<Property Key="disabledo" Value="false" />
<Property Key="disableundo" Value="false" />
<Property Key="description" Value="New Web created by SAF" />
<Property Key="lcid" Value="1033" />
<Property Key="overwrite" Value="true" />
<Property Key="template" Value="STS#0" />
<Property Key="title" Value="New Web title" />
<Property Key="url" Value="NewWeb" />
<Property Key="useuniqueperms" Value="false" />
<Property Key="webname" Value="New Web name" />
<Property Key="id" Value="{47B640DD-64A9-493b-8445-789FC0D05FF1}" />
<Property Key="stopondoexception" Value="true" />
<Property Key="stoponundoexception" Value="true" />
<!-- You can also define your own properties to be resolved by PlaceHolders in the Macro ... <Property Key="YourKey" Value="YourValue" /> -->
</Properties>
</Feature>The points of note about the Feature Receiver above are as follows :
This line tells SharePoint where to find the SAF Assembly :*ReceiverAssembly="Collaboris.Saf, Version=2.0.0.0, Culture=neutral, PublicKeyToken=182db3eac6a9e195"*This line tells SharePoint which .net class implements the Feature Receiver :*ReceiverClass="Collaboris.Saf.Adapters.SafFeatureReceiver"*Lastly, we need to tell the Feature receiver exactly where the "Macro" resides. (Relative to the Feature.xml path).This is achieved by designating an "MacroFile":*<Property Key="MacroFile" Value="Collaboris.Saf.Actions.Wss.Web.CreateWeb.macroTemplate" />*As far as the Feature goes, thats it! You deploy the feature in the normal way, either by copying to the 12 hive, or deploying via a WSP.
Now to create the Web you need to give define an XML file in the following format. The file looks like this :
<?xml version="1.0" encoding="utf-8"?>
<objects xmlns="http://www.springframework.net" default-lazy-init="true">
<object id="MacroToProcess" type="Macro">
<constructor-arg name="templateid" value="{839a4293-b076-485f-8478-9ea7d7605ea5}" />
<constructor-arg name="actions">
<list element-type="IAction">
<object id="CreateWebd5" type="Action.CreateWebAction" lazy-init="true">
<property name="DisableDo" expression="Func.Eval('${disabledo}')" />
<property name="DisableUndo" expression="Func.Eval('${disableundo}')" />
<property name="EntityList">
<object id="WebInfob5" type="Entity.WebInfo" lazy-init="true">
<property name="Description" expression="Func.Eval('${description}')" />
<property name="Lcid" expression="Func.Eval('${lcid}')" />
<property name="Overwrite" expression="Func.Eval('${overwrite}')" />
<property name="Template" expression="Func.Eval('${template}')" />
<property name="Title" expression="Func.Eval('${title}')" />
<property name="Url" expression="Func.Eval('${url}')" />
<property name="UseUniquePerms" expression="Func.Eval('${useuniqueperms}')" />
<property name="WebName" expression="Func.Eval('${webname}')" />
</object>
</property>
<property name="ID" expression="Func.Eval('${id}')" />
<property name="StopOnDoException" expression="Func.Eval('${stopondoexception}')" />
<property name="StopOnUndoException" expression="Func.Eval('${stoponundoexception}')" />
</object>
</list>
</constructor-arg>
</object>
</objects>The file is best discussed in 2 parts (as illustrated in the comments).
Part 1 - The macroThis Part contains the Action(s) that you wish to do in your Feature. In this example, we have only one Action as we are just interesting in creating a web.
Part 2 - The EntitiesEach Action can take zero or many Entities. Entities are simplye POCO's and nothing more. They are a way to pass parameters to the Action.