Example usage for com.google.gwt.user.client.ui FormPanel ENCODING_MULTIPART

List of usage examples for com.google.gwt.user.client.ui FormPanel ENCODING_MULTIPART

Introduction

In this page you can find the example usage for com.google.gwt.user.client.ui FormPanel ENCODING_MULTIPART.

Prototype

String ENCODING_MULTIPART

To view the source code for com.google.gwt.user.client.ui FormPanel ENCODING_MULTIPART.

Click Source Link

Document

Used with #setEncoding(String) to specify that the form will be submitted using MIME encoding (necessary for FileUpload to work properly).

Usage

From source file:stroom.streamstore.client.presenter.StreamUploadPresenter.java

License:Apache License

@Inject
public StreamUploadPresenter(final EventBus eventBus, final DataUploadView view,
        final ClientDispatchAsync dispatcher) {
    super(eventBus, view);

    view.getForm().setAction(dispatcher.getImportFileURL());
    view.getForm().setEncoding(FormPanel.ENCODING_MULTIPART);
    view.getForm().setMethod(FormPanel.METHOD_POST);

    final AbstractSubmitCompleteHandler submitCompleteHandler = new AbstractSubmitCompleteHandler(
            "Uploading Data", this) {
        @Override//w  w w.ja v a  2 s  .  com
        public void onSubmit(final SubmitEvent event) {
            if (!valid()) {
                event.cancel();
            } else {
                super.onSubmit(event);
            }
        }

        @Override
        protected void onSuccess(final ResourceKey resourceKey) {
            final String fileName = getView().getFileUpload().getFilename();
            final Long effectiveMs = getView().getEffectiveDate();
            final UploadDataAction action = new UploadDataAction(resourceKey, feed,
                    getView().getStreamType().getSelectedItem(), effectiveMs, getView().getMetaData(),
                    fileName);
            final AsyncCallbackAdaptor<ResourceKey> callback = new AsyncCallbackAdaptor<ResourceKey>() {
                @Override
                public void onSuccess(final ResourceKey result) {
                    hide();
                    AlertEvent.fireInfo(StreamUploadPresenter.this.streamPresenter, "Uploaded file", null);
                    streamPresenter.refresh();
                }

                @Override
                public void onFailure(final Throwable caught) {
                    error(caught.getMessage());
                }
            };

            dispatcher.execute(action, callback);
        }

        @Override
        protected void onFailure(final String message) {
            error(message);
        }
    };

    registerHandler(getView().getForm().addSubmitHandler(submitCompleteHandler));
    registerHandler(getView().getForm().addSubmitCompleteHandler(submitCompleteHandler));
}

From source file:tv.dyndns.kishibe.qmaclone.client.setting.PanelSettingIcon.java

License:Open Source License

public PanelSettingIcon() {
    setHorizontalAlignment(ALIGN_CENTER);
    add(new HTML("?????</br>"
            + "?64KB??</br>"
            + "???????</br>"
            + "?????????</br>"
            + "???????????????"));

    image.setPixelSize(96, 96);/* w  w  w .  j a  v a  2 s  . c o  m*/
    add(image);

    VerticalPanel panelForm = new VerticalPanel();

    Hidden hiddenUserCode = new Hidden();
    hiddenUserCode.setName(Constant.FORM_NAME_USER_CODE);
    hiddenUserCode.setValue(UserData.get().getUserCode() + "");
    panelForm.add(hiddenUserCode);

    fileUpload.setName(Constant.FORM_NAME_ICON);
    panelForm.add(fileUpload);

    form.setAction("icon");
    form.setEncoding(FormPanel.ENCODING_MULTIPART);
    form.setMethod(FormPanel.METHOD_POST);
    form.addSubmitCompleteHandler(this);
    form.setWidget(panelForm);
    add(form);

    add(buttonSubmit);

    htmlMessage.addStyleDependentName("settingMessage");
    add(htmlMessage);

    checkForm();
}

From source file:za.co.brewtour.client.application.imageupload.ImageUploadView.java

License:Apache License

@Inject
public ImageUploadView(final Binder binder) {
    initWidget(binder.createAndBindUi(this));

    // Disable the button until we get the URL to POST to
    setUploadButton("Loading...", false);
    uploadForm.setEncoding(FormPanel.ENCODING_MULTIPART);
    uploadForm.setMethod(FormPanel.METHOD_POST);
    uploadFile.setName("image");
}