|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.smartgwt.client.core.JsObject
com.smartgwt.client.core.DataClass
com.smartgwt.client.core.RefDataClass
com.smartgwt.client.widgets.form.fields.FormItem
com.smartgwt.client.widgets.form.fields.CanvasItem
com.smartgwt.client.widgets.form.fields.MultiFileItem
public class MultiFileItem
The MultiFileItem provides an interface for a user to save one or more files that are related to a DataSource record, where each file is represented by a record in a related DataSource.
Use MultiFileItem when a record may have one or more files associated with it (such as
attachments to an email message) where no information about the files needs to be stored other
than the files themselves. If you have several fields associated with each file (such as an
uploaded document with a version, comments and processes associated with it), consider
instead an ordinary DataSource with on field of type "binary", and using the FileItem
for upload.
See the Uploading Files overview for more information on upload.
DataSource Setup
In a relationship sometimes called a "master-detail" relationship, the MultiFileItem stores files in a "detail" DataSource which are related to a "master" DataSource record being edited by the form which contains the MultiFileItem.
To use a MultiFileItem:
primaryKey field
foreignKey relationship to the
primaryKey of the "master" DataSource
bind a DynamicForm to the "master" DataSource
editorType:"MultiFileItem" and a
dataSource
property set to the ID of the "detail" DataSource
ID "masterRecord" and with a
primaryKey
field "id".
<DataSource ID="uploadedFiles" serverType="sql">
<fields>
<field name="fileId" type="sequence" primaryKey="true" hidden="true"/>
<field name="masterRecordId" type="number" foreignKey="masterRecord.id" hidden="true"/>
<field name="file" type="binary" title="File"/>
</fields>
</DataSource>
Aside from a single "binary" field, the "detail" DataSource should generally have only hidden fields, as shown above. Additional internal fields (such as a "lastUpdated" field) may be added, but will not be editable via MultiFileItem.
Display
The MultiFileItem appears as a list of files related to the current record. An optional
button, the removeButton allows removing
files. A
second optional button, the editButton,
launches a
picker for uploading further files.
Saving
In all cases, uploading a new file is an "add" DSRequest against the
dataSource.
The MultiFileItem has two modes, according to whether the "master" record is being newly created via an "add" operation or whether the master record is pre-existing ("update" operation).
If the master record is pre-existing, each file added by the user is uploaded as soon as the user exits the picker launched from the edit button, and the list of files shown in the main form reflects the actual list of stored files.
If the master record is being newly created, files are not actually uploaded until after the master record is confirmed saved, and the list of fields shown in the main form reflects files which will be uploaded after the master record is saved.
In both cases, if there are multiple files to upload, they are uploaded one at a time, as a
series of separate "add" DSRequests against the dataSource.
Also in both cases, deletion of any file is immediate. In the case of a pre-existing master
record, all files shown actually exist as DataSource records, and deletion is performed as a
"remove" DSRequest against the dataSource.
Upload overview and related methods| Field Summary |
|---|
| Fields inherited from class com.smartgwt.client.core.JsObject |
|---|
jsObj |
| Constructor Summary | |
|---|---|
MultiFileItem()
|
|
MultiFileItem(com.google.gwt.core.client.JavaScriptObject jsObj)
|
|
MultiFileItem(java.lang.String name)
|
|
MultiFileItem(java.lang.String name,
java.lang.String title)
|
|
| Method Summary | |
|---|---|
java.lang.String |
getEmptyMessage()
Empty message to display when there are no files listed. |
static MultiFileItem |
getOrCreateRef(com.google.gwt.core.client.JavaScriptObject jsObj)
|
void |
setEmptyMessage(java.lang.String emptyMessage)
Empty message to display when there are no files listed. |
void |
setJavaScriptObject(com.google.gwt.core.client.JavaScriptObject jsObj)
|
| Methods inherited from class com.smartgwt.client.widgets.form.fields.CanvasItem |
|---|
addShowValueHandler, createCanvas, getApplyPromptToCanvas, getAutoDestroy, getCanvas, getEditCriteriaInInnerForm, getOverflow, getPrompt, getShouldSaveValue, hasAdvancedCriteria, setApplyPromptToCanvas, setAutoDestroy, setCanEditCriterionPredicate, setCanvas, setCriterionGetter, setCriterionSetter, setEditCriteriaInInnerForm, setOverflow, setPrompt, setShouldSaveValue, setupCanvasConstructor, storeValue, storeValue, storeValue |
| Methods inherited from class com.smartgwt.client.core.RefDataClass |
|---|
getRef, getRef |
| Methods inherited from class com.smartgwt.client.core.DataClass |
|---|
doAddHandler, fireEvent, getAttributeAsDoubleArray, getAttributeAsIntArray, getAttributeAsLong, getAttributeAsMap, getAttributeAsObject, getAttributeAsRecord, getAttributeAsStringArray, getAttributes, getHandlerCount, getJsObj, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute |
| Methods inherited from class com.smartgwt.client.core.JsObject |
|---|
setJsObj |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface com.google.gwt.event.shared.HasHandlers |
|---|
fireEvent |
| Constructor Detail |
|---|
public MultiFileItem()
public MultiFileItem(com.google.gwt.core.client.JavaScriptObject jsObj)
public MultiFileItem(java.lang.String name)
public MultiFileItem(java.lang.String name,
java.lang.String title)
| Method Detail |
|---|
public static MultiFileItem getOrCreateRef(com.google.gwt.core.client.JavaScriptObject jsObj)
public void setJavaScriptObject(com.google.gwt.core.client.JavaScriptObject jsObj)
setJavaScriptObject in class CanvasItempublic void setEmptyMessage(java.lang.String emptyMessage)
emptyMessage - . See String. Default value is "Click icon to add..."public java.lang.String getEmptyMessage()
String
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||