Re: Hibernate and Tables: Unexpected Snag: DirectLink prevents access to requestCycle?

Eric Everman <[email protected]>
Newsgroups gmane.comp.java.tapestry.devel
Message-ID <[email protected]>
Luke-

I created a helper bean to deal with Hibernate Sessions.  One thing I found 
is that the pageDetach event is not appropriate for committing & closing 
Hibernate Sessions in this type of situation:

**Client End
-User Fills out & submits a form

**Server Side
-Form fields values are set in the underlying page class
-FormSubmit listener method is called in the underlying class
-FormSubmit method obtains Hibernate Session & stores values
-FormSubmit method uses cycle.setPage("Success"); to indicate success

At this point, the pageDetach event is *not* raised for the current 
page.  Instead, pageEndRender() is called for the current page and control 
passes to "Success".  Thus, if you want to ensure that your Hib. Session is 
committed and closed based on a page event, you need to use the 
pageEndRender() event.

I can post the code for my helper class if you are interested - it allows 
you to obtain a session by calling getSession(IRequestCycle) and makes the 
assumption that it can find the SessionFactory as an attribute of the 
current ServletContext.

Cheers,

Eric Everman


At 11/21/2002, Luke Galea wrote:

>Hello all.. I am nearly done the development of a HibernateTableModel (and 
>corresponding SessionStateManagers, DataSource, etc ) for the MindBridge 
>contrib Table component.
>
>
>
>It s looking great.. but I am having a problem: The default column 
>component uses a DirectLink for the column header links that make the 
>table sort by that particular column. I have extended BasePage and created 
>DataStoreAccessingPage that can provide Hibernate sessions&
>
>
>
>It works by setting an attribute in the request cycle with the open 
>session so future requests will use the open session. During page detach 
>the session is closed.
>
>
>
>The problem is, when the DirectLink is called getRequestCycle returns 
>null.. can work around this by creating a session purely for the purpose 
>of completing the directLink.. but that isn t very elegant. Is there some 
>way around this? I could change the code to not use DirectLink.. but other 
>than this problem, DirectLink is ideal.
>
>
>
>Thanks in advance
>
>
>
>Luke Galea
>
>Software Development
>
><http://www.bluecatnetworks.com/>BlueCat Networks
>
>905-762-5225
>
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.