Transferring modules built prior to Sitefinity 3.6 to the new backend architecture: Breaking Control Panel modes into Views

Transferring modules built prior to Sitefinity 3.6 to the new backend architecture: Breaking Control Panel modes into Views

April 21, 2009 0 Comments

The content you're reading is getting on in years
This post is on the older side and its content may be out of date.
Be sure to visit our blogs homepage for our latest news, updates and information.

[This post is part of the developer's manual preview published on this blog. You can find temporary TOC here.]

 

As we have stated in the Overview of this topic, our first task is to break Control Panel modes into Views. Whereas ControlPanel modes used to be only the enumeration on which we used to create (hide or show) different controls, with Views we are actually going to create a separate control (View) for each of these modes.

 

Let us examine this task on the Sitefinity built-in Lists module. In the old implementation we used to have following enumeration representing various modes of the Lists module ControlPanel:
        /// <summary>Represents the display mode of the <see cref="ControlPanel"/>. </summary> 
        public enum DisplayMode 
        { 
            /// <summary>Displays all lists.</summary> 
            AllLists, 
            /// <summary>Displays a single list and all of its items.</summary> 
            ViewList, 
            /// <summary>Adds a new list.</summary> 
            NewList, 
            /// <summary>Edits an existing list.</summary> 
            EditList, 
            /// <summary>Adds a new item.</summary> 
            NewItem, 
            /// <summary>Edits an existing item.</summary> 
            EditItem, 
            /// <summary>Manages permissions of the lists module</summary> 
            Permissions 
        } 
 
Then, depending on the currently selected mode we would create the user interface in the CreateChildControls method, which used to look like this:
            switch (this.mode) 
            { 
                case DisplayMode.AllLists: 
                    this.CreateAllLists(); 
                    break
                case DisplayMode.NewList: 
                case DisplayMode.EditList: 
                case DisplayMode.ViewList: 
                case DisplayMode.NewItem: 
                case DisplayMode.EditItem: 
                    this.CreateListView(); 
                    break
                case DisplayMode.Permissions: 
                    this.CreatePermissionsView(perm.CheckDemand(CrudRights.ChangePermissions)); 
                    break
            } 
 
With further conditioning implemented in the CreateAllLists, CreateListView and CreatePermissionsView methods.

 

So, the first order of business is to create Views for each of the modes ControlPanel had. By doing that, we’ve ended up with following Views in the new implementation of the Lists module:

  • AllListsView
  • ListEdit
  • ListInsert
  • ListItemEdit
  • ListItemInsert
  • ListItemsAll
  • ListsAll
  • PermissionsView

You can see that the Views are following the modes very closely in their functionality and intention.

 

Now, that the Views have been created, new Sitefinity backend architecture will take care of all these conditions that we used to have to implement in order to always display correct UI. Once the Views are defined, we need to separate the ControlPanel template into a separate template for each View and finally move the event handlers and methods of ControlPanel to their respective Views.

 

With the Views separated, we can follow the instructions described in articles “What are Views?” and “Adding Views to ControlPanel” to wire up all the Views together into a module hierarchy.

progress-logo

The Progress Guys

View all posts from The Progress Guys on the Progress blog. Connect with us about all things application development and deployment, data integration and digital business.

Comments
Comments are disabled in preview mode.
Topics
 
 
Latest Stories in
Your Inbox
Subscribe
More From Progress
d12fcc0bdb669b804e7f71198c9619a7
5 Questions Automakers Should Ask to Improve Asset Uptime
Download Whitepaper
 
SF_MQ_WCM
2018 Gartner Magic Quadrant Web Content Management (WCM)
Download Whitepaper
 
What-Serverless-Means-For-Enterprice-Apps-Kinvey
What Serverless Means for Enterprise Apps
Watch Webinar