These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: MVP, User Controls and NHibernate
PostPosted: Fri Dec 15, 2006 1:56 pm 
Newbie

Joined: Fri Dec 15, 2006 11:39 am
Posts: 7
I am using the latest copy of NHibernate and have decide to implement the MVP on the GUI side of things to help separate actions from each other and improve the unit tests that I can write.

I have a presenter and view that are implemented in various user controls so that I can drop these simple actions onto a page to get the results that I need. When I only put one user control on a page then everything works great. I have successfully put two user controls on a page and they both load the data as required. However the problem comes when I try and save any changes that are made on the screen. Both are tied to the same link so that you click the save button and the application will be saved. Since I want both user controls to function independent of each other. All the page does is tell each user control which application they need to display and what to do if a page event happens, an error happens or success happens (in this case the page redirects to the next page).

The page has a button to save, the event of clicking the save button fires the save application function of both user controls. In order to handle events correctly without problems when each event is fired it is spawned off into its own thread. Here is my problem I can't get both user controls to save. If I remove one of the user controls completely then everything works perfect but once I add the second control and the second thread then NHibernate no long registers that the second user control did anything. So it doesn't recognize a change.

My understanding is that the page requests a session from NHibernate and then passes it to each of the user controls. And because each user control is running independent NHibernate is passing the same session to both user controls. Which I think is were my problem is happening. I am trying to solve the problem without managing the sessions on such a granular level as it increases coupling which I am trying to avoid.

Does anyone know where I can go to look for help or has help for me directly?


Top
 Profile  
 
 Post subject: session per request
PostPosted: Sat Dec 16, 2006 9:31 pm 
Beginner
Beginner

Joined: Thu Apr 27, 2006 12:19 pm
Posts: 33
Location: Seattle, WA
The last time I used NHibernate with ASP.NET we followed the session per request pattern - basically each web request is a unit of work (session). To manage the session we created an HttpModule. We were also using multiple user controls which implemented the MVP pattern for testability etc. just as you are. There are many good articles about this, here are a couple:

http://www.codeproject.com/aspnet/NHibernateBestPractices.asp
http://blogs.intesoft.net/simon/articles/16.aspx


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.