Amateur
01-03-2011, 06:18 PM
I am new to Spring.Net and currently implementing it into my .net web application. I have some questions that I hope someone can help me out with.
Firstly I have several .aspx pages that all inherit from a BasePage. Within the BasePage I have some properties that I want to inject values in to via spring. Now I am able to wire up the configuration as follows to achieve this:
<object id="identityManager"
type="XXX.IdentityCookieManager, XXXX.Cookies"
singleton="false">
<constructor-arg name="identity" ref="identity" />
</object>
<object name="basePage">
<property name="IdentityManager" ref="identityManager" />
</object>
<object type="Default.aspx" parent="basePage" />
My question is, do I have to specify every page in my application or is there a quicker way of doing such?
My next question is a little more complex. For each .aspx page, it has a controller object that carries out the operations for the page with the result passed to the page to display on screen. All page controllers inherit from a BaseController which again has some properties that I want to populate with spring.
Config for populating base controller is:
<object id="baseController">
<property name="ResourceManager" ref="controllerResources" />
<property name="IdentityManager" ref="identityManager" />
<property name="Logger" ref="logger" />
<property name="Configuration" ref="configuration" />
</object>
The controller for the page is set in the code behind of the page like this:
var views = new List<IView>() { this, this.MasterPage, this.ucControl };
this.Controller = new HomeController(views);
When the HomeController object is instansiated, the base controller properties are not set. Is there a way I can wire it up via spring that once an object that inherits from BaseController is instansiated, wire up the base controller properties?
I did look at assigning the Controller via spring config but it was a bit messy.
Any my last question has got to do with the global.asax. Is it possible to inject properties in to this that are available in Application_Start. At the moment I am injecting in to the global.asax but the properties are not populated for the Application_start method but are for subsequent methods, eg. Application_error
<object name="HttpApplicationConfigurer" type="Spring.Context.Support.HttpApplicationConfigurer, Spring.
<!-- Global.asax -->
<property name="ApplicationTemplate">
<object>
<property name="Logger" ref="logger" />
</object>
</objects>
Firstly I have several .aspx pages that all inherit from a BasePage. Within the BasePage I have some properties that I want to inject values in to via spring. Now I am able to wire up the configuration as follows to achieve this:
<object id="identityManager"
type="XXX.IdentityCookieManager, XXXX.Cookies"
singleton="false">
<constructor-arg name="identity" ref="identity" />
</object>
<object name="basePage">
<property name="IdentityManager" ref="identityManager" />
</object>
<object type="Default.aspx" parent="basePage" />
My question is, do I have to specify every page in my application or is there a quicker way of doing such?
My next question is a little more complex. For each .aspx page, it has a controller object that carries out the operations for the page with the result passed to the page to display on screen. All page controllers inherit from a BaseController which again has some properties that I want to populate with spring.
Config for populating base controller is:
<object id="baseController">
<property name="ResourceManager" ref="controllerResources" />
<property name="IdentityManager" ref="identityManager" />
<property name="Logger" ref="logger" />
<property name="Configuration" ref="configuration" />
</object>
The controller for the page is set in the code behind of the page like this:
var views = new List<IView>() { this, this.MasterPage, this.ucControl };
this.Controller = new HomeController(views);
When the HomeController object is instansiated, the base controller properties are not set. Is there a way I can wire it up via spring that once an object that inherits from BaseController is instansiated, wire up the base controller properties?
I did look at assigning the Controller via spring config but it was a bit messy.
Any my last question has got to do with the global.asax. Is it possible to inject properties in to this that are available in Application_Start. At the moment I am injecting in to the global.asax but the properties are not populated for the Application_start method but are for subsequent methods, eg. Application_error
<object name="HttpApplicationConfigurer" type="Spring.Context.Support.HttpApplicationConfigurer, Spring.
<!-- Global.asax -->
<property name="ApplicationTemplate">
<object>
<property name="Logger" ref="logger" />
</object>
</objects>