Custom Decorator never gets fired

Posted by Community Admin on 04-Aug-2018 12:37

Custom Decorator never gets fired

All Replies

Posted by Community Admin on 23-Jan-2013 00:00

Hi,

I have a support ticket open for this, but no response as yet and thought i would crowd source.  We have a custom module, and we would like to create a library (if one doesn't exist) on the publication of the custom item.

Issue we are facing is our custom decorator never gets  called, and i am very unclear as to what is going wrong as there are no errors being generated, all the code i think is supposed to be there is, but still we can't seem to get it to run:

Decorator Code:

namespace LocationsModule.Helpers
    public class LocationDecorator: LifecycleDecorator
    
        public LocationDecorator(ILifecycleManager manager, LifecycleItemCopyDelegate copyDelegate, params Type[] itemTypes)
            : base(manager, copyDelegate, itemTypes)
         
        public LocationDecorator(ILifecycleManager manager, Action<Content, Content> copyDelegate, params Type[] itemTypes)
            : base(manager, copyDelegate, itemTypes)
  
   
        protected override ILifecycleDataItemGeneric ExecuteOnPublish(ILifecycleDataItemGeneric masterItem, ILifecycleDataItemGeneric liveItem, System.Globalization.CultureInfo culture = null, DateTime? publicationDate = null)
         
            var locItem = masterItem as LocationItem;
            var manager = LocationManager.GetManager();
 
            if (locItem.AlbumId.ToString().IsNullOrEmpty())
            
                var gcId = string.IsNullOrEmpty(locItem.ReferenceId) ? "" : " (" + locItem.ReferenceId + ")";
                var albumName = "Gallery: USL " + locItem.Title + gcId;
                var album = LocationsHelper.GetAlbumByName(albumName);
 
                if (album == null)
                
                    var albumId = Guid.NewGuid();
                    LocationsHelper.CreateAlbum(albumId, albumName);
                
            
             
            return base.ExecuteOnPublish(masterItem, liveItem, culture, publicationDate);
        
    

Global.asax
protected void Application_Start(object sender, EventArgs e)
 
     Bootstrapper.Initialized += new EventHandler<Telerik.Sitefinity.Data.ExecutedEventArgs>(Bootstrapper_Initialized);
 
 
 void Bootstrapper_Initialized(object sender, Telerik.Sitefinity.Data.ExecutedEventArgs e)
 
     Telerik.Sitefinity.Web.UI.Dialogs.RegisterDialog<SelectorFields.PageSelector.PageSelectorFieldDialog>();
     Telerik.Sitefinity.Web.UI.Dialogs.RegisterDialog<Telerik.Sitefinity.Samples.SimpleImageSelectorDialog>();
 
     ObjectFactory.Container.RegisterType<ILifecycleDecorator, LocationDecorator>(typeof(LocationManager).FullName,
         new InjectionConstructor(
             new InjectionParameter<ILifecycleManager>(null),
             new InjectionParameter<Action<Content, Content>>(null),
             new InjectionParameter<Type[]>(null)));
 

Any help would be greatly appreciated.

Rob

Posted by Community Admin on 24-Jan-2013 00:00

Hi Roberto,

I am assuming that Locations module is a module created by using Module Builder. The registration of Decorator for Dynamic modules differs a little the regular ones. Below is a snippet

protected void Application_Start(object sender, EventArgs e)
       
           Bootstrapper.Initialized += new EventHandler<Telerik.Sitefinity.Data.ExecutedEventArgs>(Bootstrapper_Initialized);
       
    
       void Bootstrapper_Initialized(object sender, Telerik.Sitefinity.Data.ExecutedEventArgs e)
       
    
           if (e.CommandName == "Bootstrapped")
           
               ObjectFactory.Container.RegisterType<ILifecycleDecorator, CustomDecorator.NewsDecorator>
                   (typeof(DynamicModuleManager).FullName,
                       new InjectionConstructor(
                           new InjectionParameter<ILifecycleManager>(null),
                           new InjectionParameter<LifecycleItemCopyDelegate>(null),
                           new InjectionParameter<Type[]>(null)
                           )
                   );
           
       

Please also read this knowledge base, which goes in detail on using decorators with dynamic modules Regards,
Venkata Koppaka
the Telerik team

This thread is closed