Page added using C# won't edit in GUI editor

Topics: General, Troubleshooting
Apr 1, 2011 at 1:13 PM
Edited Apr 1, 2011 at 1:48 PM

Hi,

I wondered if anyone could help with the following. As per usual, I'm quite happy to send the site we're testing against.

We followed the process here (http://docs.composite.net/C1/Data/Adding-pages-with-Csharp.aspx) to add a page to a brand new composite install (simply extracted from Composite_C1_VS2010_2.1.4087.22991_ReleaseBuild_20110311.2.zip).

We did this by adding a web service that exposes the first function described in that example. We then called that from a console app (nothing special, just seeing if this would work).

When we then go and edit the added page in the console GUI, the page does not save. In the test site (attached to VS2010) when the new page is edited in the GUI and then we click Save we get an error thrown at:

System.NullReferenceException was unhandled by user code
  Message=Object reference not set to an instance of an object.
  Source=Composite
  StackTrace:
       at Composite.Core.WebClient.FlowMediators.FormFlowRendering.FormFlowUiDefinitionRenderer.<>c__DisplayClass7.b__1(Object sender, EventArgs e)
       at Composite_Forms_DocumentExecutionContainer.OnMessage() in W:\C1Test\Composite\controls\FormsControls\FormUiContainerTemplates\DocumentExecutionContainer.ascx.cs:line 78
  InnerException: 

which corresponds to:

    public void OnMessage()
    {
        string message = ctlFeedback.GetPostedMessage();

        if (message == "save")
        {
            var flowPage = (this.Page as FlowPage);
            flowPage.OnSave(null, null); # <----- ERROR HERE

            ctlFeedback.SetStatus(flowPage.SaveStepSucceded);
        }
        else if (message == "persist")
        {
            ctlFeedback.SetStatus(true);
        }
    }

The GUi then shows the message "Save Resourece?", "test page" has been modified. Save Changes?

Yes repeats the error, No closes the page 

and the console server log shows the following: 

01/04/2011 14:00 System.NullReferenceException: Object reference not set to an instance of an object.
   at Composite.Core.WebClient.FlowMediators.FormFlowRendering.FormFlowUiDefinitionRenderer.<>c__DisplayClass7.b__1(Object sender, EventArgs e)
   at Composite_Forms_DocumentExecutionContainer.OnMessage() in W:\C1Test\Composite\controls\FormsControls\FormUiContainerTemplates\DocumentExecutionContainer.ascx.cs:line 78

 Web Application Error, Exception Critical 
  01/04/2011 14:00 System.NullReferenceException: Object reference not set to an instance of an object.
   at Composite.Plugins.Elements.ElementProviders.PageElementProvider.EditPageWorkflow.FieldHasValidLength(String fieldValue, String fieldName, Int32 maximumLength)
   at Composite.Plugins.Elements.ElementProviders.PageElementProvider.EditPageWorkflow.ValidateSave(Object sender, ConditionalEventArgs e)
   at System.Workflow.Activities.CodeCondition.Evaluate(Activity ownerActivity, IServiceProvider provider)
   at System.Workflow.Activities.IfElseActivity.Execute(ActivityExecutionContext executionContext)
   at System.Workflow.ComponentModel.ActivityExecutor`1.Execute(T activity, ActivityExecutionContext executionContext)
   at System.Workflow.ComponentModel.CompositeActivityExecutor`1.Execute(T activity, ActivityExecutionContext executionContext)
   at System.Workflow.ComponentModel.ActivityExecutor`1.Execute(Activity activity, ActivityExecutionContext executionContext)
   at System.Workflow.ComponentModel.ActivityExecutionFilter.Execute(Activity activity, ActivityExecutionContext executionContext)
   at System.Workflow.ComponentModel.FaultAndCancellationHandlingFilter.Execute(Activity activity, ActivityExecutionContext executionContext)
   at System.Workflow.ComponentModel.ActivityExecutorOperation.Run(IWorkflowCoreRuntime workflowCoreRuntime)
   at System.Workflow.Runtime.Scheduler.Run()

 WorkflowFacade Critical 
  01/04/2011 14:00 Workflow terminated - Id = 90d84057-6074-46de-899c-66eff9327118, Exception:
Object reference not set to an instance of an object.
   at Composite.Plugins.Elements.ElementProviders.PageElementProvider.EditPageWorkflow.FieldHasValidLength(String fieldValue, String fieldName, Int32 maximumLength)
   at Composite.Plugins.Elements.ElementProviders.PageElementProvider.EditPageWorkflow.ValidateSave(Object sender, ConditionalEventArgs e)
   at System.Workflow.Activities.CodeCondition.Evaluate(Activity ownerActivity, IServiceProvider provider)
   at System.Workflow.Activities.IfElseActivity.Execute(ActivityExecutionContext executionContext)
   at System.Workflow.ComponentModel.ActivityExecutor`1.Execute(T activity, ActivityExecutionContext executionContext)
   at System.Workflow.ComponentModel.CompositeActivityExecutor`1.Execute(T activity, ActivityExecutionContext executionContext)
   at System.Workflow.ComponentModel.ActivityExecutor`1.Execute(Activity activity, ActivityExecutionContext executionContext)
   at System.Workflow.ComponentModel.ActivityExecutionFilter.Execute(Activity activity, ActivityExecutionContext executionContext)
   at System.Workflow.ComponentModel.FaultAndCancellationHandlingFilter.Execute(Activity activity, ActivityExecutionContext executionContext)
   at System.Workflow.ComponentModel.ActivityExecutorOperation.Run(IWorkflowCoreRuntime workflowCoreRuntime)
   at System.Workflow.Runtime.Scheduler.Run()

 WorkflowFacade Critical 
  

 

Any ideas?

Andy 

Coordinator
Apr 4, 2011 at 12:44 PM

Hello,

I reproduced this error and it looks like a bug of C1 - If the page field has NULL value it will not validated while saving via Visual Editor.

In that case field FriendlyUrl has NULL value.

As workaround  just modify CreateNewPage() method and add additional friendlyUrl input parameter and pass at least  String.Empty value:

 

public static Guid CreateNewPage(
            Guid parentId,
            Guid pageTypeId,
            Guid templateId,
            string title,
            string pageDescription,
            CultureInfo pageCulture,
            string menuTitle,
            string urlTitle,
            string friendlyUrl,
            string pageContentXhtml)
        {
            using  (DataConnection connection = new DataConnection())
            {
                ////// *** PAGE *** //////

                IPage page = DataConnection.New<IPage>();

                page.Id = Guid.NewGuid();
                page.PageTypeId = pageTypeId;
                page.TemplateId = templateId;
                page.Title = title;
                page.Description = pageDescription;
                page.CultureName = pageCulture.Name;
                page.MenuTitle = menuTitle;
                page.UrlTitle = urlTitle;
                page = page.AddPageAtBottom(parentId);
                page.FriendlyUrl = friendlyUrl;

                ////// *** PLACEHOLDER *** //////

...................... 

I will report this bug and it should be fixed in next release.

Apr 5, 2011 at 8:01 PM

Inna,

We've tested that and it has indeed fixed the issue. Many thanks,

Andy