Home > Presentation, SharePoint > CodeFluent Entities: SharePoint Web Part Producer

CodeFluent Entities: SharePoint Web Part Producer


In previous posts, we’ve introduced the SharePoint Web Part Producer, shown its output, and that you could customize forms. In this post we’ll show you how to generate web parts Smile

To generate web parts, add the SharePoint Web Part Producer to your project by clicking “Add new producer” on the “Producers” folder in Visual Studio’s Solution Explorer, expand the Web Producers node and select it:

image

The SharePoint Web Part producer provides two main types of features:

  • code generation features,
  • deployment features.

You can use it to generate code, compile it and deploy it on a SharePoint server in the same run, however here since we want to be able to view and extend the code, compile with Visual Studio and deploy ourselves, we’re going to disable those deployment features.

Here’s a sample configuration:

image

Properties I changed are in bold:

  • Source Production > Target Directory (mandatory): I’m making it point to my class library project containing my generated .NET classes
  • Deployment > Copy Binaries: Set it to false, we’ll compile with VS so the producer has no binary to deploy yet,
  • Deployment > Update [trust].config: Set it to false, same as before, for now we’re developing, we’re not bothering with deployment stuff,
  • Deployment > Update web.config: Set it to false, same as [trust].config,
  • Site Creator > Produce MsBuild Task Files: The site creator feature is to create a document library on the SharePoint server to test our generated web parts, set it to false for now,
  • Site Creator > Produce Source Files: set it to false as well.

Build your project over and….ooops! We get the following error:

CF5519: The SharePoint WebParts producer needs the ‘SoftFluent.AssociationManage’ pattern to be included in the project.

Correct, the AssociationManage Aspect is needed by the SharePoint producer as it adds many-to-many management features which are required in the generated UI.

While we’re at it, I’d also recommend you add the AutoFormattable aspect to your project as in the generated UI, for one to many relations, you’ll get a preview of related data if any instead of just the number of related items.

image

Generate over, and there you go: you’ll see that custom web parts were generated:

image

Carl Anderson

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s