Views hierarchy: Overview

Views hierarchy: Overview

April 01, 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 already mentioned in Sitefinity 3.6 module's backend is constructed from Views which are organized into a hierarchy, starting with the Control Panel class. This hierarchy allows us, as developers, several benefits when building modules, where two most important are:
  • Ability to manipulate the hierarchy at any level and work at once with multiple Views through their parent node
  • Ability to access the members of the parent Views (throughout the hierarchy) with a generic Host property
In this article we will examine these two properties of the hierarchical organization of the Views.

 


Ability to manipulate the hierarchy at any level


One of the biggest advantages of the hierarchical organization of the Views is the fact that we can take any given node of the hierarchy and replace or remove it with another View. Even more useful is the fact that we can reuse whole parts of the hierarchy in other modules and not just one single View. Following diagram illustrates these approaches.

As the diagram suggest, from the View hierarchy on the left we can remove the CommentsView and all the child view, such as CommentsList, CommentsInsert, CommentsEdit and CommentsPreview will be removed as well. The hierarchy beneath CommentsView will be completely change also if we replace the CommentsView View some other View.

 

Finally, we can add CommentsView View to another hierarchy (perhaps in a different module) and at the same time all the child views of the CommentsView will be moved to this new hierarchy. You can find out more about this approach in this article and also examine the sample products module to see the implementation where CommentsView View has been transplanted from Generic Content module to Products module.

 

Ability to access members of parent views


Since, both, ViewModeControl and ViewModeUserControl are generic types with generic arguments being the types of their hosts (parents), we are able to access the members of any parent Views along the hierarchy. Let us take a look at the following example:

The image above depicts an imaginary hierarchy of Views, where the top level View is Control Panel, followed by ShopsView and finally the last View in the current hierarchy is NewShopView. Since all the ViewModeControls have Host property, we can call the Host property to access the immediate parent, but since immediate parent is also a View mode control, we can also call it’s Host property to access its parent and so on.

 

So on the image, we see how we can access the ShopChainName property of the ShopsView, by simply calling this.Host.ShopCainName on NewShopView. If we need to go all the way to the top of the hierarchy, we can call this.Host.Host to get access to the members of the top View two nodes up the 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