Dynamic WebPart connections

etc
  • Dynamic WebPart connections etc

    I'm prototyping the best way to dynamically connect web parts at runtime. Essentailly, the application will allow for several disparate application groups to create web parts that will be consumed within the SharePoint front end. All of the web parts will need to automatically detect consumers and providers to create connections at runtime.

    What we are looking to do is have webparts discover and automatically connect to other compatible webparts. When a user adds the two compatible parts to a page, the parts should be able create the appropriate connections. We have a well defined interface for passing data between the parts, so the only issue is how to manage the connections. To be clear, we do not want user's to worry about having to create connections themselves.

    For our purposes "best way" means most efficient, elegant and/or standard. We'd like to follow established sharepoint design patterns as much as possible, but code efficiency is somewhat important.

    I've been able to draft a proof of concept that uses a base web part class to do this during the oninit event of each subclassed webpart. The oninit event grabs the current page's SPWebPartManager and itereates through each part creating consumer and provider connections for every webpart inheriting from the base class:

    SPWebPartManager spManager = SPWebPartManager.GetCurrentWebPartManager(Page) as SPWebPartManager;
    foreach (BaseWebPart provider in parts)
    {
        foreach (BaseWebPart consumer in parts)
        {
            if (provider != consumer)
            {
                string connectionId = string.Format("WebPartConnection{0}{1}", consumer.ID, provider.ID);
                SPWebPartConnection conn = spManager.SPWebPartConnections[connectionId];
                if (conn == null)
                {
                    conn = new SPWebPartConnection()
                    {
                        ID = connectionId,
                        ConsumerID = consumer.ID,
                        ConsumerConnectionPointID = "WebPartConnectableConsumer",
                        ProviderID = provider.ID,
                        ProviderConnectionPointID = "WebPartConnectableProvider"
                    };
                    spManager.SPWebPartConnections.Add(conn);
                }
                connectionCreated = true;
            }
        }
    }
    

  • The WPSC has a publish/subscribe event model that will likely help. (In this model, providers always raise the event, even if no subscribers are on the page.)

    Refer to the WPSC reference, in particular, the RegisterForEvent and RaiseEvent methods.

    http://msdn.microsoft.com/en-us/library/ms414515.aspx

Tags
wss-3.0 development web-part connected-web-parts
Related questions and answers
  • , and then as part of that activation, drop web parts onto some specific pages. In my case I want to be able to drop it onto the "AllItems.aspx" page of a list, but I'm equally having trouble adding it to the default.aspx home page. I would be happy either way. Note: I want to be able to activate this on existing site, I dont want to create a new Site Definition. Here is what I have tried: Feature Receiver...), then there doesn't seem to be a way to just get a reference to the page, it always wants to overwrite it with a new file. But I dont want to do that, I just want to add a Web Part to the existing page. See my

  • View WebParts, the connection is greyed out. How do I make this work? There is very little information available on connecting WebParts on a web part page. This seems to be too advanced a topic for most of the end user resources. On the other hand, it's not a developer or IT Pro topic either. The Administrator's Companion and the "SharePoint 2007 User's Guide" by Seth Bates both have one page... help me get my web part connection working. The best reference for WebPart Connections is still open, though I'll copy it into a new question.

  • the page. We do have hooks for setting default page layout based on where in the structure the page is created, here we can append the web part as well, but then the web part will only be added if you create...How can I set a web part so it will be automatically appended to a web part zone when a specific page layout is selected? The solutions I have tried so far is: Using <ZoneTemplate> under <WebPartZone> and putting my webpart in there Adding .webpart-code directly into <AllUsersWebPart> where I define the page layout, in elements.xml Put the web part on the page layouts

  • on the intranet site. On each individual page, I have setup a Content Query Web Part that displays the documents that have the corresponding Page value set (i.e. if a document Page value has been checked for "HR... by nontechnical personnel Display documents on the appropriate pages without user having to edit actual page or web part Denote document page location using user settable document attributes (if possible...My organization is in the process of converting our intranet over to a SharePoint solution. Part of this intranet will be the movement and organization of all our internal documents. Currently, we

  • I'm trying to make a web part that is managing other web parts in the solution. I need it to be able to hide other web parts based on user input. Since I can't use connections I'm trying to do this using SPLimitedWebPartManager. I got it to work but i need a double postback to get the effect, since saving the settings does not take effect before it has been loaded once more. Does any one of you know other ways of hiding web parts (in combination of using the SPLimitedWebPartManager, need the personal settings) in one postback?

  • I am trying to iterate over a List and view properties on some items that live within that list, and down one or two levels; this is on a SharePoint 2010 server. So far I have been able to connect... what lives there. What I would like is to be able to view all the ItemB's (and there may be lots of them) under each Folder, there are about 10 Folders in the List with each Folder containing lots of ItemB's. What's the easiest way to be able to find the Folder and then search under the Folder and get all of its Items to display? My experience with PowerShell and SharePoint in this regard

  • a Filtered Parameter. However the dropdown of parameters is greyed out and just says "No Parameters". Note: the web part I'm trying to connect to is also custom and may not have been fully completed and tested for providing a value via a connection. Is there anything that explains why I'm unable to set up a connection? Here is the code for my web part: public class ProgramEntityTokenConverter...I'm writing a web part that needs to use connections for processing values relating to a business object called a "Program Entity". It is supposed to take in an ID provided by a connected web part

  • that the App pool user for your content web application does not have write access to the Config database, you can't create new TimerJobDefinitions from code that runs in your content web app. A bad...I have run into a problem several times now where I have developed a custom timer job, and I want my site collection administrators to manage the schedule of this job with a custom application page... I can think of is to have another timerjob that polls some kind of queue (for example a sharepoint list in my site collection) for new timerjobs to create, and creates it if an item has been added

  • be overridden automatically (unless I can do it through SPD?). And my final option is to create a doc library for each customer. The issue here is when a customer logs in, how can I display a web part for only the doc lib they have access to, and not the other customer's webparts? If I put them all on the home page, the user will get a message stating they don't have permissions to view the data... with, my customer wants to allow her customers to log in to simply swap files with her. Of course each customer should only see their own files. Also, my customer wants SharePoint to be themed to match her

Data information