Dynamicweb 8 Notification Changes



One of the most important options for extending Dynamicweb with custom functionality is the Notification system in Dynamicweb. Some important changes are part of the Dynamicweb 8 release.


Background

The notification system was introduced with Dynamicweb eCommerce back in 2006. It is based on the observer pattern and gives developers an easy way of hooking into Dynamicweb and extends what is going on without a lot of code. Very powerful indeed.

To “listen” for a notification a simple class that derives from Dynamicweb.Extensibility.NotificationSubscriber is created and the method OnNotify is overridden.


A notification subscriber.

OnNotify has 2 parameters – the name of the notification and some arguments representing the context, i.e. an order, a template instance or things like that.

The original version of the OnNotify’s arguments was passed as an array of objects to the observing method. That gave some serious challenges to find out how many arguments was passed and what type they were etc. Therefore it was decided to change the second parameter from an array of object to an arguments object deriving from Dynamicweb.Extensibility.NotificationArgs keeping both versions for compatibility.

With the second parameter as a type safe arguments object with properties of the passed object instances, it made it simpler to code against.


A notification subscriber of the new model.

That introduced a new issue – now we had 2 types of OnNotify because of compatibility. We now see often that developers new to Dynamicweb are not aware of this, and uses the wrong OnNotify in their subscriber – making their code not work.

The change

With Dynamicweb 8 this will change – by deprecating and removing the old OnNotify method that receives an array of objects. So Dynamicweb 8 will ONLY have the new type of OnNotify that is passed with a NotificationArgs object.

So what does that mean?

That means that we have 24 notifications that will change. If you have notification subscribers observing one of these, you need to update your code. 13 of these are related to the old cart of Dynamicweb eCommerce. 5 of them with the Pageview object.

So here is the list of notifications that have changed:
  • Pageview
    • Notifications.Standard.Page.Loaded
    • Notifications.Standard.Page.OnOutput
    • Notifications.Standard.Page.AfterOutput
    • Notifications.Standard.Page.PageTitle
    • Notifications.Standard.Page.Loaded
  • Cart (v1 & v2)
    • Notifications.eCommerce.Cart.Loaded
    • Notifications.eCommerce.Cart.Deleted
    • Notifications.eCommerce.Cart.Line.Added
    • Notifications.eCommerce.Cart.Line.Removed
    • Notifications.eCommerce.Cart.Line.Increased
    • Notifications.eCommerce.Cart.Line.Decreased
  • Order (Related to Cart v1 and NOT cartv2)
    • Notifications.eCommerce.Order.Steps.PaymentSucceded
    • Notifications.eCommerce.Order.Steps.CustomerInfoHarvested
    • Notifications.eCommerce.Order.Steps.FeesHarvested
    • Notifications.eCommerce.Order.Steps.Confirmed
    • Notifications.eCommerce.Order.Steps.PaymentFailed
    • Notifications.eCommerce.Order.Steps.PaymentCanceled
  • Order
    • Notifications.eCommerce.Order.State.Changed
  • Products
    • Notifications.eCommerce.Stock.StatusChanged
  • Extranet
    • Notifications.ExtranetExtended.User.Created (Deprecated anyways because of UserManagement)
  • Newsletterv3
    • Notifications.NewsLetterV3.Newsletter.Sent
    • Notifications.NewsLetterV3.Recipient.Created
    • Notifications.NewsLetterV3.Recipient.Updated
    • Notifications.NewsLetterV3.Recipient.Deleted
If you have Notification Subscribers in your custom code observing any of these, you will get compile errors and need to update some code.


This is how you subscriber could look now - using the old model.


And this is how it should look after upgrading to Dynamicweb 8 - using the new model.

Important change #2

Another issue with notifications in Dynamicweb 7 is the naming – we have different ways of naming notifications:
  • Placing them in the Notifciations namespace:
    • Dynamicweb.Notifications.eCommerce.*
  • And placing them with the feature/module
    • Dynamicweb.Content.Commenting.Notifications.*
This is also changed so we have a more uniform way of naming them. That means that i.e. Dynamicweb.Content.Commenting.Notifications.* are moving to Dynamicweb.Notifications.Commenting.* and Dynamicweb.Ecom7.Cart.Notifications.* are moved to Dynamicweb.Notifications.eCommerce.Cart.* (Also not that Dynamicweb.Ecom7.Cart have been moved to Dynamicweb.eCommerce.Cart).

Modules have their notifications in their own namespace – i.e. News in Dynamicweb.Modules.News.Notifications.*

What else?

That is the main 2 changes to the notification system. All notifications remains, but they may have moved or changed their signature – it requires a little recoding when upgrading a solution.

Apart from that, we have also introduced a bunch of new notifications in Dynamicweb – i.e. in eCommerce namespace for Products, Groups and Orders so you have even more places to extend Dynamicweb.

Hope you agree with this change – let me know if you have comments or ideas for further improvements. Or threats for changing this :-).




1 Comment

  1. Kevin Steffer 12 October 2011 22:26
    Great!
    Man ... I have been searching for a subscriber I mean I have seen somewhere in the API many times.

    The changes seems to make it a very meaningful way to structure them, great work!

Leave a comment, thanks!

Log in in the top with the username and password you use on the developer site. Then the form will know who you are. Profile images from http://www.gravatar.com/.