PDA

View Full Version : Trying to Create a Dynamically Changing UI


ErikHR
06-08-2007, 11:43 PM
I have just downloaded Spring.Net and am reading the documentation and have looked at some of the samples. I am trying to create an application that will have a dynamically changing UI based on which content database the user decides to connect to. I need dropdown menus, tab control tab pages and items on the tabs pages to be different base on the content database the user decides to connect to.

I was thinking I would create a master database that would store the application’s UI configuration. The application would get the UI configuration specific to the content database from a stored procedure in the master database when the user chooses the content database they wanted to connect to. At that point the tab pages, menu items etc..would be recreated.

Base on what I have been reading about Spring.Net it seems like I can use it to facilitate this process of dynamically regenerating the UI or pieces of it.

At this point I am not sure what the best approach to take would be to try to implement something like this and what further reading I need to do. Any tips and/or suggestions would be greatly appreciated.

Thanks,
Erik

Mark Pollack
07-07-2007, 01:17 AM
Hi Erik,

In terms of using dependency injection features it is usually defined at runtime in XML. You can create object definition dynamically, but I don't think you want to be doing that in this case.

It is worth mentioning that there is a nice runtime feature on the application context, the method ConfigureObject (http://www.springframework.net/doc-1.1-M1/sdk/2.0/html/Spring.Core~Spring.Objects.Factory.IObjectFactory~ ConfigureObject.html) . The ref doc has some info here (http://www.springframework.net/doc-latest/reference/html/objects.html#objects-factory-client).

object ConfigureObject(object target, string name)


target: The object instance that is to be so configured.
name : The name of the object definition expressing the dependencies that are to be injected into the supplied instance.


Essentially you can define a configuration template and pass in an instance of a class, the ConfigureObject will wire up the rest of the dependencies. Depending on how you want to design the application, the templating feature might come in handy.

I'd suggest leveraing Spring at first to write your data access layer/service layer so that you can develop interfaces for retrieving the values from a database. When you want to perform some testing in isolation of the service/database you can easily replace the database implementation with a stub implementation. Leveraging Spring's ADO.NET framework (http://www.springframework.net/doc-latest/reference/html/ado.html)would also help in writing your data access layer code.

Once you have a simple way to get say a string array to populate a drop down based on runtime criteria, you can populate that control's drop down in the normal programmatic way, and then maybe pass it off to ConfigureObject to wire up some 'global' dependencies that maybe useful for that control.

Hope this helps.

Cheers,
Mark