This project is read-only.

Disable Navigation controls when Target Module is not loaded

Oct 15, 2008 at 4:03 PM
Hi,

I am looking in SCSF for my system. I am trying hand at it to see how various things can be done in it..

My Test Application has two modules named "Source" and "Target".

smart parts in "Source" module has two button which will navigate the user to views in "Target" module.

In case where in "Target" module is not loaded ( ex: authorization) I want the two buttons( which navigates user to "Target")  in "Source" module to  be disabled( or hidden)...

I would appriciate if any one could thow some light over it..

Thanks,..
Oct 20, 2008 at 6:12 PM
The ActionCatalogService is the appropriate tool for handling security -based GUI restrictions. There's a pretty good post on it here:

http://weblogs.asp.net/bsimser/archive/2007/10/26/taming-the-actioncatalog-in-scsf.aspx

The other thing that you can do is query the IModuleLoaderService, which is available at the root level. For example, this just prints out the names of the loaded modules. You could check this
list for a matching name, and if it doesn't exist, then hide the buttons:

IModuleLoaderService moduleLoaderService = RootWorkItem.Services.Get<IModuleLoaderService>();

foreach(var info in moduleLoaderService.LoadedModules)
{
   Console.WriteLine(info.Name);
}

The thing to keep in mind with this approach is that the load order of the modules will matter. If you execute the code to hide/show the buttons BEFORE the Target module would be loaded, then they'll always be hidden. The ActionCatalogService will therefor provide you with a much more complete security setup (something you can base on roles/actions/permissions, instead of the state of a potentially loaded module).