Understanding CISF Portal Widget Framework
[As part of CISF we will ship an ASP.NET AJAX web portal in which you can host your custom security management applications. The portal allows users to personalize certain pages by selecting various widgets made available to them. The information in this blog post is informational only at this stage. We would suggest you wait until the code drop before creating any widgets. Also note that in a future release we plan to build a full web sandbox for widgets and so R1 widgets will need to be re-written. ]
Syam Pinnaka here.
Security Portal is one of the key components in CISF (more information about CISF will be blogged in future posts). Security Portal supports “widget framework” to allow anyone creating and adding widgets to security portal.
In this blog post let’s examine the widget framework briefly.
Widget framework comprises of two interfaces, IWidget and IWidgetHost.
IWidgetHost interface supports the functionality to host a widget. Each widget can be hosted in a widget host and widget host in turn can be added to Portal. Here is the declaration of IWidgetHost.
public interface IWidgetHost
{
int ID { get; }
void SaveState(string state);
string GetState();
void Maximize();
void Minimize();
void Close();
bool IsFirstLoad { get; }
void ShowSettings();
void HideSettings();
}
All the common widget actions like Minimize, Maximize and Close can be implemented using IWidgetHost. In addition, each widget host can keep a record of widget instance its hosting using widget ID. Widget state can be saved and retrieved using SaveState and GetState methods. IsFirstLoad is used to determine when a widget is first loaded onto WidgetHost. ShowSetttings and HideSettings can be used to show/hide settings pane of the widget.
IWidget provides the interface to implement for Portal Widget. Any ASP.NET user control can implement the IWidget interface to plug itself into CISF security portal.
Here is the declaration of IWidget.
public interface IWidget
{
void Init(IWidgetHost host);
void ShowSettings();
void HideSettings();
void Minimize();
void Maximize();
void FullScreen();
void Closed();
}
A reference to Widget host will be passed to Init method to make it easy communicating with Widget host during widget lifetime. Widget state can be retrieved and saved using widget host reference. ShowSettings, HideSettings can be used to implement custom actions like saving the widget state, changing widget look, UI before its closed and retrieving the saved settings before they are shown to the user. Minimize, Maximize, Closed can be used to do additional actions before the corresponding action is called in Widge host.
In the OnInit of widget host, widget host creates a new widget instance using widget id, adds it onto its body, stores a reference to the widget and passes widget a reference to itself so that future communication between widget and widget host using these referenced variables.
In the next blog post I will explain step by step process to creating a CISF Widget and adding it to the CISF Portal using the widget framework.