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.utgenome.gwt.utgb.client.track.lib.NavigatorTrack.java

License:Apache License

public NavigatorTrack() {
    super("NavigatorTrack");
    panel.setStyleName("toolbox");
    panel.setWidth("100%");

    speciesBox.addChangeHandler(new PropertyChangeHandler(UTGBProperty.SPECIES, speciesBox));
    revisionBox.addChangeHandler(new PropertyChangeHandler(UTGBProperty.REVISION, revisionBox));
    regionBox.addKeyUpHandler(new SequenceRangeChangeListner());
    targetBox.addKeyUpHandler(new KeyUpHandler() {
        public void onKeyUp(KeyUpEvent e) {
            int keyCode = e.getNativeKeyCode();
            if (keyCode == KeyCodes.KEY_ENTER || keyCode == KeyCodes.KEY_TAB) {
                getTrackGroup().getPropertyWriter().setProperty(UTGBProperty.TARGET, targetBox.getText());
            }//from   ww w . j a v  a 2s.  c  om
        }
    });
    targetBox.setWidth("100px");
    // value selectors
    hp.setVerticalAlignment(HorizontalPanel.ALIGN_MIDDLE);
    hp.add(new FormLabel("Species"));
    hp.add(speciesBox);
    hp.add(new FormLabel("Ref."));
    hp.add(revisionBox);
    hp.add(new FormLabel("Chr."));
    hp.add(targetBox);
    // window locator
    regionBox.setWidth("160px");

    hp2.setVerticalAlignment(HorizontalPanel.ALIGN_MIDDLE);
    hp2.add(new FormLabel("Region"));
    hp2.add(regionBox);

    Button strandSwitch = new Button("reverse");
    Style.margin(strandSwitch, Style.LEFT, 2);
    Style.border(strandSwitch, 2, Style.BORDER_OUTSET, "white");
    strandSwitch.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent e) {
            isPlusStrand = !isPlusStrand;
            TrackWindow window = getTrackGroup().getTrackWindow();
            if (isPlusStrand) {
                getTrackGroup().setTrackWindowLocation(window.getEndOnGenome(), window.getStartOnGenome());
            } else {
                getTrackGroup().setTrackWindowLocation(window.getEndOnGenome(), window.getStartOnGenome());
            }
        }
    });
    // TODO reverse button
    //hp2.add(strandSwitch);
    hp2.add(new ScrollButtonSet());
    // save view
    final FormPanel saveViewForm = new FormPanel();
    saveViewForm.setAction(GWT.getModuleBaseURL() + "utgb-core/EchoBackView");
    saveViewForm.setEncoding(FormPanel.ENCODING_URLENCODED);
    saveViewForm.setMethod(FormPanel.METHOD_POST);
    final Hidden viewData = new Hidden("view");
    final Hidden time = new Hidden("time");
    final Button saveButton = new Button("save view");
    HorizontalPanel formLayout = new HorizontalPanel();
    formLayout.setVerticalAlignment(HorizontalPanel.ALIGN_MIDDLE);
    viewData.setVisible(false);
    formLayout.add(viewData);
    formLayout.add(time);
    formLayout.add(saveButton);
    saveButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent e) {
            XMLWriter xmlWriter = new XMLWriter();
            getTrackGroup().toXML(xmlWriter);
            String view = xmlWriter.toString();
            viewData.setValue(view);
            // send the time stamp
            Date today = new Date();
            time.setValue(Long.toString(today.getTime()));
            saveViewForm.submit();
        }
    });
    saveViewForm.add(formLayout);
    DOM.setStyleAttribute(saveViewForm.getElement(), "margin", "0");
    hp.add(saveViewForm);
    Button loadButton = new Button("load view");
    loadButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent e) {
            getTrackGroup().insertTrack(new ViewLoaderTrack(), getTrackGroup().getTrackIndex(_self) + 1);
        }
    });
    hp.add(loadButton);

}

From source file:org.utgenome.gwt.utgb.client.track.lib.ViewLoaderTrack.java

License:Apache License

public ViewLoaderTrack() {
    super("View Loader");
    // load view via HTTP
    HorizontalPanel hp = new HorizontalPanel();
    hp.setVerticalAlignment(HorizontalPanel.ALIGN_MIDDLE);
    hp.add(new FormLabel("View Silk URL: "));
    urlBox.setWidth("400px");
    urlBox.addKeyPressHandler(new KeyPressHandler() {
        public void onKeyPress(KeyPressEvent e) {
            if (e.getCharCode() == KeyCodes.KEY_ENTER) {
                downloadView(urlBox.getText());
            }/* www. java  2s.  c o m*/
        }
    });
    Button loadButton = new Button("load");
    loadButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent e) {
            downloadView(urlBox.getText());
        }
    });
    hp.add(urlBox);
    hp.add(loadButton);
    // load view from a file
    final FormPanel fileUploadForm = new FormPanel();
    fileUploadForm.setAction(GWT.getModuleBaseURL() + "utgb-core/loadview");
    fileUploadForm.setEncoding(FormPanel.ENCODING_MULTIPART);
    fileUploadForm.setMethod(FormPanel.METHOD_POST);
    HorizontalPanel formButtonPanel = new HorizontalPanel();
    FileUpload fileBox = new FileUpload();
    fileBox.setName("file");
    fileBox.setWidth("300px");
    Button uploadButton = new Button("submit");
    uploadButton.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent e) {
            fileUploadForm.submit();
        }
    });
    formButtonPanel.add(new FormLabel("View Silk File:"));
    formButtonPanel.add(fileBox);
    formButtonPanel.add(uploadButton);
    fileUploadForm.add(formButtonPanel);
    DOM.setStyleAttribute(fileUploadForm.getElement(), "margin", "0");
    fileUploadForm.addSubmitCompleteHandler(new SubmitCompleteHandler() {
        public void onSubmitComplete(SubmitCompleteEvent e) {

            getFrame().setNowLoading();
            String viewXML = extractEmbeddedSilkInComment(e.getResults());
            setViewSilk(viewXML);
        }
    });
    // set panes
    panel.setStyleName("toolbox");
    panel.add(hp);
    panel.add(fileUploadForm);
}

From source file:org.vectomatic.client.rep.controller.ExportController.java

License:Open Source License

public ExportController(RepApplication app, FormPanel form) {
    super(app);/* www  .  ja  v a2 s .com*/
    _form = form;
    form.setMethod(FormPanel.METHOD_POST);
    Element svgexport = DOM.getElementById("svgexport");
    String uri = "";
    if (svgexport != null) {
        uri = svgexport.getAttribute("content");
    }

    form.setAction(uri);
    _hidden = new Hidden();
    _hidden.setName("data");
    form.add(_hidden);
    _exportSVG11MenuItem = new ControllerMenuItem(app.getView(), app.getConstants().exportSVG11Command(),
            new ControllerBase(_app) {
                @Override
                public void activate(DrawingView view) {
                    export(new SVG11Visitor());
                }
            });
    _exportSVG12MenuItem = new ControllerMenuItem(app.getView(), app.getConstants().exportSVG12Command(),
            new ControllerBase(_app) {
                @Override
                public void activate(DrawingView view) {
                    export(new SVG12Visitor());
                }
            });
}

From source file:org.waveprotocol.wave.client.wavepanel.impl.toolbar.attachment.AttachmentPopupWidget.java

License:Apache License

/**
 * Creates link info popup./*from   w  ww  .  ja  v a 2s  .  c o m*/
 */
public AttachmentPopupWidget() {
    initWidget(BINDER.createAndBindUi(this));
    // Because we're going to add a FileUpload widget, we'll need to set the
    // form to use the POST method, and multipart MIME encoding.
    form.setEncoding(FormPanel.ENCODING_MULTIPART);
    form.setMethod(FormPanel.METHOD_POST);

    // Add an event handler to the form.
    form.addSubmitHandler(new FormPanel.SubmitHandler() {
        @Override
        public void onSubmit(SubmitEvent event) {
            // No implementation.
        }
    });

    form.addSubmitCompleteHandler(new FormPanel.SubmitCompleteHandler() {
        @Override
        public void onSubmitComplete(SubmitCompleteEvent event) {
            // When the form submission is successfully completed, this
            // event is fired. Assuming the service returned a response of type
            // text/html, we can get the result text here (see the FormPanel
            // documentation for further explanation).
            spinnerImg.setVisible(false);
            String results = event.getResults();
            if (results != null && results.contains("OK")) {
                status.setText("Done!");
                status.addStyleName(style.done());
                listener.onDone(waveRefStr, attachmentId.getId(), fileUpload.getFilename());
                hide();
            } else {
                status.setText("Error!");
                status.addStyleName(style.error());
            }
        }
    });

    uploadBtn.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            String filename = fileUpload.getFilename();
            if (filename.length() == 0) {
                Window.alert("No file to upload!");
            } else {
                spinnerPanel.setVisible(true);
                formAttachmentId.setValue(attachmentId.getId());
                formWaveRef.setValue(waveRefStr);
                form.submit();
            }
        }
    });

    // Wrap in a popup.
    PopupChrome chrome = PopupChromeFactory.createPopupChrome();
    popup = PopupFactory.createPopup(null, new CenterPopupPositioner(), chrome, true);
    popup.add(this);
    popup.addPopupEventListener(this);
}

From source file:org.wte4j.ui.client.templates.upload.TemplateUploadFormPanel.java

License:Apache License

private void setMetaData() {
    formPanel.setAction(templateUploadRestURL);
    formPanel.setEncoding(FormPanel.ENCODING_MULTIPART);
    formPanel.setMethod(FormPanel.METHOD_POST);
}

From source file:org.xwiki.gwt.wysiwyg.client.widget.wizard.util.AbstractFileUploadWizardStep.java

License:Open Source License

/**
 * Creates a new file upload wizard step that uses the given service to get information about the uploaded files.
 * /*  ww  w  .j  a va  2 s . co  m*/
 * @param wikiService the service used to access the uploaded attachments
 */
public AbstractFileUploadWizardStep(WikiServiceAsync wikiService) {
    this.wikiService = wikiService;

    setStepTitle(Strings.INSTANCE.fileUploadTitle());

    display().addStyleName("xUploadPanel");
    fileUploadForm.setEncoding(FormPanel.ENCODING_MULTIPART);
    fileUploadForm.setMethod(FormPanel.METHOD_POST);
    // set the url on submit time, just before upload

    Panel fileLabel = new FlowPanel();
    fileLabel.setStyleName("xInfoLabel");
    fileLabel.add(new InlineLabel(getFileLabel()));
    InlineLabel mandatoryLabel = new InlineLabel(Strings.INSTANCE.mandatory());
    mandatoryLabel.addStyleName("xMandatory");
    fileLabel.add(mandatoryLabel);
    fileUploadInput.setName(getFileUploadInputName());
    FlowPanel formPanel = new FlowPanel();

    formPanel.add(fileLabel);
    fileHelpLabel.setStyleName("xHelpLabel");
    fileHelpLabel.setVisible(false);
    formPanel.add(fileHelpLabel);

    fileErrorLabel.addStyleName("xErrorMsg");
    fileErrorLabel.setVisible(false);

    formPanel.add(fileErrorLabel);
    formPanel.add(fileUploadInput);

    fileUploadForm.setWidget(formPanel);

    display().add(fileUploadForm);
}

From source file:stroom.importexport.client.presenter.ImportConfigPresenter.java

License:Apache License

@Inject
public ImportConfigPresenter(final EventBus eventBus, final ImportConfigView view, final ImportProxy proxy,
        final ClientDispatchAsync dispatcher) {
    super(eventBus, view, proxy);
    this.dispatcher = dispatcher;

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

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/*from  ww  w  .j a  v  a 2s. co m*/
        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  .  ja va  2s  .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");
}