Tabbed browsing with WCSF

Topics: Web Client Software Factory, Project Management Forum, User Forum
May 7, 2009 at 9:04 AM
Edited May 7, 2009 at 11:00 AM
Hi

The browser is the new operating system, the tab is the new system process, the tab bar is the new taskbar. With this in mind I thought I should actively use the modern browsers tabs when createing an CRM application with WCSF.

When a user want to see details for a customer the customer details opens in a new tab. I want this new tab to create its own instance/proxy to a customer-service. When a user wants to open another customers details a new tab is opened and yet another instance/proxy is created for this tab.

I have not found any good solution to handle this functionality yet. WCSF and its ObjectBuilder is not the thing to use as I can see. I tried this code in the controller:

[CreateNew]
public MyCustomerService CustomerService
{
    get { return customerService; }
    set { customerService = value;}
}

But, as expected, this creates a new instance of the customer service every time the controller reloads. And it reloads quite often. I want to create ONE, only ONE, instance of the service per browser tab.

When a user opens the customer details in a new page I could get the customer ID from the querystring of the page and create an instance using the customer ID as an identificator. The service instance (proxy) could be added to the moduleService collection (IServiceCollection) and when the controller needed it it could get this instance by its name. If this sounds like a good idea how do I get the moduleService collection? And do I have access to the querystring collection from the controller?

Any suggestions?

Developer
May 8, 2009 at 9:48 PM

Hi RightCoder,

 

The behavior you are looking for (managing object instantiation based on client opened tabs) in not a simple scenario to achieve.

 

In the most general scenario the server replies to stateless requests. So the first thing you will need to resolve is how the server will be able to realize that the client is browsing in different tabs. You might be able to achieve this using client-side javascript and placing some tab information into the session. Once you get to uniquely identifiable  "tab sessions" you might extend object builder to have a strategy that creates new instances based on this "tab identity". Keep in mind that this will not be easy to implement. You might find this discussion useful:

·         How to handle dependency Injection(InterfaceDependency/ServiceDependency) dynamically based on incoming parameter?? 

 

To get the moduleService collection, you might find useful the How to: Register and Use Services from the documentation.

 

Regarding your question about accessing the querystring, you might find the following discussions useful:

·         ViewState in WCSF

·         How to handle QueryString in WCSF?

 

Hope it helps!

 

Matias Bonaventura

http://blogs.southworks.net/matiasb

May 11, 2009 at 7:58 AM

Hi Matias

Thanks for your response. I see that this can be difficult to achieve but I hope the solution I have come up with is as good as it is simple:

Instead of letting the server think about browser tabs I let the client take care of that. It is the client that should know that best. I'm not using the built-in functionalty that is available to me in the Web Client Software Factory. In the controller I have an collection (Dictionary<key, value>) where key is the ID of the tab and value is the service instance for that tab. This collection is saved in Session state and every time the controller needs an service instance it gets the ID of the actual tab from the request querystring. It search the collection and returns the service with the needed tab ID, if its not found a new service instance is created, added to the collection and returned to the controller.

This gives me some extra housekeeping code to do. I need to remove the service instance from the collection when its not used (tab is closed) etc. But I think this is an easier way than you are suggesting, but its not as elegant. Im not finished with this code, but I think it will work pretty good.

What do you think? Anyone else has any views on this design?