I'm upgrading ZK and I have encountered some problems with the creation of modal windows. Because they are created in another thread there's no hibernate and springsecurity sessions. How do I call window components on my application without losing servlet variables context?
For instance, the application creates a window with user's preference but when I click save it raises a no hibernate session error.
All over the entire project there are .zul
files with a window
component which are called in a composer through a click event:
<?xml version="1.0" encoding="UTF-8"?>
<?init class="org.zkoss.zkplus.databind.AnnotateDataBinderInit"?>
<?variable-resolver class="org.zkoss.zkplus.spring.DelegatingVariableResolver"?>
<?link rel="shortcut icon" type="image/x-icon" href="/static/images/favicon.ico"?>
<zk xmlns="http://www.zkoss.org/2005/zul"
xmlns:h="http://www.w3.org/1999/xhtml"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.zkoss.org/2005/zul http://www.zkoss.org/2005/zul/zul.xsd">
<window title="Projetos" apply="common.PreferencesComposer"
maximizable="true" minimizable="true" closable="true" maximized="true"
mode="overlapped" border="normal" height="100%" width="100%"
style="opacity:0.94;">
[hidden for brevity]
</window>
</zk>
Composer onClick method:
Window win = (Window) Executions.createComponents("/common/preferences.zul", null, args);
win.doModal();
If you create the modal window in an onClick listenr in a ZK composer, then it should be in a servlet thread.
Unless you enable Event Threads which is already deprecated. I strongly recommended you to disable event thread, because it violate the Java Servlet Specification and make you hard to integrate with other frameworks like Spring.
Remember to read the Event Threads to update the code related to some components e.g. modal window or message box.
The question is unclear. What specific usage do you mean? You can put a varialbe resolver in a composer to wire a spring bean into the composer and use the bean. Please refer to
Notice the example only works with spring 4.3 or before.