Click here to Skip to main content
Click here to Skip to main content

User Interface Process Application Block ( Part 2)

, 26 Jul 2005
Rate this:
Please Sign up or sign in to vote.
User Interface Process Application Block

Introduction

In my previous article of this series http://www.codeproject.com/dotnet/UIPAB.asp, I had tried to explain what is UIPAB all about and on what circumstances we should use it. Now in this article, I am explaining it that How we should use UIPAB in our application.This article clealy explains about how to configure the configuration file for working with UIPAB.

Programming with UIP Block Implementation 

First thing is that we need to create a project that can be either windows app or ASP.NET and then set a reference to UIP assembly. UIP assembly is generated by compiling the project that you get when downloading the UIP from the net. Then you need to create a class that derives from ControllerBase class. You create your individual views and derives those from the base classes and if you want strongly type objects rather than hash tables , then you can implement the state objects. 

 

Starting tasks

 

To get the task started there are different ways which depends on the navigation model we used. They have the UserControlNavigation within windows forms. You can now force a user to go in a particular sequence when contained with complex controls within the form. It is not available presently for the web application but may be for the subsequent version they may release it. So in case if you are working with the graphnavigation which is the sequential type of navigation then you need to call StartNavigationTask  on UIPManager which has multiple overload. 

 

Implementing Controller

 

You create a custom class which derive from the ControllerBase and number of controller depends on number of  tasks you have. This ControllerBase class is available in Microsoft.ApplicationBlocks.UIProcess. Best way is to choose one controller per tasks but in case your application is fairly small, you can have one controller per application. State is maintained on behalf of tasks. Well another thing we do is we implement navigation method  which specify which view to demonstrate next based on the contents of Config class. State is accessible in controller as it inherits from ControllerBaseClass and ControllerBaseClass have the property called state through which we can directly access the state.

 

 Views

 

Views are derived from their base class: WebFormView or WindowFormView. These base classes are available in Microsoft.ApplicationBlocks.UIProcess It access the state from the controller to initialize itself and to present itself , if necessary take the feeback from the user, modify it and then when you need to navigate to another view, you can save the state back. State is saved in a hash table which is a key value pair. If you need to access strongly type state objects, you can also create your own state. One things that is important is that as soon as we closes the view, we need to store state back. One things is to be kept in mind is that when we need to first change the base class and the layout. Sometimes if we changes the layout and then changes the base class, VS.NET got unhappy and makes some problems in displaying the UI controls.

 

 

Configuration files

 

Plays a very important role in UIPAB and all sort of configuration information is stored in the configuration file. Its web.config for web applications and <applications>.exe.config for windows applications.

 

If we talk  about the configuration files , there have the following schema.

 

<configuration>

          <ConfigSections>

<section>

          </ ConfigSections>

          <uipConfiguration>

                    <objectTypes>

                   </objectTypes>

<views>

</views>

 

<navigationGraph>

 

</navigationGraph>

</uipConfiguration>

 

</configuration>

 

First of the things is the configSection which tells how application block is plugged into the applications.

 

<configSections>

          <section

          name="uipConfiguration"

          type="Microsoft.ApplicationBlocks.UIProcess.UIPConfigHandler,  Microsoft.ApplicationBlocks.UIProcess" />

    </configSections> 

 

 

In this we are specifying that we have .NET UIPAB information will be stored in the uipConfiguration section. We can change it to any other section, if necessary and this section is been handle by a class called uipConfigHandler which resides in Microsoft.ApplicationBlocks.UIProcess namespace. Now UIPConfighandler expect the some standard schema  which consist of three elements.

 

  1. <ObjectTypes>
  2. Views
  3. navigationGraph

 

 

each of these elements also have the sub elements.

Now as far as objectTypes is concerned, it contains the type information about various pieces of architecture. So it contains information about viewManager, state , controller and statePersistenceProvider  that we should use,

 

<iViewManager

          name="WinFormViewManager"

          type="Microsoft.ApplicationBlocks.UIProcess.WinFormViewManager, Microsoft.ApplicationBlocks.UIProcess, Version=1.0.1.0,Culture=neutral,PublicKeyToken=null"/>

             

           <state

                name="State1"

                type="UIProcessQuickstarts_MultiNavGraph.State1, UIProcessQuickstarts_MultiNavGraph, Version=1.0.1.0, Culture=neutral, PublicKeyToken=null"/>

          

           <controller

                name="DemoController1"

                type="UIProcessQuickstarts_MultiNavGraph.DemoController1, UIProcessQuickstarts_MultiNavGraph, Version=1.0.1.0,Culture=neutral,PublicKeyToken=null" />

               

              

             <statePersistenceProvider

                name="SqlServerPersistState" 

                type="Microsoft.ApplicationBlocks.UIProcess.SqlServerPersistState, Microsoft.ApplicationBlocks.UIProcess, Version=1.0.1.0,Culture=neutral,PublicKeyToken=null"

                connectionString="Data Source=localhost;Initial Catalog=UIPState;user id=UIP;password=U1Pr0c3ss"/>

       

        </objectTypes>

 

 

 

So each sub element of the ObjectTypes have the name and type, where type specify which implementation we are using. For e.g. we are using the IViewManager we will see that we are implementing the winFormViewManager, in case, if we want to make our own base type, we have to specify here. Most of the time we are happy with the default type. So ObjectType identifies the core pieces of architecture and its implementation.

 

 

After that, it comes the Views elements.

 

 

 

 

<views>

<view name=”start” type=”start.aspx” controller=”OnlineController” />

<view name=”first” type=”first.aspx” controller=”OnlineController” />

<view name=”second” type=”second.aspx” controller=”OnlineController” />

 

</views>

 

In the view section, we specify all the views that are in the application. Now it contains three attributes.

 Name attribute specify the name we would refer the view in the controller. So from the actual views, we would call the navigation method of the controller and the controller then refer to view with this logical name and the physical name of the file is specified in the type attribute. Apart from this, we also specify the controller with which this element is expect to work with in the controller attribute.

 

Now comes the navigation graph

 

 <navigationGraph

                    name="navA"

 startView="Form1"

 state="State1"

 statePersist="SqlServerPersistState" iViewManager="WinFormViewManager">

          <node view='Form1'>

                <navigateTo navigateValue="next" view='Form2'/>

          </node>

           <node view='Form2'>

                <navigateTo navigateValue="previous" view='Form1' />

                <navigateTo navigateValue="next" view="Form3"/>

            </node>

            <node view='Form3'>

                <navigateTo navigateValue="previous" view='Form2' />

<navigateTo navigateValue="showPreviousNavState" view='IAmModal' />

            </node>    

 

        </navigationGraph>

       

 

Now in navigation graph there are many attributes. Name attribute is used to specify the name of the navigation graph so when we call the StartNavigationGraph then we need to specify this name. so when UIPManager calls the startnavigationGraph method, engine checks the configuration file to check the name and also check which should be the view we should display first which is specified in the startView attribute where we give the logical name of the view, 

 

 

Apart from that, it contains the node section for each view, where we specify two things. navigateValue and View. Navigatevalue  specifies the command that controller specifies it to and then after receiving the command, where should he go to is specified in the view attribute which again specify the logical name of the view. So there is a slight performance impact but it provides a lot of flexibility in our application.

 

Ok now see the functionality.

 

We have the view and we need to move to another view. So what we do is that we should first save the state of this view. This is done by accessing the state property of the controller which is again the key-value pair so we will do something like this.

 

Controller.State["someState"] = txtState.Text;

 

After this we specify the navigationmethod of the controller. Something like this:

 

((DemoController1)Controller).Form1btnNext();

 

Where we need to call the Form1btnNext method of the controller called DemoController1. we need to cast it into appropriate type

 

 

Now if we look in the controller class for our application, it is derived from the controllerBase class of the application and in the form1btnNext

 

public void Form1btnNext()

                   {

                             // Navigate to the next view

                                        State.NavigateValue = "next";

                             Navigate();

            }

 

 

We are specify the navigate value and then calling the Navigate method else we would have done this

 

Navigate(“next);

 

Both gives the same result. In the Controller class, we would have to create a constructor that takes the navigation object. By this. We ensure a way to loosely couple our view and each view is able to know its own state. This is where the advantage of UIPAB comes into the scene. Now Through this article I tried to make sure that configuration of UIPAB in web.config file is very easy to use. Through this series of articles, I tried to make sure that it is really easy to work on UIPAB. Full web.config file is available with the zip file that I am attaching with this article.

 

Conclusion

 

This series of  article was meant to explain all about configuration of UIPAB , why is it used and How to use it.      

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Nishith Pathak
Web Developer
India India
Nishith Pathak is an avid reader,Prolific writer, Speaker for Microsoft India,Published Author of APress and a Microsoft Purist.He is MVP, MCPD, MCTS MCSD.Net,MCAD.Net(EA),MCSD. His proficiency lies in exploring Microsoft technology and to share them with other peers. He is a contributing author and an avid technical reviewer for multiple electronic and print publications. He has recently co-authored a book on WCF called Pro WCF: Microsoft Practical SOA Implementation for APress Inc, USA. Over the years, he has also been involved in providing consultancy and training services to corporations. He has been awarded with Microsoft Most Valuable Professional (MVP).Working since beta version of .Net makes his competecy in .Net. He can be contacted at NisPathak@Hotmail.com or at his blog http://DotNetPathak.Blogspot.com. Currently he is focused on key areas of the Microsoft platform, specifically Distributed Computing, service orientation and exploring VISTA and help companies architecting solutions based on Service Oriented Architecture.

Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Mobile
Web01 | 2.8.140718.1 | Last Updated 27 Jul 2005
Article Copyright 2005 by Nishith Pathak
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid