Package org.zkoss.zk.ui.ext
Interface Uploadable
-
public interface UploadableImplemented withComponentto indicate that a component can be used for file upload.- Since:
- 8.6.2
- Author:
- rudyhuang
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classUploadable.ErrorUploading error constants.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.lang.StringgetUpload()Returns non-null if this component is used for file upload, or null otherwise.voidsetUpload(java.lang.String upload)Sets the JavaScript class at the client to handle the upload if this component is used for file upload.
-
-
-
Method Detail
-
getUpload
java.lang.String getUpload()
Returns non-null if this component is used for file upload, or null otherwise. Refer tosetUpload(java.lang.String)for more details.- Since:
- 5.0.0
-
setUpload
void setUpload(java.lang.String upload)
Sets the JavaScript class at the client to handle the upload if this component is used for file upload.Default: null.
For example, the following example declares a button for file upload:
<button label="Upload" upload="true" onUpload="handle(event.media)"/>As shown above, after the file is uploaded, an instance of
UploadEventis sent this component.If you want to customize the handling of the file upload at the client, you can specify a JavaScript class when calling this method:
<button upload="foo.Upload"/>Another options for the upload can be specified as follows:
<button label="Upload" upload="true,maxsize=-1,multiple=true,accept=audio/*|video/*|image/*,native"- maxsize: the maximal allowed upload size of the component, in kilobytes, or
a negative value if no limit, if the maxsize is not specified, it will use
Configuration.getMaxUploadSize() - native: treating the uploaded file(s) as binary, i.e., not to convert it to image, audio or text files.
- multiple: treating the file chooser allows multiple files to upload, the setting only works with HTML5 supported browsers (since ZK 6.0.0).
- accept: specifies the types of files that the server accepts, the setting only works with HTML5 supported browsers (since ZK 7.0.0).
- suppressedErrors: specifies the suppressed uploading errors, separated by
|(e.g. missing-required-component|illegal-upload) (since ZK 9.5.1).
Note: if the options of the
falseor the customized handler (likefoo.Upload) are not specified, the option oftrueis implicit by default.- Parameters:
upload- a JavaScript class to handle the file upload at the client, or "true" if the default class is used, or null or "false" to disable the file download (and then this button behaves like a normal button).- Since:
- 5.0.0
- See Also:
Uploadable.Error
- maxsize: the maximal allowed upload size of the component, in kilobytes, or
a negative value if no limit, if the maxsize is not specified, it will use
-
-