Home

« September 2010

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.

Archives / Back to Main Page

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



*