-
FEATURED COMPONENTS
First time here? Check out the FAQ!
I'm using zkoss community version 9, to upload using the Media function media = Fileupload.get();, the result is null, why is that?
Hey there,
The Static Fileupload#get() method is only usable when EventThread is enabled on the application. From the javadoc for Fileupload#get():
Opens a modal dialog with the default message and title,and let user upload a file.
Returns:null if the uploaded content, or null if not uploaded. Notice, by default, the event thread is disabled, and this method won't suspend and always returns null. To retrieve the uploaded content, the developer has to listen the onUpload event. For more information, refer to ZK Component Reference: Fileupload.
IMPORTANT NOTE: EventThread is a deprecated code structure, which suspends the execution of an event listener until a user action is resolved. It's less efficient than using event listeners.
You should use org.zkoss.zul.Fileupload.get(EventListener<uploadevent>) instead of the empty org.zkoss.zul.Fileupload.get().
Event listener works by default, and you really shouldn't activate EventThread. It's kept in current version as a backward-compatibility help, to keep older projects updated to latest versions without breaking, but shouldn't be used in new developments.
Asked: 2023-05-22 15:07:31 +0800
Seen: 4 times
Last updated: May 25