-
Type:
Bug
-
Resolution: Fixed
-
Priority:
Normal
-
Affects Version/s: 8.6.0, 8.6.0.1
-
Component/s: Components
-
Security Level: Jimmy
-
None
-
None
Steps to Reproduce
reproducing code
<zk> <zscript><![CDATA[ public void upload() { Fileupload.get(new EventListener() { public void onEvent(Event e) { Clients.log(e.getMedia().getName()); } }); } ]]></zscript> <button label="trigger upload dialog" onClick="upload();"/> </zk>
click the button to display the fileupload dialog
add one file
wait for the upload to finish
Current Result
in 8.5.2.1 the file shows upload progress and when finished remains visible with a "cancel" link
in 8.6.0.1 the file shows upload progress and when finished disappears leaving an empty dialog
Expected Result
same or similar as in 8.5.2.1
Debug Info
this div becomes visible in 8.5 but remains invisible since 8.6
Root Cause
since 8.6.0 the finish function is no longer called to display the successfully uploaded file information
Instead the cancel function is always called when a file was uploaded successfully or an error occurred
Workaround
manually keep track of the error state and call the expected function accordingly later
zk.afterLoad('zul', function() { var xUpload = {}; zk.override(zul.Upload, xUpload, { error : function(msg, uuid, sid) { var wgt = zk.Widget.$(uuid); if(wgt) { wgt._hasUploadError = true; } return xUpload.error.apply(this, arguments); }, close : function(uuid, sid) { var wgt = zk.Widget.$(uuid); if (!wgt || !wgt._uplder) return; if(wgt._hasUploadError) { wgt._uplder.cancel(sid); } else { wgt._uplder.finish(sid); } } });//zk.override });//zk.afterLoad
(this is not the suggested fix, but requires little overriding to patch)