locked
rehosted activitydesigner and validation RRS feed

  • Question

  • I've done the following in my custom CodeActivity:

            protected override void CacheMetadata(CodeActivityMetadata metadata)
            {
                metadata.AddValidationError("Blah");
                base.CacheMetadata(metadata);           
            }

    Shouldn't my ActivityDesigner for my CodeActivity display the error icon? It's not (warnings don't show either). Do I need to add something to the ActivityDesigner xaml for warning/error icons etc?

     

     

     


    Sham Singh
    Friday, April 9, 2010 7:18 PM

Answers

  • I should also note that TestActivity is a child of another CodeActivity


    That's probably your problem there. CodeActivity cannot actually have child activities. Only Activity or NativeActivity can have child activities...

    (And the child activities must be registered via CacheMetadata for validation to reach them, but they will be registered by default if they are exposed as public property, or part of Activity.Implementation.)
    Tim

    • Marked as answer by Sham Singh Tuesday, April 13, 2010 2:19 PM
    Monday, April 12, 2010 2:47 AM

All replies

  • Hi Sham,

    Your code sample is working OK for me. What is your activity inside of?
    Sometimes validation errors do not show up because your validation code is not getting called, because e.g. the activity is not fully added as part of the Activity tree (during CacheMetadata process).

    Tim

    P.S. I should also probably ask if you have a custom activity designer, and what class you derived it from...

    Friday, April 9, 2010 8:20 PM
  • I've created another TestActivity (CodeActivity) that does not use a custom activity designer (my original post code did). In TestActivity I've overrode CacheMetadata once again. I then execute ActivityValidationServices.Validate(this) from within the Setter of one of the TestActivity properties that gets called. CacheMetadata() is then getting called and metadata.AddValidationError("Blah") is being executed too. However, the Designer still does not indicate/show the error glyph.

    I should also note that TestActivity is a child of another CodeActivity that is using a designer of type ActivityDesigner and a WorkflowItemsPresenter for presenting its children (TestActivty being on of the children). The Parent Activity has the exact same test code to trigger the creation of validation error and it does work. An error glyph does show-up in the designer for the Parent Activity.

    I've also added:

                        var validationErrorService = new ValidationErrorService(errors);
                        _WfDesigner.Context.Services.Publish<IValidationErrorService>(validationErrorService);

    This ValidationErrorService does receive the errors from the Parent Activity, but nothing from the child (TestActivity) when CacheMetadata() returns. So for whatever reason the designer (_WfDesigner in my code) is not getting the error validation messages from TestActivity.

    Thanks for you help.



    Sham Singh
    Friday, April 9, 2010 11:40 PM
  • I should also note that TestActivity is a child of another CodeActivity


    That's probably your problem there. CodeActivity cannot actually have child activities. Only Activity or NativeActivity can have child activities...

    (And the child activities must be registered via CacheMetadata for validation to reach them, but they will be registered by default if they are exposed as public property, or part of Activity.Implementation.)
    Tim

    • Marked as answer by Sham Singh Tuesday, April 13, 2010 2:19 PM
    Monday, April 12, 2010 2:47 AM
  • Thanks, Tim. That was part of the problem. Another thing I found was that I had base.CacheMetadata(metadata) commented out up the tree a bit in a Parent Activity CacheMetadata() method. Now on to the next issues.

     

    Thanks again.


    Sham Singh
    Tuesday, April 13, 2010 2:19 PM