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:burrito.client.widgets.blobstore.BlobStoreUploader.java

License:Apache License

public BlobStoreUploader(Integer requiredWidth, Integer requiredHeight, final AsyncCallback<String> callback) {
    FlowPanel inner = new FlowPanel();
    inner.add(file);//from w ww  .  j a va2  s. c  o  m
    file.setName("file");
    file.addChangeHandler(new ChangeHandler() {

        @Override
        public void onChange(ChangeEvent event) {
            getUploadURLAndPost();
        }
    });
    form.setEncoding(FormPanel.ENCODING_MULTIPART);
    form.setMethod(FormPanel.METHOD_POST);
    if (requiredWidth != null) {
        inner.add(new Hidden("width", String.valueOf(requiredWidth)));
    }
    if (requiredHeight != null) {
        inner.add(new Hidden("height", String.valueOf(requiredHeight)));
    }
    form.addSubmitHandler(new SubmitHandler() {

        @Override
        public void onSubmit(SubmitEvent event) {
            file.setVisible(false);
            progress.setVisible(true);
        }
    });

    form.addSubmitCompleteHandler(new SubmitCompleteHandler() {

        @Override
        public void onSubmitComplete(SubmitCompleteEvent event) {
            file.setVisible(true);
            progress.setVisible(false);
            String results = event.getResults().replaceAll("<.*?>", ""); // sometime, <pre> tags are added by the browser
            if (results.contains("OK#")) {
                String blobStoreKey = results.replace("OK#", "");
                callback.onSuccess(blobStoreKey);
            } else {
                Window.alert(results);
                callback.onFailure(new RuntimeException("Failure response from server"));
            }
        }
    });
    progress.setVisible(false);
    inner.add(progress);

    form.add(inner);
    initWidget(form);
}

From source file:cc.alcina.framework.gwt.client.util.ClientUtils.java

License:Apache License

public static void submitForm(Map<String, String> params, String url) {
    FormPanel p = new FormPanel("_self");
    p.setAction(url);//ww  w .ja v a  2  s  .c  o  m
    p.setMethod(FormPanel.METHOD_POST);
    FlowPanel fp = new FlowPanel();
    p.add(fp);
    for (String key : params.keySet()) {
        addHidden(fp, key, params.get(key));
    }
    RootPanel.get().add(p);
    p.submit();
    p.removeFromParent();
}

From source file:com.anritsu.mcreleaseportal.client.UploadFile.java

public UploadFile() {
    initWidget(uiBinder.createAndBindUi(this));
    getService().enableChangesXMLUpload(enableChangesXMLUploadCallback);
    serviceDescription.setIcon(IconType.INFO_CIRCLE);
    serviceDescription.addClickHandler(new ClickHandler() {
        @Override/*from  w w  w  .  jav  a2  s.c  om*/
        public void onClick(ClickEvent event) {
            getService().getSchemaLink(getSchemaLinkCallback);
            serviceDescriptionModal.show();
        }
    });

    confirmMCPackageInfoUpdate.addHideHandler(new ModalHideHandler() {
        public void onHide(ModalHideEvent evt) {
            loadingGif.setVisible(false);
            hPanel.setVisible(true);
            mcPackageInfoPanel.setVisible(true);
            mcPackageDependencyInfo.setVisible(true);
        }
    });

    selectFile.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            mcPackageInfoPanel.setVisible(false);
            mcPackageDependencyInfo.setVisible(false);
            submitFileUpload.setEnabled(false);
            fileUpload.click();
        }
    });

    fileUpload.addChangeHandler(new ChangeHandler() {
        @Override
        public void onChange(ChangeEvent event) {
            if (fileUpload.getFilename().contains("xml")) {
                fileUploadFormPanel.setEncoding(FormPanel.ENCODING_MULTIPART);
                fileUploadFormPanel.setMethod(FormPanel.METHOD_POST);
                fileUploadFormPanel.setAction(GWT.getModuleBaseURL() + "fileupload");
                fileUploadFormPanel.submit();
                hPanel.setVisible(false);
                loadingGif.setVisible(true);
            } else {
                Notify.notify("", "Wrong file type selected!", IconType.THUMBS_DOWN, NotifyType.INFO);
            }
        }
    });

    fileUploadFormPanel.addSubmitCompleteHandler(new FormPanel.SubmitCompleteHandler() {
        @Override
        public void onSubmitComplete(FormPanel.SubmitCompleteEvent event) {
            fileUploadFormPanel.reset();

            hPanel.setVisible(true);
            loadingGif.setVisible(false);
            getService().validateChangesXML(validateChangesXMLAsyncCallback);

        }
    });

    submitFileUpload.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            hPanel.setVisible(false);
            loadingGif.setVisible(true);
            mcPackageInfoPanel.setVisible(false);
            mcPackageDependencyInfo.setVisible(false);
            getService().isMCPackagePresentInDB(isMCPackagePresentInDBCallback);

        }
    });

    updateMCPackageInfo.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            updateMCPackageInfo.setText("Inserting data to DB...");
            closeOverwriteConfirmation.setVisible(false);
            updateMCPackageInfo.setEnabled(false);

            getService().addMCPackageToDB(addMCPackageToDBCallback);
        }
    });
}

From source file:com.apress.progwt.client.college.gui.LoginWindow.java

License:Apache License

private void setupForm() {
    form = new FormPanel();

    form.setAction(Interactive.getRelativeURL(SECURITY_URL));

    form.setMethod(FormPanel.METHOD_POST);

    // Create a panel to hold all of the form widgets.

    VerticalPanel panel = new VerticalPanel();

    DecoratedTabPanel tabs = new DecoratedTabPanel();
    tabs.add(getOpenIDTab(), "OpenID");
    tabs.add(getUPTab(), "Username/Password");
    tabs.selectTab(1);/*from w w  w. ja  va  2  s .co m*/

    panel.add(tabs);

    messageLabel = new Label("");
    panel.add(messageLabel);

    form.addFormHandler(new FormHandler() {

        // note, this doesn't need to be perfectly secure. We just
        // want to know that we think we're secure. The next request
        // will tell us for sure
        public void onSubmitComplete(FormSubmitCompleteEvent event) {

            Log.debug("submit event results " + event.getResults());
            if (event.getResults().equals("OK")) {
                success();
            } else {
                Log.warn("Login Fail: " + event.getResults());
                failure();
            }

            // // TODO parse bad password etc. Super-Fragile string
            // comps
            // if (event.getResults() == null
            // || -1 != event.getResults().indexOf(
            // "not successful")
            // || -1 != event.getResults().indexOf(
            // "Bad credentials")
            // || -1 != event.getResults().indexOf("404")) {
            // Log.warn("Login Fail: " + event.getResults());
            // failure();
            // } else {
            // Log.info("Login Success");
            // Log.debug(event.getResults());
            // success();
            // }

        }

        public void onSubmit(FormSubmitEvent event) {
            Log.debug("submit to " + form.getAction());

            // This event is fired just before the form is submitted.
            // We can take
            // this opportunity to perform validation.
            // if (username.getText().length() == 0) {
            // AlertDialog.alert("Username cannot be empty");
            // event.setCancelled(true);
            // }
            // if (password.getText().length() == 0) {
            // AlertDialog.alert("Password cannot be empty");
            // event.setCancelled(true);
            // }
            lastNameEntered = username.getText();
        }
    });

    form.setWidget(panel);

}

From source file:com.audata.client.checkout.CheckinDialog.java

License:Open Source License

public CheckinDialog(String uuid, String name) {
    this.uuid = uuid;
    this.name = name;
    this.setText(LANG.check_in_msg_Text() + ": " + this.name);

    VerticalPanel main = new VerticalPanel();
    main.setSize("100%", "100%");
    main.setSpacing(3);/*from w  w w  .  ja  v  a 2s . c om*/
    main.setHorizontalAlignment(HasAlignment.ALIGN_LEFT);

    this.undo = new RadioButton("ActionGroup", LANG.check_in_Text());
    this.checkin = new RadioButton("ActionGroup", LANG.check_in_version_Text());
    this.undo.setChecked(true);
    this.undo.addClickListener(this);
    this.checkin.addClickListener(this);
    main.add(this.undo);
    main.add(this.checkin);

    this.upload = new UploadPanel();
    String url = AuDoc.jsonCall.getURL();
    this.upload.setAction(url + "docIO.php");
    this.upload.setEncoding(FormPanel.ENCODING_MULTIPART);
    this.upload.setMethod(FormPanel.METHOD_POST);
    this.upload.setVisible(false);
    main.add(upload);

    HorizontalPanel buttons = new HorizontalPanel();
    buttons.setSpacing(3);
    this.ok = new Button(LANG.ok_Text());
    this.ok.addClickListener(this);
    buttons.add(this.ok);
    this.cancel = new Button(LANG.cancel_Text());
    this.cancel.addClickListener(this);
    buttons.add(this.cancel);
    main.add(buttons);
    main.setCellHorizontalAlignment(buttons, HasAlignment.ALIGN_RIGHT);

    this.setWidget(main);
}

From source file:com.audata.client.newRecord.Metadata.java

License:Open Source License

public void onShow(Wizard parent) {
    this.upload = new UploadPanel();
    String url = AuDoc.jsonCall.getURL();
    this.upload.setAction(url + "docIO.php");
    this.upload.setEncoding(FormPanel.ENCODING_MULTIPART);
    this.upload.setMethod(FormPanel.METHOD_POST);

    this.fields.clear();
    this.addFields();
    HashMap v = parent.getValues();
    ArrayList a = (ArrayList) v.get("udfields");
    this.rTypeName = (String) v.get("typename");
    this.fields.addAll(a);
    this.paintFields();
}

From source file:com.audata.client.record.RecordProperties.java

License:Open Source License

public RecordProperties(RecordPropertiesDialog parent, String cot) {

    this.parent = parent;
    this.cot = cot;

    this.main = new VerticalPanel();
    this.main.setSpacing(3);
    this.title = new Label(LANG.record_props_Text());
    this.title.addStyleName("audoc-subsection");

    //prepare upload panel
    this.upload = new UploadPanel();
    String url = AuDoc.jsonCall.getURL();
    this.upload.setAction(url + "docIO.php");
    this.upload.setEncoding(FormPanel.ENCODING_MULTIPART);
    this.upload.setMethod(FormPanel.METHOD_POST);

    //load default fields
    this.initWidget(this.main);
}

From source file:com.brainz.wokhei.client.home.OrderBrowserModulePart.java

private void setupPayPalForm() {
    boolean isSandbox = getModule().isSandBox();
    //fill-up paypal form
    if (isSandbox) {
        _paypalForm.setAction(PayPalStrings.PAYPAL_SANDBOX_ACTION.getString());
    } else {//from  ww w  .j  a v  a 2 s. co  m
        _paypalForm.setAction(PayPalStrings.PAYPAL_ACTION.getString());
    }

    // _paypalForm.setEncoding(FormPanel.ENCODING_MULTIPART);
    _paypalForm.setMethod(FormPanel.METHOD_POST);

    VerticalPanel formPlaceHolder = new VerticalPanel();

    //setup input element for seller
    Hidden sellerInfo = new Hidden();

    sellerInfo.setName(PayPalStrings.PAYPAL_BUSINESS_NAME.getString());

    if (isSandbox) {
        sellerInfo.setValue(PayPalStrings.PAYPAL_SANDBOX_BUSINESS_VALUE.getString());
    } else {
        sellerInfo.setValue(PayPalStrings.PAYPAL_BUSINESS_VALUE.getString());
    }

    formPlaceHolder.add(sellerInfo);
    //specify buy now button
    Hidden cmdInfo = new Hidden();

    cmdInfo.setName(PayPalStrings.PAYPAL_CMD_NAME.getString());

    cmdInfo.setValue(PayPalStrings.PAYPAL_CMD_VALUE.getString());

    formPlaceHolder.add(cmdInfo);
    //specify purchase details
    Hidden itemNameInfo = new Hidden();
    Hidden amountInfo = new Hidden();
    Hidden taxInfo = new Hidden();
    Hidden currencyInfo = new Hidden();
    Hidden notifyInfo = new Hidden();
    Hidden returnInfo = new Hidden();
    Hidden custom = new Hidden();
    Hidden locale = new Hidden();

    //valuToPay sara il lordo(gross) da pagare
    Float valueToPay = TransactionType.BUYING_LOGO.getGrossToPay(_currentOrder.getTotalPaidTips());

    itemNameInfo.setName(PayPalStrings.PAYPAL_ITEMNAME_NAME.getString());
    itemNameInfo.setValue(TransactionType.BUYING_LOGO.getDescription());
    formPlaceHolder.add(itemNameInfo);

    amountInfo.setName(PayPalStrings.PAYPAL_AMOUNT_NAME.getString());
    amountInfo.setValue(TransactionType.BUYING_LOGO.getNet(valueToPay).toString());
    formPlaceHolder.add(amountInfo);

    taxInfo.setName(PayPalStrings.PAYPAL_TAX_NAME.getString());
    taxInfo.setValue(TransactionType.BUYING_LOGO.getTax(valueToPay).toString());
    formPlaceHolder.add(taxInfo);

    currencyInfo.setName(PayPalStrings.PAYPAL_CURRENCY_NAME.getString());
    currencyInfo.setValue(PayPalStrings.PAYPAL_CURRENCY_VALUE.getString());
    formPlaceHolder.add(currencyInfo);

    notifyInfo.setName(PayPalStrings.PAYPAL_NOTIFY_URL_NAME.getString());
    if (isSandbox) {
        notifyInfo.setValue(PayPalStrings.PAYPAL_NOTIFY_URL_SANDBOX_VALUE.getString());
    } else {
        notifyInfo.setValue(PayPalStrings.PAYPAL_NOTIFY_URL_VALUE.getString());

    }
    formPlaceHolder.add(notifyInfo);

    returnInfo.setName(PayPalStrings.PAYPAL_RETURN_NAME.getString());
    returnInfo.setValue(PayPalStrings.PAYPAL_RETURN_VALUE.getString());

    custom.setName(PayPalStrings.PAYPAL_CUSTOM_NAME.getString());
    custom.setValue(_currentOrder.getId().toString() + ";" + TransactionType.BUYING_LOGO.toString());
    formPlaceHolder.add(custom);

    locale.setName(PayPalStrings.PAYPAL_LOCALE_NAME.getString());
    locale.setValue(PayPalStrings.PAYPAL_LOCALE_NAME.getString());
    formPlaceHolder.add(locale);

    formPlaceHolder.add(_buyNowImage);

    _paypalForm.add(formPlaceHolder);

    _paypalForm.addSubmitCompleteHandler(new SubmitCompleteHandler() {

        public void onSubmitComplete(SubmitCompleteEvent event) {
            //nothing to handle? whoo-yeah! AVP sucks dick
        }
    });

}

From source file:com.codenvy.ide.client.wizard.project.imports.ImportFileViewImpl.java

License:Apache License

/** {@inheritDoc} */
@Override/*from   ww  w  . jav a 2 s .c  om*/
public void showDialog() {
    uploadForm.setEncoding(FormPanel.ENCODING_MULTIPART);
    uploadForm.setMethod(FormPanel.METHOD_POST);

    VerticalPanel panel = new VerticalPanel();
    uploadForm.setWidget(panel);

    file = new FileUpload();
    file.setName("ImportFile");
    file.setHeight("26px");
    file.setWidth("100%");
    file.addChangeHandler(new ChangeHandler() {
        @Override
        public void onChange(ChangeEvent changeEvent) {
            if (!file.getFilename().endsWith(".dbs")) {
                delegate.onFileNameChangedWithInvalidFormat();
            } else {
                delegate.onFileNameChanged();
            }
        }
    });
    panel.add(file);
    this.center();
    this.show();
}

From source file:com.dawg6.web.dhcalc.client.SavePanel.java

License:Open Source License

public SavePanel() {

    CaptionPanel captionPanel = new CaptionPanel("Save/Load");
    initWidget(captionPanel);/*w  w  w  . ja  va  2  s. co  m*/

    FlexTable flexTable_3 = new FlexTable();
    flexTable_3.setCellPadding(2);
    captionPanel.setContentWidget(flexTable_3);

    tabPanel = new TabPanel();
    flexTable_3.setWidget(0, 0, tabPanel);

    browserPanel = new FlexTable();
    browserPanel.setCellPadding(2);

    if (Storage.isLocalStorageSupported()) {
        tabPanel.add(browserPanel, "Browser Storage", false);
    }

    storageList = new ListBox();
    browserPanel.setWidget(0, 0, storageList);
    storageList.setWidth("100%");
    storageList.setVisibleItemCount(5);

    nameField = new TextBox();
    nameField.setVisibleLength(30);
    nameField.setText("Enter a Name");
    browserPanel.setWidget(1, 0, nameField);

    Button btnNewButton = new Button("New button");
    browserPanel.setWidget(1, 1, btnNewButton);
    btnNewButton.setText("Add");

    btnNewButton.addClickHandler(new ClickHandler() {

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

    HorizontalPanel horizontalPanel = new HorizontalPanel();
    horizontalPanel.setSpacing(5);
    horizontalPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    browserPanel.setWidget(2, 0, horizontalPanel);

    Button button_6 = new Button("New button");
    button_6.setText("Save");
    horizontalPanel.add(button_6);

    button_6.addClickHandler(new ClickHandler() {

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

    Button button_5 = new Button("New button");
    horizontalPanel.add(button_5);
    button_5.setText("Restore");

    button_5.addClickHandler(new ClickHandler() {

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

    Button button_2 = new Button("New button");
    horizontalPanel.add(button_2);
    button_2.setText("Delete");

    button_2.addClickHandler(new ClickHandler() {

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

    Button btnNewButton_1 = new Button("New button");
    horizontalPanel.add(btnNewButton_1);
    btnNewButton_1.setText("Rename");

    btnNewButton_1.addClickHandler(new ClickHandler() {

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

    browserPanel.getFlexCellFormatter().setColSpan(0, 0, 1);
    browserPanel.getFlexCellFormatter().setColSpan(2, 0, 1);
    browserPanel.getFlexCellFormatter().setColSpan(0, 0, 2);
    browserPanel.getFlexCellFormatter().setColSpan(2, 0, 2);
    browserPanel.getCellFormatter().setHorizontalAlignment(2, 0, HasHorizontalAlignment.ALIGN_CENTER);

    filePanel = new FlexTable();
    filePanel.setCellPadding(2);
    tabPanel.add(filePanel, "Local File", false);

    HorizontalPanel horizontalPanel_1 = new HorizontalPanel();
    filePanel.setWidget(0, 0, horizontalPanel_1);

    loadPanel = new FormPanel();
    loadPanel.setMethod(FormPanel.METHOD_POST);
    loadPanel.setEncoding(FormPanel.ENCODING_MULTIPART);
    loadPanel.setAction("loadData");
    horizontalPanel_1.add(loadPanel);

    HorizontalPanel horizontalPanel_2 = new HorizontalPanel();
    loadPanel.setWidget(horizontalPanel_2);
    horizontalPanel_2.setSize("100%", "100%");

    fileUpload = new FileUpload();
    fileUpload.setName("file");
    horizontalPanel_2.add(fileUpload);

    clientKey = new Hidden("client");
    horizontalPanel_2.add(clientKey);
    filePanel.getFlexCellFormatter().setColSpan(0, 0, 1);

    Button button = new Button("Save Data...");
    filePanel.setWidget(1, 0, button);
    button.setText("Save File");

    Button button_1 = new Button("Load Data...");
    filePanel.setWidget(1, 1, button_1);
    button_1.setText("Load File");
    filePanel.getFlexCellFormatter().setColSpan(0, 0, 2);
    filePanel.getCellFormatter().setHorizontalAlignment(1, 0, HasHorizontalAlignment.ALIGN_CENTER);
    filePanel.getCellFormatter().setHorizontalAlignment(1, 1, HasHorizontalAlignment.ALIGN_CENTER);

    button_1.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            loadFile();

        }
    });

    button.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            saveFile();

        }
    });

    textPanel = new FlexTable();
    textPanel.setCellPadding(2);
    tabPanel.add(textPanel, "Copy/Paste", false);

    textArea = new TextArea();
    textArea.setText(
            "Paste previously saved form data here and click \"Restore.\" Or press \"Current\" to paste current Form data.");
    textArea.setVisibleLines(5);
    textPanel.setWidget(0, 0, textArea);
    textArea.setSize("100%", "");

    Button button_3 = new Button("Save Data...");
    button_3.setText("Current");
    textPanel.setWidget(1, 0, button_3);

    textArea.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            textArea.selectAll();
        }
    });

    nameField.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            nameField.selectAll();
        }
    });

    button_3.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {

            if (listener != null) {

                FormData data = listener.getFormData();

                JSONObject obj = JsonUtil.toJSONObject(data);
                textArea.setText(JsonUtil.formatJsonText(obj.toString()));
                textArea.selectAll();
            }

        }
    });

    Button button_4 = new Button("Load Data...");
    button_4.setText("Restore");

    button_4.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            if (listener != null) {
                String text = textArea.getText();

                FormData data = JsonUtil.parseFormData(text);

                listener.setFormData(data);
                textArea.setText("");
            }

        }
    });

    textPanel.setWidget(1, 1, button_4);
    textPanel.getFlexCellFormatter().setColSpan(0, 0, 2);
    textPanel.getCellFormatter().setHorizontalAlignment(1, 0, HasHorizontalAlignment.ALIGN_CENTER);
    textPanel.getCellFormatter().setHorizontalAlignment(1, 1, HasHorizontalAlignment.ALIGN_CENTER);

    flexTable_3.getFlexCellFormatter().setColSpan(0, 0, 1);

    storageList.addChangeHandler(new ChangeHandler() {

        @Override
        public void onChange(ChangeEvent event) {
            int i = storageList.getSelectedIndex();

            if (i >= 0) {
                String name = storageList.getItemText(i);

                if (name != null)
                    nameField.setText(name);
            }

        }
    });
}