public class

FileUpload

extends Widget
implements HasChangeHandlers HasName
java.lang.Object
   ↳ com.google.gwt.user.client.ui.UIObject
     ↳ com.google.gwt.user.client.ui.Widget
       ↳ com.google.gwt.user.client.ui.FileUpload

Class Overview

A widget that wraps the HTML <input type='file'> element. This widget must be used with FormPanel if it is to be submitted to a server.

Example

{@example com.google.gwt.examples.FormPanelExample}

Summary

[Expand]
Inherited Constants
From class com.google.gwt.user.client.ui.UIObject
Public Constructors
FileUpload()
Constructs a new file upload widget.
Protected Constructors
FileUpload(Element element)
This constructor may be used by subclasses to explicitly use an existing element.
Public Methods
HandlerRegistration addChangeHandler(ChangeHandler handler)
Adds a ChangeEvent handler.
String getFilename()
Gets the filename selected by the user.
String getName()
Gets the widget's name.
boolean isEnabled()
Gets whether this widget is enabled.
void onBrowserEvent(Event event)
Fired whenever a browser event is received.
void setEnabled(boolean enabled)
Sets whether this widget is enabled.
void setName(String name)
Sets the widget's name.
static FileUpload wrap(Element element)
Creates a FileUpload widget that wraps an existing <input type='file'> element.
[Expand]
Inherited Methods
From class com.google.gwt.user.client.ui.Widget
From class com.google.gwt.user.client.ui.UIObject
From class java.lang.Object
From interface com.google.gwt.event.dom.client.HasChangeHandlers
From interface com.google.gwt.event.logical.shared.HasAttachHandlers
From interface com.google.gwt.event.shared.HasHandlers
From interface com.google.gwt.user.client.EventListener
From interface com.google.gwt.user.client.ui.HasName
From interface com.google.gwt.user.client.ui.IsWidget

Public Constructors

public FileUpload ()

Constructs a new file upload widget.

Protected Constructors

protected FileUpload (Element element)

This constructor may be used by subclasses to explicitly use an existing element. This element must be an <input> element whose type is 'file'.

Parameters
element the element to be used

Public Methods

public HandlerRegistration addChangeHandler (ChangeHandler handler)

Adds a ChangeEvent handler.

Parameters
handler the change handler
Returns

public String getFilename ()

Gets the filename selected by the user. This property has no mutator, as browser security restrictions preclude setting it.

Returns
  • the widget's filename

public String getName ()

Gets the widget's name.

Returns
  • the widget's name

public boolean isEnabled ()

Gets whether this widget is enabled.

Returns
  • true if the widget is enabled

public void onBrowserEvent (Event event)

Fired whenever a browser event is received.

Parameters
event the event received

public void setEnabled (boolean enabled)

Sets whether this widget is enabled.

Parameters
enabled true to enable the widget, false to disable it

public void setName (String name)

Sets the widget's name.

Parameters
name the widget's new name

public static FileUpload wrap (Element element)

Creates a FileUpload widget that wraps an existing <input type='file'> element. This element must already be attached to the document. If the element is removed from the document, you must call detachNow(Widget).

Parameters
element the element to be wrapped