Wrong Editor method gets called

Topics: Core, Customizing Orchard, Writing modules
Nov 13, 2014 at 4:00 PM
When I create content item, the Editor Method in Driver for "User Task" activity gets invoked, instead of Editor method for my own custom activity. Don't understand why? Because the "User Task" activity is not even in the workflow.

Thanks & Regards,
Nov 13, 2014 at 5:57 PM
Edited Nov 13, 2014 at 5:58 PM
I only can guess, but do you have created your activity with copying the UserTask Activity and maybe have forgotten to change some line of code?
Nov 14, 2014 at 6:19 AM
Edited Nov 14, 2014 at 6:27 AM
Yeah I thought the same too. But it not like it. I have a very brand new activity, and I have a part and a driver for it. Still can't figure out why its happening like this?

Thanks
Nov 14, 2014 at 7:10 AM
Got it! Here is what was happening.

I have created a driver class like this:
 public class MyOwnActivityPartDriver : ContentPartDriver<MyOwnActivityPart>
    {
        protected override DriverResult Display(MyOwnActivityPart part, string displayType, dynamic shapeHelper) {  }
        protected override DriverResult Editor(MyOwnActivityPartpart part, dynamic shapeHelper) {  }
        protected override DriverResult Editor(MyOwnActivityPartpart part, IUpdateModel updater, dynamic shapeHelper) {   }
     }
and Inherited my model from Content Part:
public class MyOwnActivityPart : ContentPart
{
      // one property here
}
Where in the other pre-built activities like User Task or Email Activity the Editor method is like this
 public class PreBuiltPartDriver : ContentPartDriver<ContentPart>
    {
        protected override DriverResult Display(ContentPart part, string displayType, dynamic shapeHelper) {  }
        protected override DriverResult Editor(ContentPart part, dynamic shapeHelper) {  }
        protected override DriverResult Editor(ContentPart part, IUpdateModel updater, dynamic shapeHelper) {   }
     }
So I changed MyOwnActivityPart to ContentPart in my driver, and It worked. Now my own editor gets called. Still don;t understand, why "User Task" Editor method is called when i use ContentPartDriver<MyOwnActivityPart> instead of ContentPartDriver<ContentPart>.

Thanks.
Marked as answer by cloudsurfer on 11/18/2014 at 10:42 PM
Nov 19, 2014 at 9:07 PM
From my understanding when editing a Content Item, all classes that derive from ContentPartDriver<T> will have their Editor method called. So if you create a custom driver, any existing drivers with the same type will still be called.

In this case, a class derived from ContentPartDriver<ContentPart> will ALWAYS have its Editor method, since all Content Items have a ContentPart (being the "base" part for the Type Definition). Even after changing your MyOwnActivityPartDriver to use ContentPart, the PreBuiltPartDriver will still be called.

If you want to suppress the DriverResult from the PreBuiltPartDriver from being returned you need to change placement.info file for the appropriate templates are set to "-"....

Justin