Home
01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
This is the personal homepage of Christopher Chestnut which
also contains information about my hobbies of which include LARP Live Action RolePlay. This First Page is a blog
page or Live Journal where I post what has been happening recently in my life and any recent upgrades to the
site. Enjoy.
Archive for March, 2010.
Back to Main Page - <- Previous month - Next month ->
Presentation class woes solved
Using spring.net and nHibernate I was creating a class in the presentation layer to display the contents of a container. Now normally the presentation logic for an object would be in the webpage itself and thus the tying up of data access would be quite simple. Simply add a new line to your web.xml as below.< object type="test.aspx">
< property name="ContainerBLL" ref="ContainerBLL">< /property>
< /object>
This would simply create the connection between the page test.aspx and the business logic layer's object ContainerBLL. I had however created my own class to house the presentation logic for displaying and dealing with a container, the reason for this simple, I wouldn't be duplicating effort if I needed to interact with a container on a different page, I would just be calling the same single class. This called its own problems as it was the container presentation logic class which was calling ContainerBLL not test.aspx so I needed to tye that class in somehow.
After a bit of tooing and froing I thought about spring.net's use of interfaces and tied it in that way. First I created an interface for the presentation class.
public interface
IcontainerInterface {
IContainerBLL ContainerBLL { set; }
ArrayList fieldObjects { get; set; }
ArrayList loadContainerEdit(Page page, int typeID);
}
public class containerInterface : IcontainerInterface
{
And then changed the web.xml to reference the class as a part of the page.
< object type="test.aspx">
< property name="containerInterface" ref="containerInterface">< /property>
< /object>
And finally the clever bit was altering the Business logic layer's Business.xml to create internal references to the business logic layer objects, not database access objects like what would usually be stored here.
< object id="containerInterface" type="NS.containerInterface, NS">
< property name="ContainerBLL" ref="ContainerBLL"/>
< /object >
Now it is working properly I can work on the more complex presentation logic.
Posted by Christopher Chestnut on 2010-03-02 13:50:00
Very useful site
Working with the new frameworks of Spring.net and nHibernate I came across this article which has been invaluable sussing out spring. Of course there is the spring manual but when just starting I found it explained many of the concepts of dependency injection that spring is famous for.In summary spring does a load of the coding for you, you create interfaces for your classes, data access layer, business logic, and presentation layer and then create interfaces for them. Initially I could not understand why you would want to add this extra level of abstraction to the class, but this article explains that spring uses these interfaces to add it's classes to yours making it work. Its class, pun intended.
http://www.developer.com/.../Dependency-Injection-with-SpringNet.htm
Posted by Christopher Chestnut on 2010-03-02 13:28:30
Back to Main Page - <- Previous month - Next month ->
All material is copyright © Christopher Chestnut aka kamui unless explicitly said otherwise
No copyright infringement is intended nor implied.
No copyright infringement is intended nor implied.
This page was last modified on:
02/04/2010 12:15:29.


