-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=3879090
By: hlellelid
Hi,
I am very new to ZK, and am working on integrating an existing Spring+Hibernate framework with the ZK UI. I have read the Small Talk and HOWTO related to integrating Hibernate + ZK (+Spring), but haven't yet been able to answer this question for myself.
The problem I am encountering is that in our application the Hibernate Session that is being bound to the thread by an OpenSessionInViewFilter object is not available to all of the ZK processes that serve that request. (At least, this is my analysis so far.) I'm assuming that this is because ZK handles events in separate threads, so the onCreate() event for a ZK component might be part of the same request, but won't have access to that Filter-bound Hibernate Session.
What I'm wondering is where is the correct/best place to store these "per-request"
objects like the Hibernate Session. All threads that handle a single request need access to that object, but clearly it cannot be shared with threads that are handling other requests. Is this something that the Execution interface was designed to address?
Thanks in advance -
Hans
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=3882033
By: henrichen
Yes, event is handled in seperate thread.
As for per-request object, you can store and retrieve it with
Execution.setAttribute() and Execution.getAttribute().
http://zk1.sourceforge.net/javadoc/2.1.0/zk/com/potix/zk/ui/Execution.html#setAt
tribute(java.lang.String,%20java.lang.Object)
You can get current Execution with static methods Executions.getCurrent()
Orignial message at:
https://sourceforge.net/forum/message.php?msg_id=3928193
By: henrichen
Since ZK version 2006/9/21 Freshly. Please add following listener in your application's WEB-INF/zk.xml and you can use Spring's OpenSessionInViewFilter(or
Interceptor) as usual.
It bridge the ThreadLocal resources to event thread automatically so now the ThreadLocal pattern should works.
<listener>
<description>Spring TransactionSynchronizationManager handler</description> <listener-class>org.zkoss.zkplus.spring.SpringTransactionSynchronizationListene
r</listener-class>
</listener>
Asked: 2006-08-22 13:48:08 +0800
Seen: 351 times
Last updated: Sep 20 '21