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

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

Introduction

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

Prototype

String METHOD_POST

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

Click Source Link

Document

Used with #setMethod(String) to specify that the form will be submitted using an HTTP POST request (necessary for FileUpload to work properly).

Usage

From source file:org.eclipse.che.ide.ext.datasource.client.ssl.upload.UploadSslKeyDialogViewImpl.java

License:Open Source License

/** {@inheritDoc} */
@Override
public void setAction(@NotNull String url) {
    uploadForm.setAction(url);
    uploadForm.setMethod(FormPanel.METHOD_POST);
}

From source file:org.eclipse.che.ide.ext.datasource.client.ssl.upload.UploadSslTrustCertDialogViewImpl.java

License:Open Source License

@Override
public void setAction(@NotNull String url) {
    uploadForm.setAction(url);
    uploadForm.setMethod(FormPanel.METHOD_POST);
}

From source file:org.eclipse.che.ide.projectimport.local.LocalZipImporterPageViewImpl.java

License:Open Source License

@Override
public void setAction(@NotNull String url) {
    submitForm.setMethod(FormPanel.METHOD_POST);
    submitForm.setAction(url);
}

From source file:org.eclipse.che.ide.upload.file.UploadFileViewImpl.java

License:Open Source License

/** {@inheritDoc} */
@Override
public void setAction(@NotNull String url) {
    submitForm.setAction(url);
    submitForm.setMethod(FormPanel.METHOD_POST);
}

From source file:org.eclipse.kura.web.client.ui.Device.CommandTabUi.java

License:Open Source License

public CommandTabUi() {
    initWidget(uiBinder.createAndBindUi(this));

    this.formExecute.clear();
    this.formExecute.setFocus(true);
    this.formExecute.setName("command");
    this.formExecute.addKeyDownHandler(new KeyDownHandler() {

        @Override/*from w w w  .  j  ava 2 s .co  m*/
        public void onKeyDown(KeyDownEvent event) {
            if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
                CommandTabUi.this.formPassword.setFocus(true);
            }
        }
    });

    this.xsrfTokenField.setID("xsrfToken");
    this.xsrfTokenField.setName("xsrfToken");
    this.xsrfTokenField.setValue("");

    this.formPassword.setText(null);
    this.formPassword.setName("password");
    this.formPassword.addKeyDownHandler(new KeyDownHandler() {

        @Override
        public void onKeyDown(KeyDownEvent event) {
            if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
                CommandTabUi.this.execute.setFocus(true);
            }
        }
    });

    this.docPath.setName("file");

    display(MSGS.deviceCommandNoOutput());

    this.reset.setText(MSGS.reset());
    this.reset.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            CommandTabUi.this.commandForm.reset();
            CommandTabUi.this.formExecute.setFocus(true);
            display(MSGS.deviceCommandNoOutput());
        }
    });

    this.execute.setText(MSGS.deviceCommandExecute());
    this.execute.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {

            CommandTabUi.this.gwtXSRFService.generateSecurityToken(new AsyncCallback<GwtXSRFToken>() {

                @Override
                public void onFailure(Throwable ex) {
                    FailureHandler.handle(ex);
                }

                @Override
                public void onSuccess(GwtXSRFToken token) {
                    CommandTabUi.this.xsrfTokenField.setValue(token.getToken());
                    CommandTabUi.this.commandForm.submit();
                    CommandTabUi.this.formExecute.setFocus(true);
                }
            });
            // http://www.gwtproject.org/javadoc/latest/com/google/gwt/user/client/ui/FileUpload.html
        }
    });

    this.commandForm.setEncoding(FormPanel.ENCODING_MULTIPART);
    this.commandForm.setMethod(FormPanel.METHOD_POST);
    this.commandForm.setAction(SERVLET_URL);

    this.commandForm.addSubmitCompleteHandler(new FormPanel.SubmitCompleteHandler() {

        @Override
        public void onSubmitComplete(SubmitCompleteEvent event) {

            String result = event.getResults();

            if (result.contains("HTTP ERROR")) {
                display(MSGS.fileUploadFailure());
            } else {
                EntryClassUi.showWaitModal();
                CommandTabUi.this.gwtXSRFService.generateSecurityToken(new AsyncCallback<GwtXSRFToken>() {

                    @Override
                    public void onFailure(Throwable ex) {
                        EntryClassUi.hideWaitModal();
                        FailureHandler.handle(ex);
                    }

                    @Override
                    public void onSuccess(GwtXSRFToken token) {
                        CommandTabUi.this.gwtDeviceService.executeCommand(token,
                                CommandTabUi.this.formExecute.getText(),
                                CommandTabUi.this.formPassword.getText(), new AsyncCallback<String>() {

                                    @Override
                                    public void onFailure(Throwable caught) {
                                        if (caught.getLocalizedMessage()
                                                .equals(GwtKuraErrorCode.SERVICE_NOT_ENABLED.toString())) {
                                            display(MSGS.error() + "\n" + MSGS.commandServiceNotEnabled());
                                        } else if (caught.getLocalizedMessage()
                                                .equals(GwtKuraErrorCode.ILLEGAL_ARGUMENT.toString())) {
                                            display(MSGS.error() + "\n" + MSGS.commandPasswordNotCorrect());
                                        } else {
                                            display(MSGS.error() + "\n" + caught.getLocalizedMessage());
                                        }
                                        EntryClassUi.hideWaitModal();
                                    }

                                    @Override
                                    public void onSuccess(String result) {
                                        display(result);
                                        EntryClassUi.hideWaitModal();
                                    }

                                });
                    }

                });
            }

        }

    });

}

From source file:org.eclipse.kura.web.client.ui.Packages.PackagesPanelUi.java

License:Open Source License

private void upload() {
    this.uploadModal.show();

    // ******FILE TAB ****//
    this.fileLabel.setText(MSGS.fileLabel());

    this.filePath.setName("uploadedFile");

    this.xsrfTokenFieldFile.setID("xsrfToken");
    this.xsrfTokenFieldFile.setName("xsrfToken");
    this.xsrfTokenFieldFile.setValue("");

    this.packagesFormFile.setAction(SERVLET_URL + "/upload");
    this.packagesFormFile.setEncoding(FormPanel.ENCODING_MULTIPART);
    this.packagesFormFile.setMethod(FormPanel.METHOD_POST);
    this.packagesFormFile.addSubmitCompleteHandler(new SubmitCompleteHandler() {

        @Override/*from   w  w w.ja v  a 2  s  .  co m*/
        public void onSubmitComplete(SubmitCompleteEvent event) {
            String result = event.getResults();
            if (result == null || result.isEmpty()) {
                PackagesPanelUi.this.uploadModal.hide();
                refresh(2500);
            } else {
                logger.log(Level.SEVERE, "Error uploading package!");
            }
        }
    });

    // ******URL TAB ****//
    this.formUrl.setName("packageUrl");

    this.xsrfTokenFieldUrl.setID("xsrfToken");
    this.xsrfTokenFieldUrl.setName("xsrfToken");
    this.xsrfTokenFieldUrl.setValue("");

    this.packagesFormUrl.setAction(SERVLET_URL + "/url");
    this.packagesFormUrl.setMethod(FormPanel.METHOD_POST);
    this.packagesFormUrl.addSubmitCompleteHandler(new SubmitCompleteHandler() {

        @Override
        public void onSubmitComplete(SubmitCompleteEvent event) {
            String result = event.getResults();
            if (result == null || result.isEmpty()) {
                PackagesPanelUi.this.uploadModal.hide();
                refresh(2500);
            } else {
                String errMsg = result;
                int startIdx = result.indexOf("<pre>");
                int endIndex = result.indexOf("</pre>");
                if (startIdx != -1 && endIndex != -1) {
                    errMsg = result.substring(startIdx + 5, endIndex);
                }
                logger.log(Level.SEVERE, MSGS.error() + ": " + MSGS.fileDownloadFailure() + ": " + errMsg);
            }
        }
    });
}

From source file:org.eclipse.kura.web.client.ui.Settings.SnapshotsTabUi.java

License:Open Source License

private void uploadAndApply() {
    this.uploadModal.show();
    this.uploadModal.setTitle(MSGS.upload());
    this.snapshotsForm.setEncoding(FormPanel.ENCODING_MULTIPART);
    this.snapshotsForm.setMethod(FormPanel.METHOD_POST);
    this.snapshotsForm.setAction(SERVLET_URL);

    this.filePath.setName("uploadedFile");

    this.xsrfTokenField.setID("xsrfToken");
    this.xsrfTokenField.setName("xsrfToken");
    this.xsrfTokenField.setValue("");

}

From source file:org.eurekastreams.web.client.ui.common.dialog.login.LoginDialogContent.java

License:Apache License

/**
 * Builds the UI.// w  ww. jav a  2 s . c o  m
 */
private void setupWidgets() {
    loginForm.setAction("/j_spring_security_check");
    loginForm.setMethod(FormPanel.METHOD_POST);

    loginContentContainer.addStyleName(StaticResourceBundle.INSTANCE.coreCss().loginContentContainer());

    FlowPanel loginPanel = new FlowPanel();
    loginPanel.addStyleName(StaticResourceBundle.INSTANCE.coreCss().loginContent());
    loginForm.setWidget(loginPanel);

    FlowPanel navPanel = new FlowPanel();
    navPanel.addStyleName(StaticResourceBundle.INSTANCE.coreCss().loginNavPanel());
    navPanel.add(errorMessage);
    loginContentContainer.add(navPanel);

    submitButton.addStyleName(StaticResourceBundle.INSTANCE.coreCss().loginButton());
    cancelButton.addStyleName(StaticResourceBundle.INSTANCE.coreCss().cancelButton());

    final FlowPanel usernamePanel = new FlowPanel();
    usernamePanel.addStyleName(StaticResourceBundle.INSTANCE.coreCss().formElement());
    Label usernameLabel = new Label("Username: ");
    usernameLabel.addStyleName(StaticResourceBundle.INSTANCE.coreCss().formLabel());
    usernamePanel.add(usernameLabel);

    username.setName("j_username");
    usernamePanel.add(username);

    loginPanel.add(usernamePanel);

    final FlowPanel passwordPanel = new FlowPanel();
    Label passwordLabel = new Label("Password: ");
    passwordPanel.addStyleName(StaticResourceBundle.INSTANCE.coreCss().formElement());
    passwordLabel.addStyleName(StaticResourceBundle.INSTANCE.coreCss().formLabel());
    passwordPanel.add(passwordLabel);

    password.setName("j_password");
    passwordPanel.add(password);

    Hidden returnTo = new Hidden("spring-security-redirect", "/login.html");
    returnTo.setName("spring-security-redirect");
    loginPanel.add(returnTo);

    loginPanel.add(passwordPanel);
    // rememberMe.setName("_spring_security_remember_me");
    // loginPanel.add(rememberMe);
    Hidden usePersistentLogon = new Hidden("_spring_security_remember_me", "on");
    usePersistentLogon.setName("_spring_security_remember_me");
    loginPanel.add(usePersistentLogon);

    errorMessage.addStyleName(StaticResourceBundle.INSTANCE.coreCss().formErrorBox());
    errorMessage.setVisible(false);

    loginContentContainer.add(loginPanel);

    FlowPanel buttonPanel = new FlowPanel();
    buttonPanel.addStyleName(StaticResourceBundle.INSTANCE.coreCss().loginButtonPanel());
    buttonPanel.add(submitButton);
    buttonPanel.add(cancelButton);
    loginContentContainer.add(buttonPanel);

    loginForm.add(loginContentContainer);
}

From source file:org.eurekastreams.web.client.ui.common.form.elements.avatar.AvatarUploadFormElement.java

License:Apache License

/**
 * Create an avatar upload form element.
 * /*from   www. j  av  a2  s  . co  m*/
 * @param label
 *            the label of the element.
 * @param desc
 *            the description.
 * @param servletPath
 *            the path to hit to upload the image
 * @param inProcessor
 *            the processor.
 * @param inStrategy
 *            the strategy.
 */
public AvatarUploadFormElement(final String label, final String desc, final String servletPath,
        final ActionProcessor inProcessor, final ImageUploadStrategy inStrategy) {
    description = desc;
    strategy = inStrategy;
    Boolean resizeable = strategy.isResizable();

    errorBox = new FlowPanel();
    errorBox.addStyleName(StaticResourceBundle.INSTANCE.coreCss().formErrorBox());
    errorBox.add(new Label("There was an error uploading your image. Please be sure "
            + "that your photo is under 4MB and is a PNG, JPG, or GIF."));

    errorBox.setVisible(false);

    this.addStyleName(StaticResourceBundle.INSTANCE.coreCss().formAvatarUpload());
    this.addStyleName(StaticResourceBundle.INSTANCE.coreCss().formElement());

    processor = inProcessor;
    // AvatarEntity Entity = inEntity;

    uploadForm.setAction(servletPath);

    uploadForm.setEncoding(FormPanel.ENCODING_MULTIPART);
    uploadForm.setMethod(FormPanel.METHOD_POST);

    Label photoLabel = new Label(label);
    photoLabel.addStyleName(StaticResourceBundle.INSTANCE.coreCss().formLabel());
    panel.add(photoLabel);

    FlowPanel avatarModificationPanel = new FlowPanel();
    avatarModificationPanel.addStyleName(StaticResourceBundle.INSTANCE.coreCss().avatarModificationPanel());

    avatarContainer.addStyleName(StaticResourceBundle.INSTANCE.coreCss().avatarContainer());
    avatarModificationPanel.add(avatarContainer);

    FlowPanel photoButtonPanel = new FlowPanel();
    photoButtonPanel.addStyleName(StaticResourceBundle.INSTANCE.coreCss().formPhotoButtonPanel());

    if (resizeable) {
        editButton = new Anchor("Resize");
        editButton.addStyleName(StaticResourceBundle.INSTANCE.coreCss().formResizeButton());
        editButton.addStyleName(StaticResourceBundle.INSTANCE.coreCss().formButton());
        photoButtonPanel.add(editButton);
    }

    deleteButton = new Anchor("Delete");
    deleteButton.addStyleName(StaticResourceBundle.INSTANCE.coreCss().formDeleteButton());
    deleteButton.addStyleName(StaticResourceBundle.INSTANCE.coreCss().formButton());
    photoButtonPanel.add(deleteButton);

    avatarModificationPanel.add(photoButtonPanel);
    panel.add(avatarModificationPanel);

    FlowPanel uploadPanel = new FlowPanel();
    uploadPanel.addStyleName(StaticResourceBundle.INSTANCE.coreCss().formUploadPanel());
    uploadPanel.add(errorBox);

    // Wrapping the FileUpload because otherwise IE7 shifts it way
    // to the right. I couldn't figure out why,
    // but for whatever reason, this works.
    FlowPanel fileUploadWrapper = new FlowPanel();
    FileUpload upload = new FileUpload();
    upload.setName("imageUploadFormElement");
    upload.addStyleName(StaticResourceBundle.INSTANCE.coreCss().formAvatarUpload());
    fileUploadWrapper.add(upload);
    uploadPanel.add(fileUploadWrapper);

    uploadPanel.add(new Label(description));
    Anchor submitButton = new Anchor("");
    submitButton.addStyleName(StaticResourceBundle.INSTANCE.coreCss().formUploadButton());
    submitButton.addStyleName(StaticResourceBundle.INSTANCE.coreCss().formButton());

    uploadPanel.add(submitButton);

    hiddenImage = new Image();
    hiddenImage.addStyleName(StaticResourceBundle.INSTANCE.coreCss().avatarHiddenOriginal());
    uploadPanel.add(hiddenImage);

    panel.add(uploadPanel);

    submitButton.addClickHandler(new ClickHandler() {
        public void onClick(final ClickEvent event) {
            uploadForm.submit();
        }
    });

    uploadForm.setWidget(panel);
    this.add(uploadForm);

    uploadForm.addSubmitCompleteHandler(new SubmitCompleteHandler() {
        public void onSubmitComplete(final SubmitCompleteEvent ev) {
            String result = ev.getResults().replaceAll("\\<.*?\\>", "");
            final boolean fail = "fail".equals(result);
            errorBox.setVisible(fail);
            if (!fail) {
                String[] results = result.split(",");
                if (results.length >= 4) {
                    strategy.setX(Integer.parseInt(results[1]));
                    strategy.setY(Integer.parseInt(results[2]));
                    strategy.setCropSize(Integer.parseInt(results[3]));
                }
                onAvatarIdChanged(results[0], strategy.getEntityType() == EntityType.PERSON);
            }
        }
    });

    if (editButton != null) {
        editButton.addClickHandler(new ClickHandler() {
            public void onClick(final ClickEvent inArg0) {
                // Since the size of the image is required before we can correctly show the
                // resize dialog, this method determines the avatar url and sets image url.
                // The load event of that image being loaded will kick off the resize modal.
                AvatarUrlGenerator urlGenerator = new AvatarUrlGenerator(EntityType.PERSON);
                hiddenImage.setUrl(urlGenerator.getOriginalAvatarUrl(avatarId));
            }
        });
        hiddenImage.addLoadHandler(new LoadHandler() {
            public void onLoad(final LoadEvent inEvent) {
                imageCropDialog = new ImageCropContent(strategy, processor, avatarId, new Command() {
                    public void execute() {
                        onAvatarIdChanged(strategy.getImageId(), strategy.getEntityType() == EntityType.PERSON);
                    }
                }, hiddenImage.getWidth() + "px", hiddenImage.getHeight() + "px");

                Dialog dialog = new Dialog(imageCropDialog);
                dialog.showCentered();
            }
        });
    }

    if (strategy.getImageType().equals(ImageType.BANNER)) {
        onAvatarIdChanged(strategy.getImageId(), strategy.getId().equals(strategy.getImageEntityId()), true,
                strategy.getEntityType() == EntityType.PERSON);
    } else {
        onAvatarIdChanged(strategy.getImageId(), strategy.getEntityType() == EntityType.PERSON);
    }

    deleteButton.addClickHandler(new ClickHandler() {
        @SuppressWarnings("unchecked")
        public void onClick(final ClickEvent event) {
            if (new WidgetJSNIFacadeImpl().confirm("Are you sure you want to delete your current photo?")) {
                strategy.getDeleteAction().delete(strategy.getDeleteParam());
            }
        }
    });

    Session.getInstance().getEventBus().addObserver(ClearUploadedImageEvent.class,
            new Observer<ClearUploadedImageEvent>() {
                public void update(final ClearUploadedImageEvent event) {
                    if (event.getImageType().equals(strategy.getImageType())
                            && event.getEntityType().equals(strategy.getEntityType())) {
                        if (event.getImageType().equals(ImageType.BANNER)) {
                            onAvatarIdChanged(event.getEntity().getBannerId(),
                                    strategy.getId().equals(event.getEntity().getBannerEntityId()), true,
                                    strategy.getEntityType() == EntityType.PERSON);
                        } else {
                            onAvatarIdChanged(null, strategy.getEntityType() == EntityType.PERSON);
                        }
                    }
                }
            });

}

From source file:org.footware.client.dialogs.UploadTrackBox.java

License:Apache License

public UploadTrackBox() {
    setText("Upload a Track");

    Grid g = new Grid(7, 2);

    setAutoHideEnabled(true);//from   w  w  w. j  a v  a 2 s  . c  om
    setGlassEnabled(true);

    //      trackName = new TextBox();
    //      trackName.setName(NAME);
    //      g.setWidget(0, 0, new HTML("Name"));
    //      g.setWidget(0, 1, trackName);

    privacy = new ListBox();
    privacy.setName(PRIVACY);
    privacy.addItem("Public", PRIVACY_PUBLIC);
    privacy.addItem("Private", PRIVACY_PRIVATE);
    g.setWidget(1, 0, new HTML("Privacy"));
    g.setWidget(1, 1, privacy);

    enableComments = new CheckBox();
    enableComments.setName(COMMENTS);
    g.setWidget(2, 0, new HTML("Enable comments"));
    g.setWidget(2, 1, enableComments);

    notes = new TextArea();
    notes.setName(NOTES);
    notes.setSize("200px", "50px");
    g.setWidget(3, 0, new HTML("Notes"));
    g.setWidget(3, 1, notes);

    email = new TextBox();
    email.setVisible(false);

    g.setWidget(6, 0, email);

    file = new FileUpload();
    file.setName(FILE);
    g.setWidget(4, 0, new HTML("Select File"));
    g.setWidget(4, 1, file);

    Button upload = new Button("Upload");
    upload.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            doUpload();
            hide();
        }

    });

    Button close = new Button("Cancel");
    close.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            hide();
        }
    });

    g.setWidget(5, 0, upload);
    g.setWidget(5, 1, close);

    form = new FormPanel();
    // TODO implement httpservlet to accept file.
    form.setAction("/footware/trackUpload");
    form.setEncoding(FormPanel.ENCODING_MULTIPART);
    form.setMethod(FormPanel.METHOD_POST);
    form.add(g);

    add(form);
}