I created a simple web part that has both a consumer and a provider connection. The provided output depends on the consumed input (so this is a sort of pipeline approach). I managed to implement the web part and set up both the connections on an SP page. However, the web part does not work in practice because Sharepoint actually calls the provider method before the data to consume has been received (this seems rather senseless to me). I discovered this using debug prints. (See the code on the bottom for more information.)
Now running SetConnectionInterfaceForOutput
Now running ParameterValues (output is "")
Now running SetConnectionInterfaceForInput
Now running getFieldValue (received input "1;#A")
So, the question is: is there any way to force Sharepoint call the consumer method before the provider method?
[ToolboxItemAttribute(false)]
public class LookupValueProcessorFilter : WebPart, Microsoft.SharePoint.WebPartPages.ITransformableFilterValues
{
private string input = "";
private string output = "";
private string debugString = "";
Label debugLabel;
[ConnectionConsumer("Lookup value input", "IWebPartField", AllowsMultipleConnections = false)]
public void SetConnectionInterfaceForInput(IWebPartField provider)
{
debugString += "Now running SetConnectionInterfaceForInput<br />";
provider.GetFieldValue(new FieldCallback(getFieldValue));
}
private void getFieldValue(object fieldValue)
{
input = fieldValue.ToString();
debugString += "Now running getFieldValue (received input \"" + input + "\")<br />";
}
[ConnectionProvider("Lookup value output", "ITransformableFilterValues", AllowsMultipleConnections = true)]
public Microsoft.SharePoint.WebPartPages.ITransformableFilterValues SetConnectionInterfaceForOutput()
{
debugString += "Now running SetConnectionInterfaceForOutput<br />";
return this;
}
public virtual System.Collections.ObjectModel.ReadOnlyCollection<string> ParameterValues
{
get
{
debugString += "Now running ParameterValues (output is \"" + output + "\")<br />";
Microsoft.SharePoint.SPFieldLookupValue lookupValue = new Microsoft.SharePoint.SPFieldLookupValue(input);
output = lookupValue.LookupValue;
return new System.Collections.ObjectModel.ReadOnlyCollection<string>(new string[] { output });
}
}
protected override void CreateChildControls()
{
base.CreateChildControls();
debugLabel = new Label();
this.Controls.Add(debugLabel);
}
protected override void OnPreRender(EventArgs e)
{
base.OnPreRender(e);
debugLabel.Text = debugString;
}
public virtual bool AllowMultipleValues
{
get {return true;}
}
public virtual bool AllowAllValue
{
get {return true;}
}
public virtual bool AllowEmptyValue
{
get {return false;}
}
public virtual string ParameterName
{
get {return "Lookup value";}
}
}