Example usage for com.google.gwt.http.client RequestBuilder GET

List of usage examples for com.google.gwt.http.client RequestBuilder GET

Introduction

In this page you can find the example usage for com.google.gwt.http.client RequestBuilder GET.

Prototype

Method GET

To view the source code for com.google.gwt.http.client RequestBuilder GET.

Click Source Link

Document

Specifies that the HTTP GET method should be used.

Usage

From source file:org.bonitasoft.console.client.view.reporting.UserStatsView.java

License:Open Source License

private void queryReport(int aRow, int aCol, int aReportIndex) {
    final RequestBuilder theRequestBuilder;
    if (aReportIndex < bonitaReports.length) {
        GWT.log("Calling report generation for: " + bonitaReports[aReportIndex].getUUID().getValue());
        try {//  w w w .jav  a2s . c  o m

            final HTML theCell;
            if (aCol % 2 == 0) {
                myCurrentRow = new FlowPanel();
                myCurrentRow.setStyleName("reporting_block");
                myReportListPanel.add(myCurrentRow);
            }
            theCell = new HTML();
            theCell.setHTML(myLoadingMessage);
            theCell.setStyleName("report_item");
            myCurrentRow.add(theCell);
            theRequestBuilder = new RequestBuilder(RequestBuilder.GET,
                    myReportingDataSource.buildReportURL(bonitaReports[aReportIndex], ReportScope.USER));
            theRequestBuilder.setCallback(new BonitaReportRequestCallback(aRow, aCol, aReportIndex, theCell));
            theRequestBuilder.send();
        } catch (RequestException e) {
            GWT.log("Error while trying to query the reports:" + e.getMessage(), e);
        }
    } else {
        myReloadButton.setVisible(true);
    }
}

From source file:org.bonitasoft.console.client.view.UserSettingsEditionView.java

License:Open Source License

private void buildSelectableReport(final ReportItem aReportItem, final HTML aContainer) {
    if (aContainer == null) {
        GWT.log("Container must not be null. Exit.", null);
        return;//from  ww  w.  ja v a 2 s. co  m
    }

    try {
        if (aReportItem == null || aReportItem.getFileName() == null
                || aReportItem.getFileName().length() == 0) {
            GWT.log("Report name must neither be null nor empty. Exit.", null);
            return;
        }
        if (aReportItem.getUUID().equals(myUserProfile.getDefaultReportUUID())
                || (myUserProfile.getDefaultReportUUID() == null
                        && aReportItem.getUUID().equals(ConsoleConstants.DEFAULT_REPORT_UUID))) {
            // Select the report if it is the one used by the user.
            selectReportContainer(aContainer);
        }
        RequestBuilder theRequestBuilder = new RequestBuilder(RequestBuilder.GET, buildReportURL(aReportItem));
        theRequestBuilder.setCallback(new RequestCallback() {
            public void onError(Request aRequest, Throwable anException) {
                aContainer.setHTML(constants.unableToDisplayReport());
            }

            public void onResponseReceived(Request aRequest, Response aResponse) {
                if (aResponse.getStatusCode() == Response.SC_OK) {
                    aContainer.setHTML(aResponse.getText());
                } else {
                    aContainer.setHTML(constants.unableToDisplayReport());
                }
                aContainer.addClickHandler(new ClickHandler() {

                    public void onClick(ClickEvent anEvent) {
                        selectReportContainer(aContainer);
                        mySelectedReport = aReportItem;
                    }

                });
            }
        });
        aContainer.setHTML(loadingHTML);
        theRequestBuilder.send();
    } catch (RequestException e) {
        aContainer.setHTML(constants.unableToDisplayReport());
    }

}

From source file:org.bonitasoft.web.toolkit.client.data.api.request.APIGetRequest.java

License:Open Source License

@Override
public void run() {
    final UrlBuilder url = new UrlBuilder(this.itemDefinition.getAPIUrl() + "/" + this.id.toString());
    if (getDeploys() != null && getDeploys().size() > 0) {
        url.addParameter(PARAMETER_DEPLOY, getDeploys());
    }//from   w  w  w  .  j a v a2s. c o m
    if (getCounters() != null && getCounters().size() > 0) {
        url.addParameter(PARAMETER_COUNTER, getCounters());
    }

    this.request = new RequestBuilder(RequestBuilder.GET, url.toString());
    super.run();
}

From source file:org.bonitasoft.web.toolkit.client.data.api.request.APISearchRequest.java

License:Open Source License

@Override
public void run() {

    final UrlBuilder url = new UrlBuilder(this.itemDefinition.getAPIUrl());
    url.addParameter(PARAMETER_PAGE, getPage());
    url.addParameter(PARAMETER_LIMIT, getResultsPerPage());
    if (getOrder() != null && getOrder().length() > 0) {
        url.addParameter(PARAMETER_ORDER, getOrder());
    }// w  ww  .j  a v a 2  s. c  o  m
    if (getSearch() != null && getSearch().length() > 0) {
        url.addParameter(PARAMETER_SEARCH, getSearch());
    }
    if (getFilters() != null && getFilters().size() > 0) {
        url.addParameter(PARAMETER_FILTER, getFilters());
    }
    if (getDeploys() != null && getDeploys().size() > 0) {
        url.addParameter(PARAMETER_DEPLOY, getDeploys());
    }
    if (getCounters() != null && getCounters().size() > 0) {
        url.addParameter(PARAMETER_COUNTER, getCounters());
    }

    this.request = new RequestBuilder(RequestBuilder.GET, url.toString());

    super.run();
}

From source file:org.bonitasoft.web.toolkit.client.data.api.request.HttpRequest.java

License:Open Source License

/**
 * Send a GET HTTP request/*from  w w w. ja v a  2 s .c om*/
 *
 * @param callback
 *        The APICallback to call onSuccess or onError.
 * @param url
 *        The URL of the API
 */
public void send(final String url, final HttpCallback callback) {
    this.send(RequestBuilder.GET, url, null, null, callback);
}

From source file:org.chtijbug.workbench.drools.client.navbar.LogoWidgetView.java

License:Apache License

@PostConstruct
public void init() {
    final RequestBuilder rb = new RequestBuilder(RequestBuilder.GET, "banner/banner.html");
    rb.setCallback(new RequestCallback() {
        @Override/* w  w  w . java 2  s  .  co m*/
        public void onResponseReceived(final Request request, final Response response) {
            final HTMLPanel html = new HTMLPanel(response.getText());
            container.setWidget(html);
        }

        @Override
        public void onError(final Request request, final Throwable exception) {
            container.setWidget(new Label(AppConstants.INSTANCE.logoBannerError()));
        }
    });
    try {
        final Request r = rb.send();
    } catch (RequestException re) {
        container.setWidget(new Label(AppConstants.INSTANCE.logoBannerError()));
    }

    initWidget(container);
}

From source file:org.cleanlogic.cesiumjs4gwt.showcase.basic.AbstractSourceButton.java

License:Apache License

public void onClick(ClickEvent event) {
    RequestBuilder reqBuilder = new RequestBuilder(RequestBuilder.GET, this.sourceCodeURL);
    try {//from   w w w  .j a va 2s .  co  m
        reqBuilder.sendRequest("", new RequestCallback() {

            public void onResponseReceived(Request request, Response response) {
                showSourceCode(response.getText());
            }

            public void onError(Request request, Throwable exception) {
            }

        });
    } catch (RequestException ex) {
    }

}

From source file:org.client.JavaApp2Workbook.java

License:Open Source License

/**
 * Resolve one type of content that a Xholon app can have.
 * @param fileName A local file name, or remote uri (http), or null.
 * @param contentType One of "_xhn" "ih" "cd" "csh" etc.
 *//*  w ww  .  j a v a2s  .co  m*/
protected void resolve(String fileName, String contentType) {
    //this.println("trying to resolve " + fileName + " " + contentType);
    if (fileName == null) {
        // app is probably using a ClientBundle
        String txt = app.rcConfig(contentType, (ClientBundleWithLookup) app.findGwtClientBundle());
        resolveDone(txt, contentType);
        return;
    }
    final String _contentType = contentType;
    final String _fileName = fileName;
    final IXholon _this = this;
    try {
        new RequestBuilder(RequestBuilder.GET, fileName).sendRequest("", new RequestCallback() {
            @Override
            public void onResponseReceived(Request req, Response resp) {
                if (resp.getStatusCode() == resp.SC_OK) {
                    resolveDone(resp.getText(), _contentType);
                } else {
                    _this.println("\nrequest: GET " + _fileName);
                    _this.println("status code:" + resp.getStatusCode());
                    _this.println("status text:" + resp.getStatusText());
                    _this.println("text:\n" + resp.getText());
                    resolveDone(null, _contentType);
                }
            }

            @Override
            public void onError(Request req, Throwable e) {
                _this.println("onError:" + e.getMessage());
                resolveDone(null, _contentType);
            }
        });
    } catch (RequestException e) {
        _this.println("RequestException:" + e.getMessage());
        resolveDone(null, _contentType);
    }
}

From source file:org.curriki.gwt.client.widgets.metadata.MetadataEdit.java

License:Open Source License

private void displaySkills(String value, final VerticalPanel panel) {
    RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, "/SearchI2G/render?uri="
            + URL.encodeComponent(value) + "&language=" + URL.encodeComponent(getLanguages()));
    try {/*from  w  ww  . j  ava  2  s  .  c  om*/
        builder.sendRequest(null, new RequestCallback() {
            public void onError(Request request, Throwable exception) {
                Window.alert("Error at rendering: " + exception);
            }

            public void onResponseReceived(Request request, Response response) {
                if (200 != response.getStatusCode()) {
                    Window.alert(
                            "Error " + response.getStatusCode() + " at rendering: " + response.getStatusText());
                    return;
                }
                panel.clear();
                panel.add(new HTML(response.getText()));

            }
        });
    } catch (RequestException e) {
        Window.alert("Error at launching rendering: " + e);
    }
}

From source file:org.dashbuilder.client.navbar.LogoWidgetView.java

License:Apache License

@PostConstruct
public void init() {
    final RequestBuilder rb = new RequestBuilder(RequestBuilder.GET, "banner/banner.html");
    rb.setCallback(new RequestCallback() {
        @Override/*w  w w . ja  v a2 s. c o  m*/
        public void onResponseReceived(final Request request, final Response response) {
            final HTMLPanel html = new HTMLPanel(response.getText());
            container.setWidget(html);
        }

        @Override
        public void onError(final Request request, final Throwable exception) {
            container.setWidget(new Label(AppConstants.INSTANCE.logoBannerError()));
        }
    });
    try {
        rb.send();
    } catch (RequestException re) {
        container.setWidget(new Label(AppConstants.INSTANCE.logoBannerError()));
    }

    initWidget(container);
}