- Simple ZK MVVM application with a "dropupload" component (Button) to upload a file.
- ZK application must be configured to serialize session externally. For our example we are serializing to Redis using Spring Session Data Redis.
- use "org.zkoss.zk.ui.http.SerializableUiFactory" in for "ui-factory-class" in zk.xml file
- use workaround described here to flush session serialization on each Execution cleanup
- use "spring.session.store-type=redis" application property to activate session serialization to Redis
- add these dependencies to serialize session to Redis, versions from Spring Session BOM:
- Start Redis standalone server with all the defaults
- Launch ZK application and click the button to upload a file
File is successfully uploaded
In "org.zkoss.zk.au.http.AuDropUploader", method "processItems", upload info key is recorded as an Desktop attribute. This attribute is lost shortly after. We suppose it is du to the fact that the instance of the Desktop is deserialized sometime before UploadEvent is processed in "org.zkoss.zk.ui.event.UploadEvent", method "getLatestUploadEvent" overriding the attributes.
Following the insight from the forum post given above we can force session serialization by executing this statement right after the call to "processItems" in "AuDropUploader":
This apparently serializes the session (with all desktop attributes) right away so that upload info key attribute is present upon any successive deserialization.
Please note that we are well aware of the helpful message in JavaDoc for "org.zkoss.zk.ui.impl.DesktopImpl" which sheds light to the potential issues related to serialization of Desktop.