public class Fileupload extends Button
There are two ways to use Fileupload
:
You don't create Fileupload
directly. Rather, use get()
or get(String, String)
.
5.0.2: If the event thread is disabled, an onUpload event (UploadEvent
)
is posted to all root components when the upload dialog is closed.
If you want the event being sent to a particular component, specify the
component in the desktop's attribute called org.zkoss.zul.Fileupload.target
.
For example,
desktop.setAttribute("org.zkoss.zul.Fileupload.target", mainWindow);
Fileupload.get();
You can create it as a component and then listen to
the onUpload event (UploadEvent
).
See also ZK Component Reference: Fileupload.
A non-XUL extension.
Filedownload
,
Serialized FormLabelImageElement.ExtraCtrl
Constructor and Description |
---|
Fileupload() |
Fileupload(String label) |
Fileupload(String label,
String image) |
Modifier and Type | Method and Description |
---|---|
static org.zkoss.util.media.Media |
get()
Opens a modal dialog with the default message and title,
and let user upload a file.
|
static org.zkoss.util.media.Media |
get(boolean alwaysNative)
Opens a modal dialog with the default message and title,
and let user upload a file.
|
static org.zkoss.util.media.Media[] |
get(org.zkoss.zk.ui.event.EventListener<org.zkoss.zk.ui.event.UploadEvent> listener)
Opens a modal dialog to upload multiple files with
the default message and title.
|
static org.zkoss.util.media.Media[] |
get(int max)
Opens a modal dialog to upload multiple files with
the default message and title.
|
static org.zkoss.util.media.Media[] |
get(int max,
boolean alwaysNative)
Opens a modal dialog to upload multiple files with
the default message and title.
|
static org.zkoss.util.media.Media[] |
get(int max,
org.zkoss.zk.ui.event.EventListener<org.zkoss.zk.ui.event.UploadEvent> listener)
Opens a modal dialog to upload multiple files with
the default message and title.
|
protected static org.zkoss.util.media.Media[] |
get(Map<String,Object> params,
String message,
String title,
int max,
int maxsize,
boolean alwaysNative)
The implementation of all public get methods.
|
static org.zkoss.util.media.Media[] |
get(Map<String,Object> params,
String message,
String title,
int max,
int maxsize,
boolean alwaysNative,
org.zkoss.zk.ui.event.EventListener<org.zkoss.zk.ui.event.UploadEvent> listener)
Opens a modal dialog to upload multiple files with
the specified message, title and options.
|
static org.zkoss.util.media.Media[] |
get(Map<String,Object> params,
String message,
String title,
String accept,
int max,
int maxsize,
boolean alwaysNative,
org.zkoss.zk.ui.event.EventListener<org.zkoss.zk.ui.event.UploadEvent> listener)
Opens a modal dialog to upload multiple files with
the specified message, title and options.
|
static org.zkoss.util.media.Media |
get(String message,
String title)
Opens a modal dialog with the specified message and title,
and let user upload a file.
|
static org.zkoss.util.media.Media |
get(String message,
String title,
boolean alwaysNative)
Opens a modal dialog with the specified message and title,
and let user upload a file.
|
static org.zkoss.util.media.Media[] |
get(String message,
String title,
int max)
Opens a modal dialog to upload multiple files with
the specified message and title.
|
static org.zkoss.util.media.Media[] |
get(String message,
String title,
int max,
boolean alwaysNative)
Opens a modal dialog to upload multiple files with
the specified message, title and options.
|
static org.zkoss.util.media.Media[] |
get(String message,
String title,
int max,
int maxsize,
boolean alwaysNative)
Opens a modal dialog to upload multiple files with
the specified message, title and options.
|
int |
getMaxsize()
Deprecated.
As of release 5.0.0, replaced with
Button.setUpload(String) |
int |
getNumber()
Deprecated.
As of release 5.0.0, replaced with
Button.setUpload(String) |
static String |
getTemplate()
Returns the template used to create the upload modal dialog.
|
boolean |
isNative()
Deprecated.
As of release 5.0.0, replaced with
Button.setUpload(String) |
void |
setMaxsize(int maxsize)
Deprecated.
As of release 5.0.0, replaced with
Button.setUpload(String) |
void |
setNative(boolean alwaysNative)
Deprecated.
As of release 5.0.0, replaced with
Button.setUpload(String) |
void |
setNumber(int maxnum)
Deprecated.
As of release 5.0.0, replaced with
Button.setUpload(String) |
static void |
setTemplate(String uri)
Sets the template used to create the upload modal dialog.
|
clone, getAutodisable, getDir, getHref, getOrient, getTarget, getType, getUpload, getZclass, isChildable, isDisabled, renderCrawlable, renderProperties, setAutodisable, setDir, setDisabled, setHref, setOrient, setTarget, setType, setUpload, updateByClient
getExtraCtrl, getHoverImage, getHoverImageContent, getIconSclass, getImage, getImageContent, getPropertyAccess, getSrc, isImageAssigned, setHoverImage, setHoverImageContent, setHoverImageContent, setIconSclass, setImage, setImageContent, setImageContent, setSrc
getLabel, setLabel
getContext, getCtrlKeys, getPopup, getTooltip, setContext, setContext, setContextAttributes, setCtrlKeys, setPopup, setPopup, setPopupAttributes, setTooltip, setTooltip, setTooltipAttributes
focus, getAction, getDraggable, getDroppable, getHeight, getHflex, getLeft, getRenderdefer, getSclass, getStyle, getTabindex, getTabindexInteger, getTooltiptext, getTop, getVflex, getWidth, getZindex, getZIndex, service, setAction, setClass, setDraggable, setDroppable, setFocus, setHeight, setHeight0, setHeightDirectly, setHflex, setHflex0, setHflexDirectly, setLeft, setLeftDirectly, setRenderdefer, setSclass, setStyle, setTabindex, setTabindex, setTooltiptext, setTop, setTopDirectly, setVflex, setVflex0, setVflexDirectly, setWidth, setWidth0, setWidthDirectly, setZclass, setZindex, setZIndex, setZIndexDirectly
addAnnotation, addAnnotation, addCallback, addClientEvent, addEventHandler, addEventListener, addEventListener, addForward, addForward, addForward, addForward, addMoved, addRedrawCallback, addScopeListener, addShadowRoot, addShadowRootBefore, addSharedEventHandlerMap, appendChild, applyProperties, beforeChildAdded, beforeChildRemoved, beforeParentChanged, detach, didActivate, didActivate, didDeserialize, didDeserialize, disableBindingAnnotation, disableClientUpdate, enableBindingAnnotation, equals, getAnnotatedProperties, getAnnotatedPropertiesBy, getAnnotation, getAnnotation, getAnnotations, getAnnotations, getAnnotations, getAttribute, getAttribute, getAttribute, getAttributeOrFellow, getAttributes, getAttributes, getAuService, getAutag, getCallback, getChildren, getClientAttribute, getClientDataAttribute, getClientEvents, getDefaultMold, getDefinition, getDesktop, getEventHandler, getEventHandlerNames, getEventListenerMap, getEventListeners, getFellow, getFellow, getFellowIfAny, getFellowIfAny, getFellows, getFirstChild, getId, getLastChild, getListenerIterator, getMold, getNextSibling, getPage, getParent, getPreviousSibling, getRedrawCallback, getRoot, getShadowFellowIfAny, getShadowRoots, getShadowVariable, getShadowVariable, getShadowVariable0, getSpaceOwner, getSpecialRendererOutput, getStubonly, getSubBindingAnnotationCount, getTemplate, getTemplateNames, getUuid, getWidgetAttribute, getWidgetAttributeNames, getWidgetClass, getWidgetListener, getWidgetListenerNames, getWidgetOverride, getWidgetOverrideNames, hasAttribute, hasAttribute, hasAttribute, hasAttributeOrFellow, hasBindingAnnotation, hasFellow, hasFellow, hasSubBindingAnnotation, insertBefore, invalidate, isInvalidated, isListenerAvailable, isVisible, onChildAdded, onChildRemoved, onPageAttached, onPageDetached, onWrongValue, query, queryAll, redraw, redrawChildren, removeAttribute, removeAttribute, removeAttribute, removeCallback, removeChild, removeEventListener, removeForward, removeForward, removeRedrawCallback, removeScopeListener, removeShadowRoot, render, render, render, replace, response, response, response, service, sessionDidActivate, sessionWillPassivate, setAttribute, setAttribute, setAttribute, setAuService, setAutag, setClientAttribute, setClientDataAttribute, setDefinition, setDefinition, setId, setMold, setPage, setPageBefore, setParent, setStubonly, setStubonly, setSubBindingAnnotationCount, setTemplate, setVisible, setVisibleDirectly, setWidgetAttribute, setWidgetClass, setWidgetListener, setWidgetOverride, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdateWidgetListener, smartUpdateWidgetOverride, toString, updateSubBindingAnnotationCount, willPassivate, willPassivate, willSerialize, willSerialize
public Fileupload()
public Fileupload(String label)
public int getMaxsize()
Button.setUpload(String)
public void setMaxsize(int maxsize)
Button.setUpload(String)
public int getNumber()
Button.setUpload(String)
public void setNumber(int maxnum) throws org.zkoss.zk.ui.WrongValueException
Button.setUpload(String)
org.zkoss.zk.ui.WrongValueException
public boolean isNative()
Button.setUpload(String)
public void setNative(boolean alwaysNative)
Button.setUpload(String)
public static org.zkoss.util.media.Media get()
public static org.zkoss.util.media.Media get(boolean alwaysNative)
alwaysNative
- whether to treat the uploaded file as binary
stream, regardless its content type.
If false (the default), it will convert to
Image
, Audio
,
binary stream, or text files depending on the content type.Configuration.getUploadCharset()
,
Configuration.getUploadCharsetFinder()
public static org.zkoss.util.media.Media get(String message, String title)
message
- the message. If null, the default is used.title
- the title. If null, the default is used.public static org.zkoss.util.media.Media get(String message, String title, boolean alwaysNative)
message
- the message. If null, the default is used.title
- the title. If null, the default is used.alwaysNative
- whether to treat the uploaded file as binary
stream, regardless its content type.
If false (the default), it will convert to
Image
, Audio
,
binary stream, or text files depending on the content type.Configuration.getUploadCharset()
,
Configuration.getUploadCharsetFinder()
public static org.zkoss.util.media.Media[] get(org.zkoss.zk.ui.event.EventListener<org.zkoss.zk.ui.event.UploadEvent> listener)
listener
- The callback event listener when the event thread is disabled, the listener will be invoked, if it is not null.
Note: the target of the listener is always null.public static org.zkoss.util.media.Media[] get(int max, org.zkoss.zk.ui.event.EventListener<org.zkoss.zk.ui.event.UploadEvent> listener)
max
- the maximal allowed number that an user can upload
at once. If non-positive, 1 is assumed.listener
- The callback event listener when the event thread is disabled, the listener will be invoked, if it is not null.
Note: the target of the listener is always null.public static org.zkoss.util.media.Media[] get(int max)
max
- the maximal allowed number that an user can upload
at once. If non-positive, 1 is assumed.public static org.zkoss.util.media.Media[] get(int max, boolean alwaysNative)
max
- the maximal allowed number that an user can upload
at once. If non-positive, 1 is assumed.alwaysNative
- whether to treat the uploaded files as binary
stream, regardless its content type.
If false (the default), it will convert to
Image
, Audio
,
binary stream, or text files depending on the content type.Configuration.getUploadCharset()
,
Configuration.getUploadCharsetFinder()
public static org.zkoss.util.media.Media[] get(String message, String title, int max)
The returned format depending on the content type.
max
- the maximal allowed number that an user can upload
at once. If non-positive, 1 is assumed.
If max is larger than 1000, 1000 is assumed.public static org.zkoss.util.media.Media[] get(String message, String title, int max, boolean alwaysNative)
max
- the maximal allowed number that an user can upload
at once. If non-positive, 1 is assumed.
If max is larger than 1000, 1000 is assumed.alwaysNative
- whether to treat the uploaded files as binary
stream, regardless its content type.
If false (the default), it will convert to
Image
, Audio
,
binary stream, or text files depending on the content type.public static org.zkoss.util.media.Media[] get(String message, String title, int max, int maxsize, boolean alwaysNative)
max
- the maximal allowed number that an user can upload
at once. If non-positive, 1 is assumed.
If max is larger than 1000, 1000 is assumed.maxsize
- the maximal upload size of the component.alwaysNative
- whether to treat the uploaded files as binary
stream, regardless its content type.
If false (the default), it will convert to
Image
, Audio
,
binary stream, or text files depending on the content type.public static org.zkoss.util.media.Media[] get(Map<String,Object> params, String message, String title, int max, int maxsize, boolean alwaysNative, org.zkoss.zk.ui.event.EventListener<org.zkoss.zk.ui.event.UploadEvent> listener)
max
- the maximal allowed number that an user can upload
at once. If non-positive, 1 is assumed.
If max is larger than 1000, 1000 is assumed.maxsize
- the maximal upload size of the component.alwaysNative
- whether to treat the uploaded files as binary
stream, regardless its content type.
If false (the default), it will convert to
Image
, Audio
,
binary stream, or text files depending on the content type.listener
- The callback event listener when the event thread is disabled, the listener will be invoked, if it is not null.
Note: the target of the listener is always null.public static org.zkoss.util.media.Media[] get(Map<String,Object> params, String message, String title, String accept, int max, int maxsize, boolean alwaysNative, org.zkoss.zk.ui.event.EventListener<org.zkoss.zk.ui.event.UploadEvent> listener)
accept
- specifies the types of files that the server accepts,
the setting only works with HTML5 supported browsersmax
- the maximal allowed number that an user can upload
at once. If non-positive, 1 is assumed.
If max is larger than 1000, 1000 is assumed.maxsize
- the maximal upload size of the component.alwaysNative
- whether to treat the uploaded files as binary
stream, regardless its content type.
If false (the default), it will convert to
Image
, Audio
,
binary stream, or text files depending on the content type.listener
- The callback event listener when the event thread is disabled, the listener will be invoked, if it is not null.
Note: the target of the listener is always null.protected static org.zkoss.util.media.Media[] get(Map<String,Object> params, String message, String title, int max, int maxsize, boolean alwaysNative)
get
methods will prepare
an empty map and invoke this method to retrieve the media.
It is designed to allow applications to customize the creation of
the dialog, such as adding more parameters.public static void setTemplate(String uri)
The template must follow the default template: ~./zul/html/fileuploaddlg.zul
In other words, just adjust the label and layout and don't change the component's ID.
Note: the template has no effect, if you use Fileupload
as
a component (and embed it to a page).
public static String getTemplate()
Copyright © 2018. All rights reserved.