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

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

Introduction

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

Prototype

String METHOD_GET

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

Click Source Link

Document

Used with #setMethod(String) to specify that the form will be submitted using an HTTP GET request.

Usage

From source file:com.google.gerrit.client.auth.openid.OpenIdSignInDialog.java

License:Apache License

public OpenIdSignInDialog(final SignInMode requestedMode, final String token, final String initialErrorMsg) {
    super(requestedMode, token);

    formBody = new FlowPanel();
    formBody.setStyleName(OpenIdResources.I.css().loginForm());

    form = new FormPanel();
    form.setMethod(FormPanel.METHOD_GET);
    form.addSubmitHandler(this);
    form.add(formBody);//from w  w  w .  j a  va 2  s  . c  o m

    redirectBody = new FlowPanel();
    redirectBody.setVisible(false);
    redirectForm = new FormPanel();
    redirectForm.add(redirectBody);

    panelWidget = new FlowPanel();
    panelWidget.add(form);
    panelWidget.add(redirectForm);
    add(panelWidget);

    createHeaderLogo();
    createHeaderText();
    createErrorBox();
    createIdentBox();

    link(OpenIdUrls.URL_GOOGLE, OpenIdUtil.C.nameGoogle(), OpenIdResources.I.iconGoogle());
    link(OpenIdUrls.URL_YAHOO, OpenIdUtil.C.nameYahoo(), OpenIdResources.I.iconYahoo());

    if (initialErrorMsg != null) {
        showError(initialErrorMsg);
    }
    formBody.add(new HTML(OpenIdUtil.C.whatIsOpenIDHtml()));
}

From source file:org.jbpm.formbuilder.client.RestyFormBuilderModel.java

License:Apache License

@Override
public void loadFormTemplate(final FormRepresentation form, String language) {
    final String url = URLBuilder.loadFormTemplateURL(this.contextPath, language);
    Resource resource = new Resource(url);
    try {//from  w w w  .  j  av a  2  s.co  m
        String xml = helper.asXml(form, null);
        resource.post().xml(XMLParser.parse(xml)).send(new SimpleTextCallback(i18n.CouldntExportTemplate()) {
            @Override
            public void onSuccess(Method method, String response) {
                String fileName = helper.getFileName(response);
                FormPanel auxiliarForm = new FormPanel();
                auxiliarForm.setMethod(FormPanel.METHOD_GET);
                auxiliarForm.setAction(url);
                Hidden hidden1 = new Hidden("fileName");
                hidden1.setValue(fileName);
                Hidden hidden2 = new Hidden("formName");
                hidden2.setValue(
                        form.getName() == null || "".equals(form.getName()) ? "template" : form.getName());
                VerticalPanel vPanel = new VerticalPanel();
                vPanel.add(hidden1);
                vPanel.add(hidden2);
                auxiliarForm.add(vPanel);
                RootPanel.get().add(auxiliarForm);
                auxiliarForm.submit();
            }
        });
    } catch (FormEncodingException e) {
        bus.fireEvent(new NotificationEvent(Level.ERROR, i18n.CouldntDecodeForm(), e));
    }
}

From source file:org.rstudio.studio.client.server.remote.RemoteServerAuth.java

License:Open Source License

public void updateCredentials(final ServerRequestCallback<Integer> requestCallback) {
    // safely cleanup any previously active update credentials forms
    safeCleanupPreviousUpdateCredentials();

    // create a hidden form panel to submit the update credentials to
    // (we do this so GWT manages the trickiness associated with 
    // managing and reading the contents of a hidden iframe) 
    final FormPanel updateCredentialsForm = new FormPanel();
    updateCredentialsForm.setMethod(FormPanel.METHOD_GET);
    updateCredentialsForm.setEncoding(FormPanel.ENCODING_URLENCODED);

    // form url/*from   ww w .  j a  va2  s  .  c  o m*/
    String url = remoteServer_.getApplicationURL("auth-update-credentials");
    updateCredentialsForm.setAction(url);

    // request log entry (fake up a json rpc method call to conform
    // to the data format expected by RequestLog
    String requestId = Integer.toString(Random.nextInt());
    String requestData = createRequestData();
    final RequestLogEntry logEntry = RequestLog.log(requestId, requestData);

    // form submit complete handler
    updateCredentialsForm.addSubmitCompleteHandler(new SubmitCompleteHandler() {

        public void onSubmitComplete(SubmitCompleteEvent event) {
            // parse the results
            String results = event.getResults();
            RpcResponse response = RpcResponse.parse(event.getResults());
            if (response != null) {
                logEntry.logResponse(ResponseType.Normal, results);

                // check for error
                RpcError rpcError = response.getError();
                if (rpcError != null) {
                    if (rpcError.getCode() == RpcError.METHOD_NOT_FOUND) {
                        requestCallback.onResponseReceived(new Integer(CREDENTIALS_UPDATE_UNSUPPORTED));
                    } else {
                        requestCallback.onError(new RemoteServerError(rpcError));
                    }
                } else // must be a valid response
                {
                    Bool authenticated = response.getResult();
                    if (authenticated.getValue()) {
                        requestCallback.onResponseReceived(new Integer(CREDENTIALS_UPDATE_SUCCESS));
                    } else {
                        requestCallback.onResponseReceived(new Integer(CREDENTIALS_UPDATE_FAILURE));
                    }
                }
            } else // error parsing results
            {
                logEntry.logResponse(ResponseType.Error, results);

                // form message
                String msg = "Error parsing results: " + (results != null ? results : "(null)");

                // we don't expect this so debug log to flag our attention
                Debug.log("UPDATE CREDENTIALS: " + msg);

                // return the error
                RpcError rpcError = RpcError.create(RpcError.PARSE_ERROR, msg);
                requestCallback.onError(new RemoteServerError(rpcError));
            }

            // remove the hidden form (from both last-ditch list and DOM)
            previousUpdateCredentialsForms_.remove(updateCredentialsForm);
            Scheduler.get().scheduleDeferred(new ScheduledCommand() {
                public void execute() {
                    RootPanel.get().remove(updateCredentialsForm);
                }
            });
        }
    });

    // add the (hidden) form panel to the document and last ditch list
    RootPanel.get().add(updateCredentialsForm, -1000, -1000);
    previousUpdateCredentialsForms_.add(updateCredentialsForm);

    // submit the form
    updateCredentialsForm.submit();
}

From source file:therandomhomepage.mainclient.FeedbackPanel.java

License:Apache License

public FeedbackPanel() {

    NamedFrame mailFrame = new NamedFrame("mailFrame");
    mailFrame.setVisible(false);// w ww.j ava 2  s.c om

    final FormPanel form = new FormPanel(mailFrame);
    form.setAction("/php/sendMail.php");

    form.setMethod(FormPanel.METHOD_GET);
    form.setEncoding(FormPanel.ENCODING_URLENCODED);

    VerticalPanel panel = new VerticalPanel();
    panel.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER);
    panel.setVerticalAlignment(VerticalPanel.ALIGN_TOP);

    panel.add(form);

    panel.add(mailFrame);

    initWidget(panel);

    table = new FlexTable();
    table.addStyleName("divBlock");
    table.addStyleName("feedbackForm");

    table.setWidget(1, 0, new HTML("<h3>Feedback</h3>"));

    table.setWidget(2, 0, new Label("Name: "));
    table.getFlexCellFormatter().setVerticalAlignment(1, 0, HasVerticalAlignment.ALIGN_TOP);

    TextBox txtName = new TextBox();
    txtName.setName("txtName");
    table.setWidget(2, 1, txtName);

    table.setWidget(3, 0, new Label("Email: "));
    table.getFlexCellFormatter().setVerticalAlignment(2, 0, HasVerticalAlignment.ALIGN_TOP);

    txtEmail = new TextBox();
    txtEmail.setName("txtEmail");
    table.setWidget(3, 1, txtEmail);

    table.setWidget(4, 0, new Label("Subject: "));
    table.getFlexCellFormatter().setVerticalAlignment(3, 0, HasVerticalAlignment.ALIGN_TOP);

    ListBox subject = new ListBox();
    subject.setName("selSubject");
    subject.addItem("General", "General");
    subject.addItem("Comments", "Comments");
    subject.addItem("Suggestion", "Suggestion");
    subject.addItem("Bug report", "Bug report");
    subject.addItem("Others", "Others");

    table.setWidget(4, 1, subject);

    table.setWidget(5, 0, new Label("Message: "));
    table.getFlexCellFormatter().setVerticalAlignment(4, 0, HasVerticalAlignment.ALIGN_TOP);

    txtMessage = new TextArea();
    txtMessage.setName("txtMessage");
    txtMessage.setCharacterWidth(50);
    txtMessage.setVisibleLines(8);
    table.setWidget(5, 1, txtMessage);

    btnSubmit = new Button("Submit", new ClickListener() {
        public void onClick(Widget sender) {
            form.submit();
        }
    });

    table.setWidget(6, 0, btnSubmit);

    form.add(table);

    form.addFormHandler(new FormHandler() {
        public void onSubmitComplete(FormSubmitCompleteEvent event) {
            //ignore this
        }

        public void onSubmit(FormSubmitEvent event) {
            if (txtEmail.getText().trim().length() == 0) {
                Window.alert("Please provide your email address !");
                event.setCancelled(true);
                txtEmail.setFocus(true);
            } else if (txtMessage.getText().trim().length() == 0) {
                Window.alert("Please provide feedback !");
                event.setCancelled(true);
                txtMessage.setFocus(true);
            } else {
                HTML thanksHTML = new HTML(
                        "<b class=\"thanks\">We really appreciate your feedback. Thanks a lot !</b>");
                table.setWidget(0, 1, thanksHTML);
                btnSubmit.setEnabled(false);
            }
        }
    });
}