Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

UI Implementation in Menu Extensions

1. Rendering
2. Security Implementation
3. Caching of sitemap

Rendering

Once the Sitemap has been created using the database and the tree structure has been obtained we
show the menu using Milonic menus. The tree is traversed through using the BFS(Breadth First
Technique) technique. For every node during the traversal we create a milonic menu tag.

Security

During the traversal of the sitemap tree we check for the security of every node. If security returns
false we do not show that particular menu and its children on that page.

For checking the security of a particular node we activate a class using reflection. The fully qualified
name of the class is obtained from the DB. This class should implement the interface
IMenuSecurityCheck .Therefore every node can have a separate security implementation and that
logic can be written outside of core by creating a new class and giving its fully qualified name in the
security column of that node in the DB. This helps us in creating new security implementations
outside of core which can be used as extensions for existing or new nodes.

Caching

The sitemap is accessed using the .NET static function SiteMap.RootNode . This method build the
sitemap every time it is called and returns the root node of the sitemap. We cache the root node in
the application context by creating a variable in global.asax . so that every time we need not build
the sitemap again.

We also need to do some caching in the session context for security because the security value for
every node is not the same for every user mode in the application. Therefore we need to cache the
security in the session context which is user specific. This is done using a dictionary which stores the
values of security for every node based on the node’s unique identifier. This way the security
functions are called only the first time a page is accessed by a user. The next time the values are
picked from the hashtable.
Creating a new extension menu or change the properties of an existing one

1. Add a new row in the extensions table in the database.


2. Create a new security class for that row or use an existing one.

1. Add a new row in the extensions table in the database

A new row can be added to the extensions table for the following purposes

a) Create a new menu item whose parent is a core menu item

1.) To create a new menu item we need to add a row in the TBL_SiteMap_Extension table and
fill in all the properties for that item such as UniqueIdentifier,Title, Description,URL,ToolTip,
visibility, Level( Height from Root Node), Ordinal( The position of a node under its parent),
its type(which will determine the type of rendering to be applied on that node), IsActive ( to
be disabled if the module is not active) and Security( the fully qualified name of the class
which contains the security implementation for that menu).

2.) In addition to the above we need to also give the parent id of this node in
Parent_SiteMap_FK which will determine the parent of our new menu item.

b) Create a new menu item whose parent is also a new menu item

1.) Do first step in 1.) above


2.) Instead of adding a parent in Parent_SiteMap_FK we add the parent in Parent_Ext_FK. This
will correspond to the id of a extension menu which we have already created.

c) Change an already existing menu item

We can change the follwing of an existing menu item - Title, Description,URL,ToolTip,


visibility,Ordinal, Security. This can be done by

1.) Do first step in 1.) above. We need to ensure that we put the original LevelVal and
SiteMapType_Fk of the menu we are changing as these can not be changed by this process
2.) Add the ID of the core menu we want to change in SiteMap_Fk

2. Create a new security class for that row or use an existing one

For every menu we need a security implementation to decide if that menu should be should be
shown or not for that particular menu.
a) Security for new Menus

For new menus we need new security classes. So we create a class which implements the
IMenuSecurityCheck interface. This class will have a method

bool MenuSecurityCheck(WebUtilContext pc, int nodeid)

This method will return the security value of that particular node. One class can also be used for
multiple menus and the menus can be differentiated on the basis of node Id which gives the
unique identifier of the menu to the method. Once this class has been created we can enter the
fully qualified name of this class in the Security Column of the new Menu.

b) Security for Core menus

We can also change the security implementation of an already existing menu by using the steps
in (Change an already existing menu item) and changing the value in Security column

You might also like