Malek's Moorish Tales

Meanderings about life and technology

leaving for Tunis ...

Tomorrow morning, I am leaving for Tunis where I give an Office System 2003 Training for 5 days.

Today, I hade to do some interesting work on InfoPath and on CMS. InfoPath is really a great baby for creating Forms using Web Services ... on CMS, I had to work on a placeholder that makes it easy for the content authors to apply Css classes (without knowing it) to their content. The main idea is to apply on of a few predefined tags, and let the css take care of it (in my case choosing one of a multitude of bulleted lists with flashy icons).

I will be posting that code on monday ( iam just too tired to comment it right now).

Proud to be a Moor

Without going into political or historical polemic, I just am proud of the scientific and artistic production of the Moorish Andalusian civilisation. It was one where Muslims, Christians and Jews lived together in peace and harmony for centuries, and it has produced some of the most beautiful works of arts ever made.

It suffices to go to the Alcazar Reales in Sevilla, or to the Mosk-Cathedral in Cordoba, or even better, to the Alhambra in Granada to be conviced ...

If I claim such heritage, it is because I have no other understanding of the history of my people and country except being the civilisation that started with the "Berbers", and the glory of Hannibal, Jugurtha and Juba. Even then and way before, our land was a meeting place for civilisations and a melting pot for cultures likethose of the Phoenicians and the Romans. Way later, whith the arrival of the Arabs, it was still the people of our land, the berbers that made the western islamic civilisation that took over Andalussia (now southern Spain) and made it one of the most flourishing civilisations in the world ...

So that is the begining of mty tales, which will be an expression of the views of a guy proud to be a Moor ...

Créer des Web Parts sous .Net revient à créer un contrôle Web Personnalisé (ou presque ...)

On peut créer des Web Parts de la même manière qu'on crée des contrôles Web personnalisés sous ASP.Net. La seule différence est qu'on utilise la méthode RenderWebPart au lieu de Render.(Ceci permet d'avoir toute la fonctionnalité inhérente aux Web Parts, telle que la possibilité de les glisser d'un emplacement dans la page vers un autre, d'utiliser lee panneaux des outils qui permet de modifier les propriétés...etc.)). exemple en C# (les réferences à Microsoft.SharePoint.dll et à System.Data.dll sont nécessaires):

using System;
using
System.ComponentModel
using
System.Web.UI; using System.Web.UI.WebControls;
using
System.Xml.Serialization;
using
Microsoft.SharePoint;
using
Microsoft.SharePoint.Utilities;
using
Microsoft.SharePoint.WebPartPages;
namespace
MyWebPartsLibrary
{

[ToolboxData("<{0}:WebPart1 runat=server></{0}:WebPart1>"),
XmlRoot(Namespace="MyWebPartsLibrary")]
public class WebPart1 : Microsoft.SharePoint.WebPartPages.WebPart
{

private DataGrid myAuthorsGrid=new DataGrid();
protected override void RenderWebPart(HtmlTextWriter output)
{

myAuthorsGrid.DataSource=getAuthors().Table[0];
myAuthorsGrid.DataBind();
myAuthorsGrid.RenderControl(output);

}
private DataSet getAuthors()
{

System.Data.SqlClient.SqlConnection cnn = new System.Data.SqlClient.SqlConnection("data source=localhost; initial catalog=pubs; integrated security=SSPI");
System.Data.SqlClient.SqlDataAdapter adapt =
new System.Data.SqlClient.SqlDataAdapter("select * from authors", cnn);
System.Data.DataSet result =
new System.Data.DataSet();
adapt.Fill(result);
return result;

}

}

}

Comme pour toute solution Office System, un Manifeste est obligatoire et doit être signé avec un certificat numérique, et il doit référencer la dll comme suit :

<?xml version="1.0"?>

<WebPartManifest xmlns="http://schemas.microsoft.com/WebPart/v2/Manifest">

<Assemblies>

<Assembly FileName="MyWebPartsLibrary.dll">

<SafeControls>

<SafeControl Namespace="MyWebPartsLibrary" TypeName="*" />

</SafeControls>

</Assembly>

</Assemblies>

<DwpFiles>

<DwpFile FileName="WebPart1.dwp"/>

</DwpFiles>

</WebPartManifest>

 

Pour installer le(s) composant Web Part dans SharePoint, un fichier CAB doit être créé (Projet de déploiement) et l'utilitaire stsadmn.exe est utilisé pour l'installation comme suit :

stsadm –o addwppack –MyWebPartLibrary.dll

 

Web Parts as Custom Web Controls (or almost...)

I will continue on the Office System series with this very simple exemple of how one can write Web Parts just as one would write any ASP.Net Custom WebControl. The only difference is that you don't override the Render Method, but the RenderWebPart method instead (this allows for the Web Part predefined functionnality like dragging and dropping the Web Part within the Web Part Page in Windows SharePoint Services sites or SharePoint Portal Server sites, as well as the integration within the Web Part Framework and use of the WebPart Tool panes ...etc.). example in C# (A reference to Microsoft.SharePoint.dll and to System.Data.dll are needed):

using System;
using
System.ComponentModel
using
System.Web.UI; using System.Web.UI.WebControls;
using
System.Xml.Serialization;
using
Microsoft.SharePoint;
using
Microsoft.SharePoint.Utilities;
using
Microsoft.SharePoint.WebPartPages;
namespace
MyWebPartsLibrary
{

[ToolboxData("<{0}:WebPart1 runat=server></{0}:WebPart1>"),
XmlRoot(Namespace="MyWebPartsLibrary")]
public class WebPart1 : Microsoft.SharePoint.WebPartPages.WebPart
{

private DataGrid myAuthorsGrid=new DataGrid();
protected override void RenderWebPart(HtmlTextWriter output)
{

myAuthorsGrid.DataSource=getAuthors().Table[0];
myAuthorsGrid.DataBind();
myAuthorsGrid.RenderControl(output);

}
private DataSet getAuthors()
{

System.Data.SqlClient.SqlConnection cnn = new System.Data.SqlClient.SqlConnection("data source=localhost; initial catalog=pubs; integrated security=SSPI");
System.Data.SqlClient.SqlDataAdapter adapt =
new System.Data.SqlClient.SqlDataAdapter("select * from authors", cnn);
System.Data.DataSet result =
new System.Data.DataSet();
adapt.Fill(result);
return result;

}

}

}

As for all Office System Solutions, there must be a manifest that is signed with a digital certificate (that's the basis of all security configurations and policies for Office System solutions) that references the dll as follows :

<?xml version="1.0"?>

<!-- You need only one manifest per CAB project for Web Part Deployment.-->

<!-- This manifest file can have multiple assembly nodes.-->

<WebPartManifest xmlns="http://schemas.microsoft.com/WebPart/v2/Manifest">

<Assemblies>

<Assembly FileName="MyWebPartsLibrary.dll">

<SafeControls>

<SafeControl Namespace="MyWebPartsLibrary" TypeName="*" />

</SafeControls>

</Assembly>

</Assemblies>

<DwpFiles>

<DwpFile FileName="WebPart1.dwp"/>

</DwpFiles>

</WebPartManifest>

 

To install the Web Part in SharePoint, a CAB file has to be created (Setup Project) and the utility stsadmn.exe is used for installation as follows :

stsadm –o addwppack –MyWebPartLibrary.dll