org.zkoss.zul
Class Fileupload

java.lang.Object
  extended by org.zkoss.zk.ui.AbstractComponent
      extended by org.zkoss.zk.ui.HtmlBasedComponent
          extended by org.zkoss.zul.impl.XulElement
              extended by org.zkoss.zul.impl.LabelElement
                  extended by org.zkoss.zul.impl.LabelImageElement
                      extended by org.zkoss.zul.Button
                          extended by org.zkoss.zul.Fileupload
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, Component, Disable, Scope, ComponentCtrl
Direct Known Subclasses:
Fileupload

public class Fileupload
extends Button

A fileupload dialog used to let user upload a file.

There are two ways to use Fileupload:

1. Open as a modal dialog:

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();

2. Embed as part of the page:

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.

Author:
tomyeh
See Also:
Filedownload, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class org.zkoss.zul.impl.LabelImageElement
LabelImageElement.ExtraCtrl
 
Nested classes/interfaces inherited from class org.zkoss.zk.ui.AbstractComponent
AbstractComponent.Children
 
Field Summary
 
Fields inherited from class org.zkoss.zk.ui.HtmlBasedComponent
_zclass
 
Fields inherited from interface org.zkoss.zk.ui.Component
APPLICATION_SCOPE, COMPONENT_SCOPE, DESKTOP_SCOPE, PAGE_SCOPE, REQUEST_SCOPE, SESSION_SCOPE, SPACE_SCOPE
 
Fields inherited from interface org.zkoss.zk.ui.sys.ComponentCtrl
CE_BUSY_IGNORE, CE_DUPLICATE_IGNORE, CE_IMPORTANT, CE_NON_DEFERRABLE, CE_REPEAT_IGNORE
 
Constructor Summary
Fileupload()
           
Fileupload(java.lang.String label)
           
Fileupload(java.lang.String label, java.lang.String image)
           
 
Method Summary
static Media get()
          Opens a modal dialog with the default message and title, and let user upload a file.
static Media get(boolean alwaysNative)
          Opens a modal dialog with the default message and title, and let user upload a file.
static Media[] get(int max)
          Opens a modal dialog to upload mulitple files with the default message and title.
static Media[] get(int max, boolean alwaysNative)
          Opens a modal dialog to upload mulitple files with the default message and title.
protected static Media[] get(java.util.Map<java.lang.String,java.lang.Object> params, java.lang.String message, java.lang.String title, int max, int maxsize, boolean alwaysNative)
          The implemenation of all public get methods.
static Media get(java.lang.String message, java.lang.String title)
          Opens a modal dialog with the specified message and title, and let user upload a file.
static Media get(java.lang.String message, java.lang.String title, boolean alwaysNative)
          Opens a modal dialog with the specified message and title, and let user upload a file.
static Media[] get(java.lang.String message, java.lang.String title, int max)
          Opens a modal dialog to upload multiple files with the specified message and title.
static Media[] get(java.lang.String message, java.lang.String title, int max, boolean alwaysNative)
          Opens a modal dialog to upload multiple files with the specified message, title and options.
static Media[] get(java.lang.String message, java.lang.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 java.lang.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(java.lang.String uri)
          Sets the template used to create the upload modal dialog.
 
Methods inherited from class org.zkoss.zul.Button
clone, getAutodisable, getDir, getHref, getOrient, getTabindex, getTarget, getType, getUpload, getZclass, isChildable, isDisabled, renderCrawlable, renderProperties, setAutodisable, setDir, setDisabled, setHref, setOrient, setTabindex, setTarget, setType, setUpload, updateByClient
 
Methods inherited from class org.zkoss.zul.impl.LabelImageElement
getExtraCtrl, getHoverImage, getHoverImageContent, getImage, getImageContent, getSrc, isImageAssigned, setHoverImage, setHoverImageContent, setHoverImageContent, setImage, setImageContent, setImageContent, setSrc
 
Methods inherited from class org.zkoss.zul.impl.LabelElement
getLabel, setLabel
 
Methods inherited from class org.zkoss.zul.impl.XulElement
getContext, getCtrlKeys, getPopup, getTooltip, setContext, setContext, setCtrlKeys, setPopup, setPopup, setTooltip, setTooltip
 
Methods inherited from class org.zkoss.zk.ui.HtmlBasedComponent
focus, getAction, getDraggable, getDroppable, getHeight, getHflex, getLeft, getRenderdefer, getSclass, getStyle, getTooltiptext, getTop, getVflex, getWidth, getZindex, getZIndex, service, setAction, setClass, setDraggable, setDroppable, setFocus, setHeight, setHeightDirectly, setHflex, setHflexDirectly, setLeft, setLeftDirectly, setRenderdefer, setSclass, setStyle, setTooltiptext, setTop, setTopDirectly, setVflex, setWidth, setWidthDirectly, setZclass, setZindex, setZIndex, setZIndexDirectly
 
Methods inherited from class org.zkoss.zk.ui.AbstractComponent
addAnnotation, addAnnotation, addClientEvent, addEventHandler, addEventListener, addEventListener, addForward, addForward, addForward, addForward, addMoved, addScopeListener, addSharedAnnotationMap, addSharedEventHandlerMap, appendChild, applyProperties, beforeChildAdded, beforeChildRemoved, beforeParentChanged, detach, didActivate, didActivate, didDeserialize, didDeserialize, disableClientUpdate, equals, getAnnotatedProperties, getAnnotatedPropertiesBy, getAnnotation, getAnnotation, getAnnotations, getAnnotations, getAnnotations, getAttribute, getAttribute, getAttribute, getAttributeOrFellow, getAttributes, getAttributes, getAuService, getAutag, getChildren, getClientEvents, getDefaultMold, getDefinition, getDesktop, getEventHandler, getEventHandlerNames, getEventListenerMap, getEventListeners, getFellow, getFellow, getFellowIfAny, getFellowIfAny, getFellows, getFirstChild, getId, getLastChild, getListenerIterator, getMold, getNextSibling, getPage, getParent, getPreviousSibling, getRoot, getSpaceOwner, getStubonly, getTemplate, getTemplateNames, getUuid, getWidgetAttribute, getWidgetAttributeNames, getWidgetClass, getWidgetListener, getWidgetListenerNames, getWidgetOverride, getWidgetOverrideNames, hasAttribute, hasAttribute, hasAttribute, hasAttributeOrFellow, hasFellow, hasFellow, insertBefore, invalidate, isInvalidated, isListenerAvailable, isVisible, onChildAdded, onChildRemoved, onPageAttached, onPageDetached, onWrongValue, query, queryAll, redraw, redrawChildren, removeAttribute, removeAttribute, removeAttribute, removeChild, removeEventListener, removeForward, removeForward, removeScopeListener, render, render, render, replace, response, response, service, sessionDidActivate, sessionWillPassivate, setAttribute, setAttribute, setAttribute, setAuService, setAutag, setDefinition, setDefinition, setId, setMold, setPage, setPageBefore, setParent, setStubonly, setStubonly, setTemplate, setVisible, setVisibleDirectly, setWidgetAttribute, setWidgetClass, setWidgetListener, setWidgetOverride, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdateWidgetListener, smartUpdateWidgetOverride, toString, willPassivate, willPassivate, willSerialize, willSerialize
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Fileupload

public Fileupload()

Fileupload

public Fileupload(java.lang.String label)

Fileupload

public Fileupload(java.lang.String label,
                  java.lang.String image)
Method Detail

getMaxsize

public int getMaxsize()
Deprecated. As of release 5.0.0, replaced with Button.setUpload(String)


setMaxsize

public void setMaxsize(int maxsize)
Deprecated. As of release 5.0.0, replaced with Button.setUpload(String)


getNumber

public int getNumber()
Deprecated. As of release 5.0.0, replaced with Button.setUpload(String)


setNumber

public void setNumber(int maxnum)
               throws WrongValueException
Deprecated. As of release 5.0.0, replaced with Button.setUpload(String)

Throws:
WrongValueException

isNative

public boolean isNative()
Deprecated. As of release 5.0.0, replaced with Button.setUpload(String)


setNative

public void setNative(boolean alwaysNative)
Deprecated. As of release 5.0.0, replaced with Button.setUpload(String)


get

public static Media 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 retrive the uploaded content, the developer has to listen the onUpload event. For more information, refer to ZK Component Reference: Fileupload.

get

public static Media get(boolean alwaysNative)
Opens a modal dialog with the default message and title, and let user upload a file.

Parameters:
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.
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 retrive the uploaded content, the developer has to listen the onUpload event. For more information, refer to ZK Component Reference: Fileupload.
Since:
3.0.0
See Also:
Configuration.getUploadCharset(), Configuration.getUploadCharsetFinder()

get

public static Media get(java.lang.String message,
                        java.lang.String title)
Opens a modal dialog with the specified message and title, and let user upload a file.

Parameters:
message - the message. If null, the default is used.
title - the title. If null, the default is used.
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 retrive the uploaded content, the developer has to listen the onUpload event. For more information, refer to ZK Component Reference: Fileupload.

get

public static Media get(java.lang.String message,
                        java.lang.String title,
                        boolean alwaysNative)
Opens a modal dialog with the specified message and title, and let user upload a file.

Parameters:
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.
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 retrive the uploaded content, the developer has to listen the onUpload event. For more information, refer to ZK Component Reference: Fileupload.
Since:
3.0.0
See Also:
Configuration.getUploadCharset(), Configuration.getUploadCharsetFinder()

get

public static Media[] get(int max)
Opens a modal dialog to upload mulitple files with the default message and title.

Parameters:
max - the maximal allowed number that an user can upload at once. If nonpositive, 1 is assumed.
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 retrive the uploaded content, the developer has to listen the onUpload event. For more information, refer to ZK Component Reference: Fileupload.

get

public static Media[] get(int max,
                          boolean alwaysNative)
Opens a modal dialog to upload mulitple files with the default message and title.

Parameters:
max - the maximal allowed number that an user can upload at once. If nonpositive, 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.
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 retrive the uploaded content, the developer has to listen the onUpload event. For more information, refer to ZK Component Reference: Fileupload.
Since:
3.0.0
See Also:
Configuration.getUploadCharset(), Configuration.getUploadCharsetFinder()

get

public static Media[] get(java.lang.String message,
                          java.lang.String title,
                          int max)
Opens a modal dialog to upload multiple files with the specified message and title.

The returned format depending on the content type.

Parameters:
max - the maximal allowed number that an user can upload at once. If nonpositive, 1 is assumed. If max is larger than 1000, 1000 is assumed.
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 retrive the uploaded content, the developer has to listen the onUpload event. For more information, refer to ZK Component Reference: Fileupload.

get

public static Media[] get(java.lang.String message,
                          java.lang.String title,
                          int max,
                          boolean alwaysNative)
Opens a modal dialog to upload multiple files with the specified message, title and options.

Parameters:
max - the maximal allowed number that an user can upload at once. If nonpositive, 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.
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 retrive the uploaded content, the developer has to listen the onUpload event. For more information, refer to ZK Component Reference: Fileupload.
Since:
3.0.0

get

public static Media[] get(java.lang.String message,
                          java.lang.String title,
                          int max,
                          int maxsize,
                          boolean alwaysNative)
Opens a modal dialog to upload multiple files with the specified message, title and options.

Parameters:
max - the maximal allowed number that an user can upload at once. If nonpositive, 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.
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 retrive the uploaded content, the developer has to listen the onUpload event. For more information, refer to ZK Component Reference: Fileupload.
Since:
3.6.0

get

protected static Media[] get(java.util.Map<java.lang.String,java.lang.Object> params,
                             java.lang.String message,
                             java.lang.String title,
                             int max,
                             int maxsize,
                             boolean alwaysNative)
The implemenation of all public get methods. In other words, all public 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.

Since:
5.0.11

setTemplate

public static void setTemplate(java.lang.String uri)
Sets the template used to create the upload modal dialog.

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).


getTemplate

public static java.lang.String getTemplate()
Returns the template used to create the upload modal dialog.



Copyright © 2005-2011 Potix Corporation. All Rights Reserved. SourceForge.net Logo