Search in sources :

Example 1 with FormSubmitEvent

use of com.google.gwt.user.client.ui.FormSubmitEvent in project data-access by pentaho.

the class UploadFileEntryPoint method onModuleLoad.

public void onModuleLoad() {
    // Create a FormPanel and point it at a service.
    final FormPanel uploadForm = new FormPanel();
    uploadForm.setAction(GWT.getModuleBaseURL() + "/UploadService");
    // 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.
    uploadForm.setEncoding(FormPanel.ENCODING_MULTIPART);
    uploadForm.setMethod(FormPanel.METHOD_POST);
    // Create a panel to hold all of the form widgets.
    VerticalPanel panel = new VerticalPanel();
    uploadForm.setWidget(panel);
    // Create a TextBox, giving it a name so that it will be submitted.
    final TextBox tb = new TextBox();
    tb.setName("textBoxFormElement");
    panel.add(tb);
    // Create a FileUpload widget.
    FileUpload upload = new FileUpload();
    upload.setName("uploadFormElement");
    panel.add(upload);
    // Add a 'Upload' button.
    Button uploadSubmitButton = new Button("Upload");
    panel.add(uploadSubmitButton);
    uploadSubmitButton.addClickListener(new ClickListener() {

        public void onClick(Widget sender) {
            uploadForm.submit();
        }
    });
    uploadForm.addFormHandler(new FormHandler() {

        public void onSubmit(FormSubmitEvent event) {
        }

        public void onSubmitComplete(FormSubmitCompleteEvent event) {
            Window.alert(event.getResults());
        }
    });
    RootPanel.get().add(uploadForm);
}
Also used : FormSubmitCompleteEvent(com.google.gwt.user.client.ui.FormSubmitCompleteEvent) VerticalPanel(com.google.gwt.user.client.ui.VerticalPanel) FormPanel(com.google.gwt.user.client.ui.FormPanel) Button(com.google.gwt.user.client.ui.Button) Widget(com.google.gwt.user.client.ui.Widget) FormHandler(com.google.gwt.user.client.ui.FormHandler) TextBox(com.google.gwt.user.client.ui.TextBox) FormSubmitEvent(com.google.gwt.user.client.ui.FormSubmitEvent) FileUpload(com.google.gwt.user.client.ui.FileUpload) ClickListener(com.google.gwt.user.client.ui.ClickListener)

Aggregations

Button (com.google.gwt.user.client.ui.Button)1 ClickListener (com.google.gwt.user.client.ui.ClickListener)1 FileUpload (com.google.gwt.user.client.ui.FileUpload)1 FormHandler (com.google.gwt.user.client.ui.FormHandler)1 FormPanel (com.google.gwt.user.client.ui.FormPanel)1 FormSubmitCompleteEvent (com.google.gwt.user.client.ui.FormSubmitCompleteEvent)1 FormSubmitEvent (com.google.gwt.user.client.ui.FormSubmitEvent)1 TextBox (com.google.gwt.user.client.ui.TextBox)1 VerticalPanel (com.google.gwt.user.client.ui.VerticalPanel)1 Widget (com.google.gwt.user.client.ui.Widget)1