Example usage for com.google.gwt.user.client.ui FormSubmitEvent setCancelled

List of usage examples for com.google.gwt.user.client.ui FormSubmitEvent setCancelled

Introduction

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

Prototype

public void setCancelled(boolean cancel) 

Source Link

Document

Sets whether the form submit will be canceled.

Usage

From source file:com.google.gwt.maps.sample.hellomaps.client.Geocoder2Demo.java

License:Apache License

public Geocoder2Demo() {
    Panel panel = new FlowPanel();
    final FormPanel form = new FormPanel();
    form.setAction("#");
    Panel formElements = new FlowPanel();
    Label label = new Label("Search for an address:");
    formElements.add(label);// www.j a va 2  s. co  m
    final TextBox addressBox = new TextBox();
    addressBox.setVisibleLength(40);
    formElements.add(addressBox);
    Button submit = new Button("Search");
    submit.addClickListener(new ClickListener() {
        public void onClick(Widget sender) {
            form.submit();
        }
    });
    formElements.add(submit);
    form.add(formElements);
    form.addFormHandler(new FormHandler() {
        public void onSubmit(FormSubmitEvent event) {
            showAddress(addressBox.getText());
            event.setCancelled(true);
        }

        public void onSubmitComplete(FormSubmitCompleteEvent event) {
        }
    });
    panel.add(form);

    map = new MapWidget(LatLng.newInstance(34, 0), 1);
    map.setSize("100%", "480px");
    panel.add(map);

    Grid grid = new Grid((sampleAddresses.length / NUM_ADDRESS_COLUMNS) + 1, NUM_ADDRESS_COLUMNS);

    for (int i = 0; i < sampleAddresses.length; i++) {
        final String address = sampleAddresses[i];
        Button link = new Button(address);
        // Hyperlink link = new Hyperlink(address, true,
        // "Extracting Structured Address Information");
        link.addClickListener(new ClickListener() {
            public void onClick(Widget sender) {
                addressBox.setText(address);
                form.submit();
            }
        });
        grid.setWidget(i / NUM_ADDRESS_COLUMNS, i % NUM_ADDRESS_COLUMNS, link);
    }
    panel.add(grid);

    initWidget(panel);
    geocoder = new Geocoder();
}

From source file:com.google.gwt.maps.sample.hellomaps.client.GeocoderDemo.java

License:Apache License

public GeocoderDemo() {
    Panel panel = new FlowPanel();
    final FormPanel form = new FormPanel();
    form.setAction("#");

    Panel formElements = new FlowPanel();
    final TextBox address = new TextBox();
    address.setVisibleLength(60);//  w  ww  .jav  a 2s .c o  m
    address.setText("10 10th Street, Atlanta, GA");
    formElements.add(address);
    formElements.add(buildLatLngPanel());
    this.displayLatLng(ATLANTA);

    Button submit = new Button("Go!");
    submit.addClickListener(new ClickListener() {
        public void onClick(Widget sender) {
            form.submit();
        }
    });
    formElements.add(submit);
    form.add(formElements);
    form.addFormHandler(new FormHandler() {
        public void onSubmit(FormSubmitEvent event) {
            showAddress(address.getText());
            event.setCancelled(true);
        }

        public void onSubmitComplete(FormSubmitCompleteEvent event) {
        }
    });
    panel.add(form);

    map = new MapWidget(ATLANTA, 13);
    map.setSize("500px", "300px");
    panel.add(map);
    initWidget(panel);
    geocoder = new Geocoder();
}