AWG Blogs

Friday, July 6, 2012

"Specified view is invalid" error when transferring .webpart

I couldn't figure out why SharePoint would produce ASP.NET error when importing a previously exported .webpart. The quick way to resolve it is to remove the ViewFlag element or set it to 0 in the .webpart file. But I found that when I do this the web part does not set ctx values, such as httpvdir. One workaround is to use Server variables rather than CAML variables in the .webpart's ParameterBinding value. I could also open the page in SPD, and make a minor change and save it, which fixes the problem. But I still need to determine what is causing the issue. (BTW, what does ViewFlag, or its absence, have to do with the issue, and what do the ViewFlag values mean anyways? No-one knows apparently).

I finally reproduced the issue in a simple case:
In SourceSiteCol, create a plain doc library and set ContentTypesEnabled to true ("Allow management of content types").
Save as list template. Copy this to DestSiteCol List template gallery.
On DestSiteCol subsite, create a list based on the uploaded list template.
In a web part page on this subsite, add a ListViewWebPart based on the created list. In SPD, convert it to a DataFormWebPart.
Export it as a .webpart. Then import into another web part page on the same site; the error occurs. Disabling Content type management for the created list makes the error go away. So the problem has something to do with Content Types...

At any rate, when transferring lists and their web parts to other sites, can edit the .webpart as follows:
Look for SelectParameters and change the Parameter with ListID to have ListName, and set its DefaultValue to the current display name of the target list (note, if the display name changes, your web part will break, and you'll have to fix the name in the XSLT).
Remove the  Update, Insert, and Delete params see (http://blogs.msdn.com/b/joshuag/archive/2008/11/10/easily-making-the-data-form-web-part-reusable.aspx).
Set TitleUrl property to the URL of the default view
Set the Title property to the intended title of the web part

Friday, June 15, 2012

Biological Architecture of Software Applications

Organs communicate through the medium of interstitial fluids, i.e. the environment of the body. The sun communicates with the open system of Planet Earth through an environment of space. When you look around self-sustaining systems communicate through indirect mediums. Why should software architecture be any different?

The easiest-to-develop and most self-sustaining software is done, I propose, through a combination of the Observer design pattern and Environments. These Environments are the Observables that trigger events whenever properties are set; Observers (like cells and enzymes) subscribe to those property initializations of interest and may set further properties on their Environment. Environments may subscribe to the property change events of other Environments and so forth. This is a more natural way to design implement software. DCI on steroids if you will. Makes DDD look rather stodgy by comparison....

Monday, May 21, 2012

Secondary Lookup Column in SP2007?

There's UI support in 2010

Stefan Stanev found out it's possible to rig SP2007 to do the same thing, sort of (see http://stefan-stanev-sharepoint-blog.blogspot.com/2010/11/sharepoint-2007-associated-lookup.html).

The catch is deleting the field will give error Exception calling "Delete" with "0" argument(s): "One or more field types are not installed properly. Go to the list settings page to delete these fields."

I noticed you get the same error if attempting to delete Created_x0020_Date once AllowDeletion is set to True. So it appears the issue is widespread with regard to lookup columns that contain the FieldRef attribute.

My only concern is what happens when upgrade occurs.

Monday, April 30, 2012

Middleman Pattern

The DCI paradigm, specifically the canonical example of the account transfer seems unnatural. If I'm not mistaken, in most business domains the act of transferring resources between entities is performed by a middleman entity. Behavior is no more injected into entities than are entry-level checking account clerks trained on the spot to make transfers to investment accounts (imagine this is a bank in the pre-computing days).

So I propose the "Middleman Pattern." The following is an example. Note: the example could be abstracted in that concrete classes could be decoupled via interface implementation and dependency injection.



Edit: See also suggestion of "money transferrer" at http://pettermahlen.com/2010/09/10/dci-architecture-good-not-great-or-both/

Tuesday, April 24, 2012

SharePointMVC Note

When following the Deployment.docx, the instructions say to put the DLLs in the SharePoint website _app_bin. Well, I had to also put the web app DLL in the SharePoint website bin folder to get it working; otherwise I'd get the error: Could not load type 'SampleWebApplication.xxxxxx'.   at System.Web.UI.TemplateParser.GetType(String typeName, Boolean ignoreCase, Boolean throwOnError)
   at System.Web.UI.TemplateParser.ProcessInheritsAttribute(String baseTypeName, String codeFileBaseTypeName, String src, Assembly assembly)
   at System.Web.UI.TemplateParser.PostProcessMainDirectiveAttributes(IDictionary parseData)

Sunday, April 15, 2012

UML Aggregation Vs DDD Aggregate

The same root term "Aggregate" in DDD does not correspond to the UML "Aggregation" notation (filled diamond).

DDD use of root term "Aggregate":
OrderLines have no reason to exist without their parent Order, nor can they belong to any otherOrder. In this case, Order and OrderLines would probably be an Aggregate, and the Order would be the Aggregate Root

Sunday, March 18, 2012

Force Post in .load method

The following code:
$('div').load('Service.asmx/HelloWorld')
may produce the error in the Response as visible from the Console tab of Firebug: "Request format is unrecognized for URL unexpectedly ending in '/HelloWorld'."

This ASP.NET web service expects a POST. To force a POST change the code by adding a bogus object to the .load jQuery method:
$('div').load('Service.asmx/HelloWorld',{test:"blah"})

Update: Actual fix is to edit the web.config, see comment by Lotas here.