|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Upload
SmartGWT provides special client and server-side support for file upload that allows uploaded files to be treated like ordinary DataSource fields. This includes:
FileItem
and com.smartgwt.client..MultiFileItem
FormItems that enable users to upload one or
more files as a background operation, without leaving the current page
Single file upload: "binary" field type
To use SmartGWT's client-server upload system, you use a DataSource field of
type
"binary". By default, a DynamicForm bound to a DataSource
with a field of type "binary" will use the FileItem
, which displays a standard HTML
<input type="upload"> form control.
When you call DynamicForm.saveData()
on a DynamicForm containing a FileItem,
SmartGWT processes the save identically to a saveData() call that did not include a file
upload:
FieldType
.
Client-side callbacks, such as the callback passed to saveData(), fire normally.
Processing File Uploads with server-side business logic
Server-side business logic that processes file uploads may retrieve upload files via the server side API dsRequest.getUploadedFile(fieldName). The uploaded file is returned as an instance of ISCFileItem, which provides access to a Java InputStream as well as metadata about the file (size, name). See the ${isc.DocUtils.linkForDocNode('javaServerReference', 'Java Server Reference')} for details.
NOTE: request processing engines such as
Struts may parse the inbound request before SmartGWT receives it. If you are creating an
RPCManager object inside of a Struts Action and the file being uploaded is not available via
dsRequest.getUploadedFile()
, this is likely to be the problem, and you should
use SmartGWT com.smartgwt.client..DMI
instead.
Server-side validation errors may be provided, including validation errors for the uploaded file (such as too large or invalid content), and will be displayed in the form that attempted an upload.
Be aware of the following special concerns when processing file uploads:
Multi file upload: 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.
See the com.smartgwt.client..MultiFileItem
docs for details.
Upload without the SmartGWT Server
If it is acceptable that the application will do a full-page reload after the upload completes, you can simply:
encoding
to "multipart"
UploadItem
to get a basic HTML upload control
action
to a URL where you have deployed server-side code to
handle the upload
DynamicForm.submitForm()
to cause the form to be submitted
Note that when you submitForm(), the only values that will be sent to your actionURL are
values for which actual FormItems exist. This differs from saveData(), in which the
entire set of values
are always sent. To handle submitting
extra values, use HiddenItem
s.
For further details, see the UploadItem
docs.
Background upload without the SmartGWT Server
Achieving background file upload without using the SmartGWT server is also possible
although considerably more advanced. In addition to the steps above, create a hidden
<iframe> element in the page, and use target
to target the form
submission at this IFRAME. In order receive a callback notification when the upload
completes, after processing the file upload, your server should output HTML content for the
IFRAME that includes a <SCRIPT> block which will navigate out of the IFRAME (generally
via the JavaScript global "top") and call a global method you have declared as a callback.
ListGrid.getAutoFitMaxColumns()
,
ListGrid.getAutoFitMaxColumns()
,
ListGrid.getAutoFitMaxColumns()
,
ListGrid.getAutoFitMaxColumns()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |