NHibernate.Burrow causes controls on the page to DataBind too early in the page cycle

Description

Instead of the wwDataBinder controls provided in the NHibernate.Burrow sample, I am using the regular ObjectDataSource control along with regular DataBound controls in my application. What I found out is that, while NHibernate.Burrow IHttpModule is traversing the tree control in order to find Stateful fields, it is accessing all the controls on the page. This access is forcing the databound controls on the page to databind to their automatic datasource (in my case ObjectDataSource). The problem arises from the fact that these DataBinds are hapenning too early in the cycle namely the PreLoad event.

To provide a more solid example. Lets say I have an Employee object which is marked as EntityField. And lets say my ObjectDataSource calls a method in the page that returns this Employee object. Since the IHttpModule accesses all the controls on the page including the databound controls during the PreLoad event, it causes the databound fields (such as DropDownLists) to databind. When these controls try to databind, they call the ObjectDataSource's SelectMethod which is the method that is supposed to return the Employee object. However Employee object is still null because NHibernate.Burrow still haven't populated it yet.

I believe there is no need to traverse the whole control tree everytime a page is requested since Statefulfields are already set when the assembly is compiled. A better approach would be to tap into Application_Start and traverse all the classes and fields in the assembly and do this only once.

Environment

None

Activity

Kailuo Wang 
December 18, 2008 at 6:36 AM

the problem mentioned in this issue will be solved by

Kailuo Wang 
December 18, 2008 at 6:35 AM

Manuel, that's a good idea. I've created a new issue on that.

Manuel Abadia 
December 18, 2008 at 5:48 AM

Kailuo, what about using a ControlAdapter for Page and UserControl to load/save the state instead of traversing the control tree to avoid the problem Ender is facing?

Kailuo Wang 
December 11, 2008 at 12:26 PM

I am closing this because it's not really a bug.
Also I added a new feature https://nhibernate.jira.com/browse/NHB-17 according to needs mentioned in the last comment

Ender Malkoc 
December 11, 2008 at 12:09 AM

I can't really make my ObjectDataSource independent from my page because I want to eventually mark my data object as [ConversationalField]. And since ConversationalFields can only be on a page or control, my ObjectDataSource needs to get it from my page. But I might be aproaching this wrong.

Upon further thought, what I suggested earlier is not really possible. Do you think it would be possible to add a configuration option to prevent traversing the controls? If user sets this option in the web.config he will not be able to use the StatefulField attribute in UserControls (thought it will still function in the Page). This would be a really useful option for people in my situation as well as people who needs better performance.

Won't Fix

Details

Assignee

Reporter

Components

Fix versions

Affects versions

Priority

Who's Looking?

Open Who's Looking?
Created December 10, 2008 at 12:47 PM
Updated December 18, 2008 at 6:36 AM
Resolved December 11, 2008 at 12:26 PM
Who's Looking?