public class UploadItem extends TextItem
NOTE: use FileItem
,
not UploadItem, if you are using the Smart GWT Server framework. FileItem is much easier to use and addresses
all the limitations of UploadItem discussed below. See the Uploading Files
overview for details.
If a form containing an UploadItem is redrawn
(which may happen if other form items are shown or hidden, the form is resized
, or other items show validation errors) then the value in
the upload item is lost (because an HTML upload field may not be created with a value). For this reason, if you are
building a form that combines an UploadItem with other FormItems that could trigger redraw()s, recommended practice is
to place each UploadItem in a distinct DynamicForm instance and create the visual appearance of a single logical form
via combining the DynamicForms in a Layout
.
NOTE: Browser-specific behaviors:
Upload overview and related methods
id
Constructor and Description |
---|
UploadItem() |
UploadItem(com.google.gwt.core.client.JavaScriptObject jsObj) |
UploadItem(java.lang.String name) |
UploadItem(java.lang.String name,
java.lang.String title) |
Modifier and Type | Method and Description |
---|---|
static void |
changeAutoChildDefaults(java.lang.String autoChildName,
Canvas defaults)
Changes the defaults for Canvas AutoChildren named
autoChildName . |
static void |
changeAutoChildDefaults(java.lang.String autoChildName,
FormItem defaults)
Changes the defaults for FormItem AutoChildren named
autoChildName . |
static void |
changePickerIconDefaults(FormItemIcon defaults) |
void |
deselectValue()
This method is not supported by
UploadItem . |
void |
deselectValue(java.lang.Boolean start)
This method is not supported by
UploadItem . |
java.lang.String |
getAccept()
A comma-separated list of valid MIME types, used as a filter for the file picker window.
|
int |
getHeight()
Height for this uploadItem.
|
java.lang.Boolean |
getMultiple()
When true, allow the file-selection dialog shelled by the browser to select multiple
files.
|
static UploadItem |
getOrCreateRef(com.google.gwt.core.client.JavaScriptObject jsObj) |
int[] |
getSelectionRange()
This method is not supported by
UploadItem . |
int |
getWidth()
Width for this uploadItem.
|
void |
selectValue()
This method is not supported by
UploadItem . |
void |
setAccept(java.lang.String accept)
A comma-separated list of valid MIME types, used as a filter for the file picker window.
|
static void |
setDefaultProperties(UploadItem uploadItemProperties)
Class level method to set the default properties of this class.
|
void |
setHeight(int height)
Height for this uploadItem.
|
void |
setJavaScriptObject(com.google.gwt.core.client.JavaScriptObject jsObj) |
void |
setMultiple(java.lang.Boolean multiple)
When true, allow the file-selection dialog shelled by the browser to select multiple
files.
|
void |
setSelectionRange()
This method is not supported by
UploadItem . |
void |
setValue()
Attempting to set the value for an upload form item is disallowed for security reasons.
|
void |
setWidth(int width)
Width for this uploadItem.
|
getBrowserAutoCapitalize, getBrowserAutoCorrect, getBrowserInputType, getChangeOnKeypress, getCharacterCasing, getEnteredValue, getFormatOnBlur, getFormatOnFocusChange, getHint, getKeyPressFilter, getLength, getMask, getMaskOverwriteMode, getMaskPadChar, getMaskPromptChar, getMaskSaveLiterals, getPrintFullText, getSaveOnEnter, getSelectOnClick, getSelectOnFocus, getShowHintInField, getTextBoxStyle, getValueAsString, setBrowserAutoCapitalize, setBrowserAutoCorrect, setBrowserInputType, setChangeOnKeypress, setCharacterCasing, setDefaultProperties, setFormatOnBlur, setFormatOnFocusChange, setKeyPressFilter, setLength, setMask, setMaskOverwriteMode, setMaskPadChar, setMaskPromptChar, setMaskSaveLiterals, setPrintFullText, setSaveOnEnter, setSelectionRange, setSelectOnClick, setSelectOnFocus, setShowHintInField, setTextBoxStyle
_getValue, addBlurHandler, addChangedHandler, addChangeHandler, addClickHandler, addDoubleClickHandler, addEditorEnterHandler, addEditorExitHandler, addFocusHandler, addIconClickHandler, addIconKeyPressHandler, addItemHoverHandler, addKeyDownHandler, addKeyPressHandler, addKeyUpHandler, addPickerIconClickHandler, addTitleClickHandler, addTitleDoubleClickHandler, addTitleHoverHandler, addValueHoverHandler, asSGWTComponent, blurItem, canEditCriterion, clearValue, disable, enable, focusInItem, getAccessKey, getAlign, getAllowExpressions, getAlwaysFetchMissingValues, getApplyHeightToTextBox, getAriaRole, getAttribute, getAttributeAsBoolean, getAttributeAsDate, getAttributeAsDouble, getAttributeAsFloat, getAttributeAsInt, getAttributeAsJavaScriptObject, getAttributeAsString, getBrowserSpellCheck, getCanEdit, getCanFocus, getCanvasAutoChild, getCellHeight, getCellStyle, getClassName, getClipStaticValue, getClipTitle, getConfig, getContainerWidget, getCriteriaField, getCriterion, getCriterion, getDataPath, getDateFormatter, getDecimalPad, getDecimalPrecision, getDefaultIconSrc, getDisabled, getDisableIconsOnReadOnly, getDisplayField, getDisplayFieldName, getDisplayValue, getDisplayValue, getEditorTypeConfig, getEditPendingCSSText, getEmptyDisplayValue, getEmptyValueIcon, getEndRow, getErrorIconHeight, getErrorIconSrc, getErrorIconWidth, getErrorMessageWidth, getFetchMissingValues, getFieldName, getFilterLocally, getForm, getFormItemAutoChild, getFullDataPath, getGlobalTabIndex, getHintStyle, getHoverAlign, getHoverDelay, getHoverHeight, getHoverOpacity, getHoverStyle, getHoverVAlign, getHoverWidth, getIcon, getIconHeight, getIconHSpace, getIconPageRect, getIconPrompt, getIconRect, getIconVAlign, getIconWidth, getImageURLPrefix, getImageURLSuffix, getImplicitSave, getImplicitSaveOnBlur, getInputFormat, getLeft, getLocateItemBy, getMultipleValueSeparator, getName, getOperator, getOptionCriteria, getOptionFilterContext, getOptionOperationId, getPageLeft, getPageRect, getPageTop, getPicker, getPickerIconHeight, getPickerIconName, getPickerIconPrompt, getPickerIconProperties, getPickerIconSrc, getPickerIconStyle, getPickerIconWidth, getPrintTextBoxStyle, getPrintTitleStyle, getPrompt, getReadOnlyDisplay, getReadOnlyTextBoxStyle, getRect, getRedrawOnChange, getRejectInvalidValueOnChange, getRequired, getRequiredMessage, getRowSpan, getSelectedRecord, getShouldSaveValue, getShowClippedTitleOnHover, getShowClippedValueOnHover, getShowDisabled, getShowErrorIcon, getShowErrorStyle, getShowErrorText, getShowFocused, getShowFocusedErrorState, getShowFocusedIcons, getShowFocusedPickerIcon, getShowHint, getShowIcons, getShowOverIcons, getShowPickerIcon, getShowRTL, getShowTitle, getShowValueIconOnly, getStartRow, getStopOnError, getSuppressValueIcon, getSynchronousValidation, getTabIndex, getTextAlign, getTimeFormatter, getTitle, getTitleAlign, getTitleColSpan, getTitleOrientation, getTitleStyle, getTitleVAlign, getTooltip, getTop, getType, getValidateOnChange, getValidateOnExit, getValidOperators, getVAlign, getValue, getValueAsRecordList, getValueField, getValueFieldName, getValueIconHeight, getValueIconLeftPadding, getValueIconRightPadding, getValueIconSize, getValueIconWidth, getVisible, getVisibleHeight, getVisibleWidth, getWrapTitle, hasAdvancedCriteria, hide, hideIcon, invalidateDisplayValueCache, isCreated, isDisabled, isDrawn, isVisible, redraw, setAccessKey, setAlign, setAllowExpressions, setAlwaysFetchMissingValues, setApplyHeightToTextBox, setAriaRole, setAriaState, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAutoChildConstructor, setAutoChildProperties, setAutoChildProperties, setAutoChildVisibility, setBrowserSpellCheck, setCanEdit, setCanEditCriterionPredicate, setCanFocus, setCellHeight, setCellStyle, setClipStaticValue, setClipTitle, setColSpan, setColSpan, setCriteriaField, setCriterion, setCriterionGetter, setCriterionSetter, setDataPath, setDateFormatter, setDecimalPad, setDecimalPrecision, setDefaultIconSrc, setDefaultProperties, setDefaultValue, setDefaultValue, setDefaultValue, setDefaultValue, setDefaultValue, setDefaultValue, setDefaultValue, setDisabled, setDisableIconsOnReadOnly, setDisplayField, setDisplayFormat, setDisplayFormat, setEditorProperties, setEditorType, setEditorType, setEditorType, setEditorValueFormatter, setEditorValueParser, setEditPendingCSSText, setEmptyDisplayValue, setEmptyValueIcon, setEndRow, setErrorFormatter, setErrorIconHeight, setErrorIconSrc, setErrorIconWidth, setErrorMessageWidth, setErrorOrientation, setFetchMissingValues, setFilterLocally, setGlobalTabIndex, setHeight, setHint, setHintStyle, setHoverAlign, setHoverDelay, setHoverHeight, setHoverOpacity, setHoverStyle, setHoverVAlign, setHoverWidth, setIconHeight, setIconHSpace, setIconPrompt, setIcons, setIconVAlign, setIconWidth, setImageURLPrefix, setImageURLSuffix, setImplicitSave, setImplicitSaveOnBlur, setInitHandler, setInputFormat, setInputTransformer, setItemHoverFormatter, setItemTitleHoverFormatter, setItemValueHoverFormatter, setLeft, setLocateItemBy, setMultipleValueSeparator, setName, setOperator, setOptionCriteria, setOptionDataSource, setOptionFilterContext, setOptionOperationId, setPickerIconHeight, setPickerIconName, setPickerIconPrompt, setPickerIconProperties, setPickerIconSrc, setPickerIconStyle, setPickerIconWidth, setPrintTextBoxStyle, setPrintTitleStyle, setPrompt, setProperty, setProperty, setProperty, setProperty, setProperty, setReadOnlyDisplay, setReadOnlyTextBoxStyle, setRedrawOnChange, setRejectInvalidValueOnChange, setRequired, setRequiredMessage, setRowSpan, setShouldSaveValue, setShowClippedTitleOnHover, setShowClippedValueOnHover, setShowDisabled, setShowErrorIcon, setShowErrorStyle, setShowErrorText, setShowFocused, setShowFocusedErrorState, setShowFocusedIcons, setShowFocusedPickerIcon, setShowHint, setShowIcons, setShowIfCondition, setShowOverIcons, setShowPickerIcon, setShowRTL, setShowTitle, setShowValueIconOnly, setStartRow, setStopOnError, setSuppressValueIcon, setSynchronousValidation, setTabIndex, setTextAlign, setTimeFormatter, setTitle, setTitleAlign, setTitleColSpan, setTitleHoverFormatter, setTitleOrientation, setTitleStyle, setTitleVAlign, setTooltip, setTop, setType, setValidateOnChange, setValidateOnExit, setValidators, setValidOperators, setVAlign, setValue, setValue, setValue, setValue, setValue, setValue, setValueField, setValueFormatter, setValueHoverFormatter, setValueIconHeight, setValueIconLeftPadding, setValueIconMapper, setValueIconRightPadding, setValueIcons, setValueIconSize, setValueIconWidth, setValueMap, setValueMap, setVisible, setWidth, setWrapTitle, shouldApplyHeightToTextBox, shouldFetchMissingValue, shouldSaveOnEnter, show, showIcon, showPicker, stopHover, updateState, validate, valueClipped
getRef, getRef, internalSetID
doAddHandler, fireEvent, getAttributeAsDoubleArray, getAttributeAsIntArray, getAttributeAsLong, getAttributeAsMap, getAttributeAsObject, getAttributeAsRecord, getAttributeAsStringArray, getAttributes, getHandlerCount, getJsObj, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttributeAsJavaObject
public UploadItem()
public UploadItem(com.google.gwt.core.client.JavaScriptObject jsObj)
public UploadItem(java.lang.String name)
public UploadItem(java.lang.String name, java.lang.String title)
public static UploadItem getOrCreateRef(com.google.gwt.core.client.JavaScriptObject jsObj)
public void setJavaScriptObject(com.google.gwt.core.client.JavaScriptObject jsObj)
setJavaScriptObject
in class TextItem
public static void changeAutoChildDefaults(java.lang.String autoChildName, Canvas defaults)
autoChildName
.autoChildName
- name of an AutoChild to customize the defaults for.defaults
- Canvas defaults to apply. These defaults override any existing properties
without destroying or wiping out non-overridden properties.AutoChildUsage
public static void changeAutoChildDefaults(java.lang.String autoChildName, FormItem defaults)
autoChildName
.autoChildName
- name of an AutoChild to customize the defaults for.defaults
- FormItem defaults to apply. These defaults override any existing properties
without destroying or wiping out non-overridden properties.AutoChildUsage
public static void changePickerIconDefaults(FormItemIcon defaults)
public void setAccept(java.lang.String accept)
accept
- . See String
. Default value is nullpublic java.lang.String getAccept()
String
public void setHeight(int height)
setHeight
in class TextItem
height
- height Default value is 19Appearance overview and related methods
public int getHeight()
getHeight
in class TextItem
Appearance overview and related methods
public void setMultiple(java.lang.Boolean multiple)
Support is not full-cycle at the server - that is, there are server APIs for retrieving each file that was uploaded, but no built-in support for storing multiple files against a single DataSource field. However, you can write custom server DMI code to do something with the files - for instance, you could create multiple new DataSource records for each file via a server DMI like this below:
String fileNameStr = (String)dsRequest.getValues().get("image_filename").toString(); String[] fileNames = fileNameStr.split(", "); List files = dsRequest.getUploadedFiles(); for (int i = 0; i < files.size(); i++) { ISCFileItem file = (ISCFileItem)files.get(i); InputStream fileData = file.getInputStream(); DSRequest inner = new DSRequest("mediaLibrary", "add"); Map values = new HashMap(); values.put("title", dsRequest.getValues().get("title")); values.put("image", fileData); values.put("image_filename", fileNames[i]); values.put("image_filesize", file.getSize()); values.put("image_date_created", new Date()); inner.setValues(values); inner.execute(); } DSResponse dsResponse = new DSResponse(); dsResponse.setStatus(0); return dsResponse;
multiple
- multiple Default value is truepublic java.lang.Boolean getMultiple()
Support is not full-cycle at the server - that is, there are server APIs for retrieving each file that was uploaded, but no built-in support for storing multiple files against a single DataSource field. However, you can write custom server DMI code to do something with the files - for instance, you could create multiple new DataSource records for each file via a server DMI like this below:
String fileNameStr = (String)dsRequest.getValues().get("image_filename").toString(); String[] fileNames = fileNameStr.split(", "); List files = dsRequest.getUploadedFiles(); for (int i = 0; i < files.size(); i++) { ISCFileItem file = (ISCFileItem)files.get(i); InputStream fileData = file.getInputStream(); DSRequest inner = new DSRequest("mediaLibrary", "add"); Map values = new HashMap(); values.put("title", dsRequest.getValues().get("title")); values.put("image", fileData); values.put("image_filename", fileNames[i]); values.put("image_filesize", file.getSize()); values.put("image_date_created", new Date()); inner.setValues(values); inner.execute(); } DSResponse dsResponse = new DSResponse(); dsResponse.setStatus(0); return dsResponse;
public void setWidth(int width)
setWidth
in class TextItem
width
- width Default value is 150Appearance overview and related methods
public int getWidth()
getWidth
in class TextItem
Appearance overview and related methods
public void deselectValue()
UploadItem
.deselectValue
in class TextItem
public void deselectValue(java.lang.Boolean start)
UploadItem
.deselectValue
in class TextItem
start
- By default the text insertion cursor will be moved to the end of the current value - pass in this parameter to move to
the start insteadpublic int[] getSelectionRange()
UploadItem
.getSelectionRange
in class TextItem
null
public void selectValue()
UploadItem
.selectValue
in class TextItem
public void setSelectionRange()
UploadItem
.public void setValue()
public static void setDefaultProperties(UploadItem uploadItemProperties)
Note: This method is intended for setting default attributes only and will effect all instances of the underlying class (including those automatically generated in JavaScript). This method should not be used to apply standard EventHandlers or override methods for a class - use a custom subclass instead.
uploadItemProperties
- properties that should be used as new defaults when instances of this class are created