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
FormItem.CustomStateGetter, FormItem.StateCustomizer
scClassName, warnOnEditorTypeConversion, warnOnEditorTypeConversionDefault
id
factoryCreated, factoryProperties, readOnly
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 . |
java.lang.String |
getTextBoxStyle()
Base CSS class name for this
UploadItem 's native file input element. |
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 |
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 |
setTextBoxStyle(java.lang.String textBoxStyle)
Base CSS class name for this
UploadItem 's native file input element. |
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, getEditProxyConstructor, getEnforceLength, getEnteredValue, getEscapeHTML, getFetchMissingValues, getFormatOnBlur, getFormatOnFocusChange, getHint, getKeyPressFilter, getLength, getMask, getMaskOverwriteMode, getMaskPadChar, getMaskPromptChar, getMaskSaveLiterals, getPrintFullText, getSaveOnEnter, getSelectOnClick, getSelectOnFocus, getShowHintInField, getSupportsCutPasteEvents, getUsePlaceholderForHint, getValueAsString, pendingStatusChanged, setBrowserAutoCapitalize, setBrowserAutoCorrect, setBrowserInputType, setChangeOnKeypress, setCharacterCasing, setDefaultProperties, setEditProxyConstructor, setEnforceLength, setEscapeHTML, setFetchMissingValues, setFormatOnBlur, setFormatOnFocusChange, setKeyPressFilter, setLength, setMask, setMaskOverwriteMode, setMaskPadChar, setMaskPromptChar, setMaskSaveLiterals, setPastedValueTransformer, setPrintFullText, setSaveOnEnter, setSelectionRange, setSelectOnClick, setSelectOnFocus, setShowHintInField, setSupportsCutPasteEvents, setUsePlaceholderForHint, shouldFetchMissingValue
_getValue, addBlurHandler, addChangedHandler, addChangeHandler, addClickHandler, addDoubleClickHandler, addEditorEnterHandler, addEditorExitHandler, addFocusHandler, addIconClickHandler, addIconKeyPressHandler, addItemHoverHandler, addKeyDownHandler, addKeyPressHandler, addKeyUpHandler, addPendingStatusChangedHandler, addPickerIconClickHandler, addShowContextMenuHandler, addTitleClickHandler, addTitleDoubleClickHandler, addTitleHoverHandler, addValueHoverHandler, addValueIconClickHandler, applyFormula, asSGWTComponent, blurItem, canEditCriterion, clearErrors, clearValue, disable, disableIcon, enable, enableIcon, error, error, errorIfNotCreated, focusInItem, getAccessKey, getAlign, getAllowExpressions, getAlwaysFetchMissingValues, getApplyAlignToText, getApplyHeightToTextBox, getAriaRole, getAttribute, getAttributeAsBoolean, getAttributeAsBoolean, getAttributeAsDate, getAttributeAsDouble, getAttributeAsFloat, getAttributeAsInt, getAttributeAsJavaScriptObject, getAttributeAsObject, getAttributeAsString, getAutoComplete, getBrowserSpellCheck, getCanEdit, getCanEditOpaqueValues, getCanFocus, getCanSelectText, getCanTabToIcons, getCanvasAutoChild, getCellHeight, getCellStyle, getClassName, getClipStaticValue, getClipTitle, getConfig, getContainerWidget, getControlStyle, getCriteriaField, getCriterion, getCriterion, getCursorPosition, getCustomState, getDataPath, getDateFormatter, getDecimalPad, getDecimalPrecision, getDefaultIconSrc, getDisabled, getDisableIconsOnReadOnly, getDisplayField, getDisplayFieldName, getDisplayValue, getDisplayValue, getEditorTypeConfig, getEditPendingCSSText, getEmptyDisplayValue, getEmptyValueIcon, getEndRow, getErrorIconHeight, getErrorIconSrc, getErrorIconWidth, getErrorMessageWidth, getErrors, getExportFormat, getFieldName, getFilterLocally, getForeignDisplayField, getForm, getFormat, getFormItemAutoChild, getFormula, getFullDataPath, getGlobalTabIndex, getGridColNum, getGridRowNum, getHeightAsString, getHidden, getHintStyle, getHoverAlign, getHoverDelay, getHoverHeight, getHoverOpacity, getHoverStyle, getHoverVAlign, getHoverWidth, getIcon, getIconHeight, getIconHSpace, getIconPageRect, getIconPrompt, getIconRect, getIconVAlign, getIconWidth, getImageURLPrefix, getImageURLSuffix, getImplicitSave, getImplicitSaveOnBlur, getInputFormat, getLeft, getLoadingDisplayValue, getLocateItemBy, getMinHintWidth, getMultipleValueSeparator, getName, getOperator, getOptionCriteria, getOptionDataSource, getOptionDataSourceAsString, getOptionFilterContext, getOptionOperationId, getOriginalValueMessage, getPageLeft, getPageRect, getPageTop, getPicker, getPickerIconHeight, getPickerIconName, getPickerIconPrompt, getPickerIconProperties, getPickerIconSrc, getPickerIconStyle, getPickerIconWidth, getPixelHeight, getPixelWidth, getPrintTextBoxStyle, getPrintTitleStyle, getPrompt, getReadOnlyDisplay, getReadOnlyHover, getReadOnlyTextBoxStyle, getReadOnlyWhen, getRect, getRedrawOnChange, getRejectInvalidValueOnChange, getRequired, getRequiredMessage, getRequiredWhen, getRowSpan, getScClassName, getSelectedRecord, getShouldSaveValue, getShowClippedTitleOnHover, getShowClippedValueOnHover, getShowDeletions, getShowDisabled, getShowErrorIcon, getShowErrorStyle, getShowErrorText, getShowFocused, getShowFocusedErrorState, getShowFocusedIcons, getShowFocusedPickerIcon, getShowHint, getShowIcons, getShowOldValueInHover, getShowOver, getShowOverIcons, getShowPending, getShowPickerIcon, getShowRTL, getShowTitle, getShowValueIconOnly, getStartRow, getStaticHeight, getStopOnError, getSuppressValueIcon, getSynchronousValidation, getTabIndex, getTextAlign, getTextFormula, getTimeFormatter, getTitle, getTitleAlign, getTitleColSpan, getTitleOrientation, getTitleStyle, getTitleVAlign, getTooltip, getTop, getType, getUpdateControlOnOver, getUpdatePickerIconOnOver, getUpdateTextBoxOnOver, getUseDisabledHintStyleForReadOnly, getValidateOnChange, getValidateOnExit, getValidOperators, getVAlign, getValue, getValueAsRecordList, getValueDeselectedCSSText, getValueField, getValueFieldName, getValueIconHeight, getValueIconLeftPadding, getValueIconRightPadding, getValueIconSize, getValueIconWidth, getVisible, getVisibleHeight, getVisibleTitleWidth, getVisibleWhen, getVisibleWidth, getWarnOnEditorTypeConversion, getWarnOnEditorTypeConversionDefault, getWidthAsString, getWrapHintText, getWrapTitle, handleWarnOnEditorTypeConversion, hasAdvancedCriteria, hasErrors, hide, hideIcon, invalidateDisplayValueCache, isCreated, isCutEvent, isDisabled, isDrawn, isFocused, isInGrid, isPasteEvent, isVisible, linkToInstanceUponCreate, mapDisplayToValue, mapValueToDisplay, mapValueToDisplay, mapValueToDisplay, redraw, redraw, setAccessKey, setAlign, setAllowExpressions, setAlwaysFetchMissingValues, setApplyAlignToText, setApplyHeightToTextBox, setAriaRole, setAriaState, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAutoChildConstructor, setAutoChildProperties, setAutoChildProperties, setAutoChildProperties, setAutoChildVisibility, setAutoComplete, setBrowserSpellCheck, setCanEdit, setCanEditCriterionPredicate, setCanEditOpaqueValues, setCanFocus, setCanSelectText, setCanTabToIcons, setCellHeight, setCellStyle, setClipStaticValue, setClipTitle, setColSpan, setColSpan, setControlStyle, setCriteriaField, setCriterion, setCriterionGetter, setCriterionSetter, setCustomStateGetter, 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, setErrors, setErrors, setExportFormat, setFilterLocally, setForeignDisplayField, setFormat, setFormula, setGlobalTabIndex, setHeight, setHidden, setHint, setHintStyle, setHoverAlign, setHoverDelay, setHoverHeight, setHoverOpacity, setHoverStyle, setHoverVAlign, setHoverWidth, setIconDisabled, setIconHeight, setIconHSpace, setIconPrompt, setIcons, setIconVAlign, setIconWidth, setImageURLPrefix, setImageURLSuffix, setImplicitSave, setImplicitSaveOnBlur, setInitHandler, setInputFormat, setInputTransformer, setItemHoverFormatter, setItemTitleHoverFormatter, setItemValueHoverFormatter, setJavaScriptObject, setLeft, setLoadingDisplayValue, setLocateItemBy, setMinHintWidth, setMultipleValueSeparator, setName, setNullProperty, setOperator, setOptionCriteria, setOptionDataSource, setOptionDataSource, setOptionFilterContext, setOptionOperationId, setOriginalValueMessage, setPickerIconHeight, setPickerIconName, setPickerIconPrompt, setPickerIconProperties, setPickerIconSrc, setPickerIconStyle, setPickerIconWidth, setPrintTextBoxStyle, setPrintTitleStyle, setPrompt, setProperty, setProperty, setProperty, setProperty, setProperty, setReadOnlyDisplay, setReadOnlyHover, setReadOnlyTextBoxStyle, setReadOnlyWhen, setRedrawOnChange, setRejectInvalidValueOnChange, setRequired, setRequiredMessage, setRequiredWhen, setRowSpan, setScClassName, setShouldSaveValue, setShowClippedTitleOnHover, setShowClippedValueOnHover, setShowDeletions, setShowDisabled, setShowErrorIcon, setShowErrorStyle, setShowErrorText, setShowFocused, setShowFocusedErrorState, setShowFocusedIcons, setShowFocusedPickerIcon, setShowHint, setShowIcons, setShowIfCondition, setShowOldValueInHover, setShowOver, setShowOverIcons, setShowPending, setShowPickerIcon, setShowRTL, setShowTitle, setShowValueIconOnly, setStartRow, setStateCustomizer, setStaticHeight, setStopOnError, setSuppressValueIcon, setSynchronousValidation, setTabIndex, setTextAlign, setTextFormula, setTimeFormatter, setTitle, setTitleAlign, setTitleColSpan, setTitleHoverFormatter, setTitleOrientation, setTitleStyle, setTitleVAlign, setTooltip, setTop, setType, setUpdateControlOnOver, setUpdatePickerIconOnOver, setUpdateTextBoxOnOver, setUseDisabledHintStyleForReadOnly, setValidateOnChange, setValidateOnExit, setValidators, setValidOperators, setVAlign, setValue, setValue, setValue, setValue, setValue, setValue, setValueDeselectedCSSText, setValueField, setValueFormatter, setValueHoverFormatter, setValueIconHeight, setValueIconLeftPadding, setValueIconMapper, setValueIconRightPadding, setValueIcons, setValueIconSize, setValueIconWidth, setValueMap, setValueMap, setVisible, setVisibleWhen, setWarnOnEditorTypeConversion, setWarnOnEditorTypeConversionDefault, setWidth, setWrapHintText, setWrapTitle, shouldApplyHeightToTextBox, shouldSaveOnEnter, shouldStopKeyPressBubbling, show, showIcon, showPicker, stopHover, storeValue, storeValue, updateState, validate, valueClipped
getRef, getRef, internalSetID
applyFactoryProperties, doAddHandler, fireEvent, getAttributeAsDoubleArray, getAttributeAsIntArray, getAttributeAsLong, getAttributeAsMap, getAttributeAsObject, getAttributeAsRecord, getAttributeAsStringArray, getAttributes, getHandlerCount, getReadOnly, isFactoryCreated, logConfiguration, setAttribute, setAttribute, setAttribute, setAttributeAsJavaObject, setFactoryCreated, setReadOnly
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 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. For usage tips on this
param, see SGWTProperties
.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. For usage tips on this
param, see SGWTProperties
.AutoChildUsage
public static void changePickerIconDefaults(FormItemIcon defaults)
public void setAccept(java.lang.String accept)
Note that this property
makes use of the HTML accept
attribute, and so relies on the browser to perform the desired filtering. For
further study, see:
accept
- Default value is nullpublic java.lang.String getAccept()
Note that this property
makes use of the HTML accept
attribute, and so relies on the browser to perform the desired filtering. For
further study, see:
public void setHeight(int height)
setHeight
in class FormItem
height
- Default value is 19FormLayout overview and related methods
,
Filling Examplepublic int getHeight()
getHeight
in class FormItem
FormLayout overview and related methods
,
Filling Examplepublic 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
- 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 setTextBoxStyle(java.lang.String textBoxStyle)
UploadItem
's native file input element. Note that the customization via CSS of a native file input element allowable by the browser varies widely; in some browsers on certain platforms, it may be possible to customize certain CSS properties, but not in others; or, it may be that the CSS property (e.g. border) is applied differently in some browsers.
If the textBoxStyle is changed at runtime, FormItem.updateState()
must be called to update the visual
state. However, calling updateState() will clear any file selected by the user to be uploaded.
setTextBoxStyle
in class TextItem
textBoxStyle
- FormItemBaseStyle . Default value is "uploadItem"
,
FormItem.setCellStyle(java.lang.String)
,
FormItemStyling overview and related methods
public java.lang.String getTextBoxStyle()
UploadItem
's native file input element. Note that the customization via CSS of a native file input element allowable by the browser varies widely; in some browsers on certain platforms, it may be possible to customize certain CSS properties, but not in others; or, it may be that the CSS property (e.g. border) is applied differently in some browsers.
If the textBoxStyle is changed at runtime, FormItem.updateState()
must be called to update the visual
state. However, calling updateState() will clear any file selected by the user to be uploaded.
getTextBoxStyle
in class TextItem
FormItemBaseStyle
,
FormItem.getCellStyle()
,
FormItemStyling overview and related methods
public void setWidth(int width)
setWidth
in class FormItem
width
- Default value is 150FormLayout overview and related methods
,
Spanning Examplepublic int getWidth()
getWidth
in class FormItem
FormLayout overview and related methods
,
Spanning Examplepublic 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 affect 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. Calling this method after instances have been created can result in undefined behavior, since it bypasses any setters and a class instance may have already examined a particular property and not be expecting any changes through this route.
uploadItemProperties
- properties that should be used as new defaults when instances of this class are createdSGWTProperties