Orckestra / C1-CMS-Foundation

C1 CMS Foundation - .NET based, open source and a bundle of joy!
https://c1.orckestra.com/
Other
251 stars 109 forks source link

Use StaticMethodCall as source in Widgets #675

Closed djalfe closed 5 years ago

djalfe commented 5 years ago

I wan't to use the HierarchicalSelector as widget for one of my functions and i've configured it so the list of TreeNodes comes from a StaticMethodCal.

When invoking my function i alway get the error System.NotImplementedException: The method or operation is not implemented. and the stacktrace is as follows

System.NotImplementedException: The method or operation is not implemented.
   at Composite.Functions.Forms.FunctionParameterProducer.GetResult()
   at Composite.Functions.Forms.FunctionProducerMediator.EvaluateProducer(Object producer)
   at Composite.C1Console.Forms.Foundation.FormTreeCompiler.CompilePhases.EvaluatePropertiesPhase.HandleProducerElement(ElementCompileTreeNode element, List`1 newProperties, String defaultOverloadPropertyName)
   at Composite.C1Console.Forms.Foundation.FormTreeCompiler.CompilePhases.EvaluatePropertiesPhase.EvaluateElementCompileTreeNode(ElementCompileTreeNode element, List`1 newProperties, String defaultOverloadPropertyName)
   at Composite.C1Console.Forms.Foundation.FormTreeCompiler.CompilePhases.EvaluatePropertiesPhase.Evaluate(ElementCompileTreeNode node, List`1 newProperties, String defaultOverloadPropertyName)
   at Composite.C1Console.Forms.Foundation.FormTreeCompiler.CompilePhases.EvaluatePropertiesPhase.Evaluate(ElementCompileTreeNode node, List`1 newProperties, String defaultOverloadPropertyName)
   at Composite.C1Console.Forms.Foundation.FormTreeCompiler.CompilePhases.EvaluatePropertiesPhase.Evaluate(ElementCompileTreeNode node, List`1 newProperties, String defaultOverloadPropertyName)
   at Composite.C1Console.Forms.Foundation.FormTreeCompiler.CompilePhases.EvaluatePropertiesPhase.Evaluate(ElementCompileTreeNode node, List`1 newProperties, String defaultOverloadPropertyName)
   at Composite.C1Console.Forms.Foundation.FormTreeCompiler.CompilePhases.EvaluatePropertiesPhase.Evaluate(ElementCompileTreeNode node, List`1 newProperties, String defaultOverloadPropertyName)
   at Composite.C1Console.Forms.Foundation.FormTreeCompiler.CompilePhases.EvaluatePropertiesPhase.Evaluate(ElementCompileTreeNode node, List`1 newProperties, String defaultOverloadPropertyName)
   at Composite.C1Console.Forms.FormTreeCompiler.Compile(XDocument doc, IFormChannelIdentifier channel, Dictionary`2 bindingObjects, Boolean withDebug, String customControlIdPrefix, Dictionary`2 bindingsValidationRules)
   at Composite.Core.WebClient.FunctionUiHelper.BuildWidgetForParameters(IEnumerable`1 parameterProfiles, Dictionary`2 bindings, String uniqueName, String panelLabel, IFormChannelIdentifier channelIdentifier)
   at functioneditor.ShowParameterData(XElement functionNode, String parameterName, String fullParameterPath) in C:\Work\Costumers\AUA\Project\www\Composite\content\misc\editors\functioncalleditor\functioncalleditor.aspx.cs:line 1157
   at functioneditor.UpdateEditingPanel(XElement document, String nodeID) in C:\Work\Costumers\AUA\Project\www\Composite\content\misc\editors\functioncalleditor\functioncalleditor.aspx.cs:line 1047
   at functioneditor.SyncTreeAndEditingPanel() in C:\Work\Costumers\AUA\Project\www\Composite\content\misc\editors\functioncalleditor\functioncalleditor.aspx.cs:line 646
   at functioneditor.Page_Load(Object sender, EventArgs args) in C:\Work\Costumers\AUA\Project\www\Composite\content\misc\editors\functioncalleditor\functioncalleditor.aspx.cs:line 327
   at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)
   at System.Web.UI.Control.OnLoad(EventArgs e)
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

This is my WidgetMarkup which i apply to a function parameter

const string xml =
        "<f:widgetfunction name=\"Composite.Widgets.String.HierarchicalSelector\" xmlns:f=\"http://www.composite.net/ns/function/1.0\" xmlns:ff=\"http://www.composite.net/ns/management/bindingforms/std.function.lib/1.0\">" +
        "<f:param name=\"TreeNodes\">" +
        "    <param.value>"+
        "       <ff:StaticMethodCall Type=\"AUA.Data.CustomDataSelectors\" Method=\"GetTypes\" />" +
        "    </param.value>"+
        "</f:param>" +
        "<f:param name=\"Required\" value=\"true\" />" +
        "<f:param name=\"AutoSelectChildren\" value=\"false\" />" +
        "<f:param name=\"AutoSelectParents\" value=\"false\" />" +
        "</f:widgetfunction>";
djalfe commented 5 years ago

Is anybody alive on this Channel ... It would be nice with some kind of feedback. :-(

mawtex commented 5 years ago

Below is a minimal working example, here the list of tree nodes come from an Inline C# Function (code below, registered as "Maw.GetSelectionTreeNode"). If you register your existing static function as a C# Function, you should have the same effect.

Widget markup:

 <f:widgetfunction xmlns:f="http://www.composite.net/ns/function/1.0" name="Composite.Widgets.String.HierarchicalSelector">
  <f:param name="TreeNodes">
      <f:function name="Maw.GetSelectionTreeNode" />
  </f:param>
 </f:widgetfunction>

C# code:

using System.Collections.Generic;
using Composite.C1Console.Forms.CoreUiControls;

namespace Maw
{
 public static class InlineMethodFunction
 {
  public static IEnumerable<SelectionTreeNode> GetSelectionTreeNode()
  {
      var child = new SelectionTreeNode
      {
          Label = "Child",
          Key = "childKey",
          Selectable = true,
          Children = null
      };

      var root = new SelectionTreeNode
      {
          Label = "Root",
          Key = "rootKey",
          Selectable = true,
          Children = new List<SelectionTreeNode>{ child }
      };

      return new List<SelectionTreeNode> { root };
  }
 }
}