List of usage examples for com.google.gwt.http.client RequestBuilder GET
Method GET
To view the source code for com.google.gwt.http.client RequestBuilder GET.
Click Source Link
From source file:org.jboss.errai.ui.client.local.DynamicAngularComposite.java
License:Apache License
public DynamicAngularComposite(final String angularTemplateUrl, final String domElementId, final String angularModule) { final ElementWrapperWidget widget = ElementWrapperWidget.getWidget(DOM.createDiv()); this.initWidget(widget); // Just for testing purposes. The angular template could be downloaded using // Errai RPC or an Errai CDI event. try {//from www . j ava2s. c om new RequestBuilder(RequestBuilder.GET, angularTemplateUrl).sendRequest(null, new RequestCallback() { @Override public void onResponseReceived(Request request, Response response) { String template = response.getText(); Element domEl = DOM.createElement("div"); domEl.setInnerHTML(template); VisitContext<Element> context = Visit.depthFirst(domEl, new Visitor<Element>() { @Override public boolean visit(VisitContextMutable<Element> context, Element element) { if (element.hasAttribute("id")) { String id = element.getAttribute("id"); if (id.equals(domElementId)) { context.setResult(element); } } return true; } }); widget.setHTML(context.getResult().getString()); if (angularModule == null || angularModule.isEmpty()) { bootstrap(domElementId); } else { bootstrap(domElementId, angularModule); } } @Override public void onError(Request request, Throwable exception) { throw new RuntimeException(exception); } }); } catch (RequestException e) { throw new RuntimeException(e); } }
From source file:org.jboss.errai.ui.shared.ServerTemplateProvider.java
License:Apache License
@Override public void provideTemplate(final String url, final TemplateRenderingCallback renderingCallback) { final RequestBuilder request = new RequestBuilder(RequestBuilder.GET, url); request.setCallback(new RequestCallback() { @Override//from w ww. j a v a 2s.c om public void onResponseReceived(Request request, Response response) { if (response.getStatusCode() == Response.SC_OK) { renderingCallback.renderTemplate(response.getText()); } else { throw new RuntimeException("Failed to retrieve template from server at " + url + " (status code: " + response.getStatusCode() + ")"); } } @Override public void onError(Request request, Throwable exception) { throw new RuntimeException("Failed to retrieve template from server at " + url, exception); } }); try { request.send(); } catch (RequestException e) { throw new RuntimeException("Failed to retrieve template from server at" + request.getUrl(), e); } }
From source file:org.jboss.hal.dmr.dispatch.impl.DMRHandler.java
License:Open Source License
private RequestBuilder chooseRequestBuilder(final ModelNode operation) { RequestBuilder requestBuilder;/*ww w .j a va 2 s . c o m*/ final String op = operation.get(OP).asString(); if (READ_RESOURCE_DESCRIPTION_OPERATION.equals(op)) { String endpoint = endpoints.dmr(); if (endpoint.endsWith("/")) { endpoint = endpoint.substring(0, endpoint.length() - 1); } String descriptionUrl = endpoint + descriptionOperationToUrl(operation); requestBuilder = new RequestBuilder(RequestBuilder.GET, com.google.gwt.http.client.URL.encode(descriptionUrl)); requestBuilder.setHeader(HEADER_ACCEPT, DMR_ENCODED); requestBuilder.setHeader(HEADER_CONTENT_TYPE, DMR_ENCODED); requestBuilder.setIncludeCredentials(true); requestBuilder.setRequestData(null); } else { requestBuilder = postRequestBuilder; requestBuilder.setRequestData(operation.toBase64String()); } return requestBuilder; }
From source file:org.jbpm.workbench.cm.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/*from w w w. j a v a 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(translationService.format(ShowcaseConstants.LOGO_BANNER_ERROR))); } }); try { rb.send(); } catch (RequestException re) { container.setWidget(new Label(translationService.format(ShowcaseConstants.LOGO_BANNER_ERROR))); } initWidget(container); }
From source file:org.kie.workbench.common.screens.server.management.client.widget.card.footer.FooterPresenter.java
License:Apache License
RequestBuilder makeRequest(final String url, final Command onSuccess, final Command onError) { final RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, url); final String none = "none"; builder.setUser(none);//from w w w . j a v a 2 s.c om builder.setPassword(none); builder.setCallback(makeCallback(onSuccess, onError)); builder.setHeader("Accept", "*/*"); return builder; }
From source file:org.mindinformatics.gwt.framework.component.profiles.src.testing.JsonProfileManager.java
License:Apache License
@Override public void retrieveUserProfiles() { String url = GWT.getModuleBaseURL() + "profile/" + _application.getUserManager().getUser().getUserName() + "/all?format=json"; if (!_application.isHostedMode()) url = ApplicationUtils.getUrlBase(GWT.getModuleBaseURL()) + "profile/" + _application.getUserManager().getUser().getUserName() + "/all?format=json"; RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, url); builder.setHeader("Content-type", "application/json"); try {/* w ww. j av a 2 s.c o m*/ Request request = builder.sendRequest(null, new RequestCallback() { public void onError(Request request, Throwable exception) { _application.getInitializer().addException("Couldn't retrieve User Profiles JSON"); } public void onResponseReceived(Request request, Response response) { if (200 == response.getStatusCode()) { ArrayList<MProfile> userProfiles = new ArrayList<MProfile>(); JsArray profiles = (JsArray) parseJson(response.getText()); for (int j = 0; j < profiles.length(); j++) { JsoProfile jsoProfile = (JsoProfile) profiles.get(j); MProfile profile = new MProfile(); profile.setUuid(jsoProfile.getUuid()); profile.setName(jsoProfile.getName()); profile.setDescription(jsoProfile.getDescription()); profile.setLastSavedOn(jsoProfile.getCreatedOn()); JsArray<JavaScriptObject> creators = jsoProfile.getCreatedBy(); if (getObjectType(creators.get(0)).equals(IPerson.TYPE)) { AgentsFactory factory = new AgentsFactory(); JsoAgent jperson = (JsoAgent) creators.get(0); profile.setLastSavedBy((IPerson) factory.createAgent(jperson)); } JsArray<JsoProfileEntry> plugins = jsoProfile.getStatusPlugins(); for (int i = 0; i < plugins.length(); i++) { JsoProfileEntry entry = plugins.get(i); profile.getPlugins().put(entry.getName(), entry.getStatus()); } JsArray<JsoProfileEntry> features = jsoProfile.getStatusFeatures(); for (int i = 0; i < features.length(); i++) { JsoProfileEntry entry = features.get(i); profile.getFeatures().put(entry.getName(), entry.getStatus()); } userProfiles.add(profile); } setProfiles(userProfiles); stageCompleted(); } else { _application.getInitializer().addException( "Couldn't retrieve User Profiles JSON (" + response.getStatusText() + ")"); } } }); } catch (RequestException e) { _application.getInitializer().addException("Couldn't retrieve User Profiles JSON"); } }
From source file:org.mindinformatics.gwt.framework.component.profiles.src.testing.JsonProfileManager.java
License:Apache License
@Override public void retrieveUserCurrentProfile() { String url = GWT.getModuleBaseURL() + "profile/" + _application.getUserManager().getUser().getUserName() + "/info?format=json"; if (!_application.isHostedMode()) url = ApplicationUtils.getUrlBase(GWT.getModuleBaseURL()) + "profile/" + _application.getUserManager().getUser().getUserName() + "/info?format=json"; RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, url); builder.setHeader("Content-type", "application/json"); try {/*from w w w. j a va 2 s . c o m*/ Request request = builder.sendRequest(null, new RequestCallback() { public void onError(Request request, Throwable exception) { _application.getInitializer().addException("Couldn't retrieve User Profile JSON"); } public void onResponseReceived(Request request, Response response) { if (200 == response.getStatusCode()) { JsoProfile jsoProfile = (JsoProfile) ((JsArray) parseJson(response.getText())).get(0); MProfile profile = new MProfile(); profile.setUuid(jsoProfile.getUuid()); profile.setName(jsoProfile.getName()); profile.setDescription(jsoProfile.getDescription()); profile.setLastSavedOn(jsoProfile.getCreatedOn()); AgentsFactory factory = new AgentsFactory(); JsArray<JavaScriptObject> creators = jsoProfile.getCreatedBy(); if (getObjectType(creators.get(0)).equals(IPerson.TYPE)) { JsoAgent person = (JsoAgent) creators.get(0); profile.setLastSavedBy((IPerson) factory.createAgent(person)); } JsArray<JsoProfileEntry> plugins = jsoProfile.getStatusPlugins(); for (int i = 0; i < plugins.length(); i++) { JsoProfileEntry entry = plugins.get(i); profile.getPlugins().put(entry.getName(), entry.getStatus()); } JsArray<JsoProfileEntry> features = jsoProfile.getStatusFeatures(); for (int i = 0; i < features.length(); i++) { JsoProfileEntry entry = features.get(i); profile.getFeatures().put(entry.getName(), entry.getStatus()); } setCurrentProfile(profile); stageCompleted(); } else { _application.getInitializer().addException( "Couldn't retrieve User Profile JSON (" + response.getStatusText() + ")"); } } }); } catch (RequestException e) { _application.getInitializer().addException("Couldn't retrieve User Profile JSON"); } }
From source file:org.n52.client.ctrl.PropertiesManager.java
License:Open Source License
private void init() { try {//from ww w. j a v a2 s . co m // TODO refactor grabbing properties + loading mechanism setCurrentLanguage(); RequestBuilder requestBuilder = new RequestBuilder(RequestBuilder.GET, "properties/client-properties.xml"); RequestCallback callback = new RequestCallback() { public void onError(Request request, Throwable exception) { Toaster.getToasterInstance().addMessage(i18n.errorRequest()); } public void onResponseReceived(Request request, Response response) { PropertiesManager.this.properties = XMLParser.parse(response.getText()); Application.continueStartup(); } }; requestBuilder.sendRequest(null, callback); } catch (RequestException ex) { Toaster.getToasterInstance().addMessage(i18n.errorRequest()); } }
From source file:org.nsesa.editor.gwt.editor.client.Editor.java
License:EUPL
/** * Configures the local/* w w w . ja v a 2s .c o m*/ */ protected void configure() { try { RequestBuilder requestBuilder = new RequestBuilder(RequestBuilder.GET, CONFIGURATION_FILE); requestBuilder.sendRequest("", new RequestCallback() { @Override public void onResponseReceived(Request req, Response resp) { final JavaScriptObject configuration; try { configuration = JsonUtils.safeEval(resp.getText()); clientFactory.setConfiguration(configuration); // configuration ok -- continue LOG.log(Level.INFO, "Successfully read " + CONFIGURATION_FILE); } catch (Exception e) { LOG.log(Level.WARNING, "Could parse " + CONFIGURATION_FILE + ", configuration will be empty.", e); } finally { // continue with the loading onModuleLoadDeferred(); } } @Override public void onError(Request res, Throwable throwable) { // handle errors LOG.log(Level.INFO, "Could not read " + CONFIGURATION_FILE + ", configuration will be empty.", throwable); clientFactory.setConfiguration(JavaScriptObject.createObject()); // configuration failed -- ignore onModuleLoadDeferred(); } }); } catch (RequestException e) { LOG.log(Level.SEVERE, "Could not execute GET request to retrieve " + CONFIGURATION_FILE, e); clientFactory.setConfiguration(JavaScriptObject.createObject()); // configuration failed -- ignore onModuleLoadDeferred(); } }
From source file:org.nuxeo.ecm.platform.annotations.gwt.client.annotea.AnnoteaClient.java
License:Apache License
public void getAnnotationList(String annotates, final boolean forceDecorate) { if (annotates.contains("?")) { annotates = annotates.substring(0, annotates.indexOf('?')); }/*w w w.j a v a 2 s . c o m*/ String url = controller.getAnnoteaServerUrl() + "?w3c_annotates=" + annotates; RequestBuilder getRequest = new RequestBuilder(RequestBuilder.GET, URL.encode(url)); try { getRequest.sendRequest(null, new RequestCallback() { public void onError(Request request, Throwable exception) { } public void onResponseReceived(Request request, Response response) { responseManager.processAnnotationListResponse(response.getText()); if (forceDecorate) { // Force all the annotations to be redecorated controller.updateAnnotations(true); } } }); } catch (RequestException e) { GWT.log("Error while requesting annotations: " + url, e); Log.debug("Error while requesting annotations: " + url, e); Window.alert(e.toString()); } }