Fileupload"

From Documentation
Line 9: Line 9:
 
= Employment/Purpose =
 
= Employment/Purpose =
  
A fileupload dialog used to let user upload a file.The <tt>fileupload</tt> component is not a modal dialog. Rather, it is a component, so it is placed inline with other components.
+
There are two ways to use <javadoc>org.zkoss.zul.Fileupload</javadoc>: uses <javadoc>org.zkoss.zul.Fileupload</javadoc> as a component to upload files, or invoke <javadoc method="get()">org.zkoss.zul.Fileupload</javadoc> to open a dialog to upload files.
 +
 
 +
== Use as a Component ==
 +
 
 +
== Invoke the Static Method: get ==
 +
 
 +
Fileupload provides a set of static methods to simplify the file uploading, such as <javadoc method="get()">org.zkoss.zul.Fileupload</javadoc>, <javadoc method="get(java.lang.String, java.lang.String)">org.zkoss.zul.Fileupload</javadoc>, and so on.
 +
 
 +
The behavior is a little bit different depending on if the event thread is enabled (default: it is disabled).
 +
 
 +
=== Event Thread Enabled ===
 +
=== Event Thread Disabled ===
  
 
== Specify the target component ==
 
== Specify the target component ==

Revision as of 11:12, 2 September 2010

Fileupload

Employment/Purpose

There are two ways to use Fileupload: uses Fileupload as a component to upload files, or invoke Fileupload.get() to open a dialog to upload files.

Use as a Component

Invoke the Static Method: get

Fileupload provides a set of static methods to simplify the file uploading, such as Fileupload.get(), Fileupload.get(String, String), and so on.

The behavior is a little bit different depending on if the event thread is enabled (default: it is disabled).

Event Thread Enabled

Event Thread Disabled

Specify the target component

Since 5.0.2, if the event thread is disabled, an onUpload event 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(); //then mainWindow will receive the onUpload event

Example

<image id="img" />
Upload your hot shot:
<fileupload onUpload="img.setContent(event.media)" />


Supported events

Name
Event Type
None None

Supported Children

*NONE

Use cases

Version Description Example Location
     

Version History

Version Date Content
5.0.2 May 2010 Able to specify a target for the onUpload event sent by Fileupload.get(). Used if the event thread is disabled.



Last Update : 2010/09/02

Copyright © Potix Corporation. This article is licensed under GNU Free Documentation License.