Web Client Software Factory 5th drop: Composite Web UI Application Block, ObjectBuilder, Page Flow Application Block…

Topics: Web Client Software Factory
Oct 19, 2006 at 4:06 AM
Last week we made a lot of changes to the reference implementation. Actually, we performed radical changes to the solution! And I am really happy about it because the application is looking really good!

The major changes we made are the following:

Added the Composite Web UI Application Block (I'll call it simply 'CWAB' in this post) and ObjectBuilder. As you might guess, CWAB is a kind of CAB ported to suit the web environment, but there are some CAB things you won’t find in CWAB and some new CWAB things you won’t find in CAB. This is because we are porting/developing stuff in an on-demand basis, that is, “don’t do until you really need it”, and of course because CWAB and CAB target different developing models (Windows applications / web applications).
The main advantage about using CWAB is that it will provide users very useful features as regards modularity. Users familiar with CAB will also be happy because much of the know-how of CAB can be applied to CWAB (with some differences, though). These are some of the differences you will encounter while digging into CWAB:
The “Module” concept in CWAB is quite similar to the one defined in CAB but with some changes we had to make to match the web development model. For instance, apart from having a class library, you have a “module folder” in the main web site where you store your views (web pages up to now; we might include support for web user controls in the future). Another difference is that CWAB always creates a WorkItem per module (in CAB the developer decides whether to create a WorkItem or not for the module). Module WorkItems let you create elements such as services that live in the module scope, that is, they can be accessed only by elements in the module. And of course, you can still register global services (services shared across all modules of the application) because you can access the root WorkItem through the module WorkItem. I strongly recommend you to see the Module Quickstart to better understand what a Module in CWAB is.
The WorkItem concept has changed too. In CAB a WorkItem acts as a container of elements and besides contiains business logic to fulfill a use case. In SC-SF we also introduced the ControlledWorkItem/WorkItemController concept to separate these two responsabilities (containtment and business logic, respectively). In CWAB, a WorkItem is just a container, with no business logic. Now the business logic mainly resides in modules' controllers (for instance, see the ElectronicFundsTransferController in the Reference Implementation). Moreover, the WorkItem hierarchy is different. In CWAB there is a root WorkItem (similar to CAB's root WorkItem) and it contains one child WorkItem per module. This means that each module has a corresponding WorkItem. Please note that all WorkItems exist at the application level, and are created when the application starts.
Modules can also expose its features to the Web UI by registering their own site map nodes with the new ISiteMapService. The ISiteMapService is consumed by a custom site map provider included in CWAB which reads all the site map nodes that were registered with the ISiteMapService and creates a site map that can be consumed from ASP.NET navigation controls.
Created a new data source control. We didn’t come up with an appropriate name yet, so we simply named it “CustomDataSource” J Why we created this control? We created this control because we needed a data binding mechanism more “MVPC friendly” than what ASP.NET built-in datasource controls provide. In the MVPC pattern, the presenter is the one that controls the view’s state. Therefore, it tells the view what information to display and also when it should be displayed. We wanted to use the ObjectDataSource control, but we find it somehow incompatible with the MVPC model, mainly because the ObjectDataSource (that lives in the view) decides when to get the information to be displayed, and that behavior doesn’t suit well with the MVPC pattern. Moreover, we think that this approach is much more simple (from the user's point of view) than what we had been using before (the TransferTemplateDataSource) and will provide users similar user experience to what ASP.NET built-in data source controls provide (you can create it and set it up using the designer).
As you may imagine, we also had to update the main application class (ShellApplication in CAB-SCSF) in CWAB to match the ASP.NET model. The main application class is now called “WebClientApplication” and is extended by the global application class (Global.asax). The WebClientApplication class is in charge of creating the root WorkItem, registering required services and loading all the modules of the application during the application start up.
We added a StateValue class to provide state management. You can use this class in your application to store data that needs to be persisted between requests. Currently, we provide an implementation that stores the data in the ASP.NET session, but you will be able to extend it to use a different persistence mechanism. Moreover, we created an ObjectBuilder strategy that injects the state data into your objects when being created. (ObjectBuilder’s magic J). Take a look at the ElectronicFundsTransferController class to get better understanding of how to use the StateValue class.
Added ObjectBuilder to build the web pages. I love it! J Just put an attribute there and you will get what you need J. (Ok, I know it is not that easy but once you become familiar with it you can’t stop using it!)
Packaged all the page flow stuff in the new Page Flow Application Block. This block enables you to use page flow in your web site using Windows Workflow Foundation to define it, and is extensible enough so that you can replace the Windows Workflow engine with another workflow engine.
Besides from the reference implementation, we have been working very hard to improve the documentation and the quickstarts. Please take a look at them and give us your feedback!

Get it from the Releases section.
Oct 19, 2006 at 9:20 AM
Great Stuff - What's in the works for next week?
Nov 10, 2006 at 10:32 AM
Hi!

This is sad that there will be no code reuse for Windows and ASP.NET. Now only Business layer can be this same.
Dec 15, 2006 at 3:01 PM
This is really good stuff.
Dec 15, 2006 at 11:50 PM
Thanks! But this is old, we are now in release N-12 :)

Get it from the Releases section.

Mariano Szklanny
http://staff.southworks.net/mariano