problem in upload

asked 2023-05-22 15:07:31 +0800

anwar gravatar image anwar

I'm using zkoss community version 9, to upload using the Media function media = Fileupload.get();, the result is null, why is that?

delete flag offensive retag edit

2 Answers

Sort by ยป oldest newest most voted

answered 2023-05-25 12:25:00 +0800

MDuchemin gravatar image MDuchemin
2480 1 6
ZK Team

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.

link publish delete flag offensive edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

1 follower



Asked: 2023-05-22 15:07:31 +0800

Seen: 8 times

Last updated: Jul 06

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More