List of usage examples for com.google.gwt.http.client RequestBuilder POST
Method POST
To view the source code for com.google.gwt.http.client RequestBuilder POST.
Click Source Link
From source file:org.apache.thrift.async.TAsyncClientManager.java
License:Apache License
public void call(final TAsyncMethodCall method) throws TException { String data = new String(method.getRequestData()); RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode(serviceUrl)); builder.setHeader("Content-Type", "application/json"); builder.setRequestData(new String(data)); if (method.getClient().hasTimeout()) { builder.setTimeoutMillis((int) method.getClient().getTimeout()); }/*www. j a v a 2s . c om*/ try { builder.sendRequest(new String(data), new RequestCallback() { @Override public void onResponseReceived(Request request, Response response) { if (response != null) { switch (response.getStatusCode()) { case Response.SC_OK: method.onSuccess(response.getText()); break; default: method.onError( new TTransportException("Bad HTTP status code: " + response.getStatusCode())); break; } } else { method.onError(new TTransportException("HTTP response is null.")); } } @Override public void onError(Request request, Throwable exception) { method.onError(new TTransportException(exception)); } }); } catch (RequestException e) { method.onError(new TTransportException(e)); } }
From source file:org.appverse.web.framework.frontend.gwt.commands.impl.live.LogoutManagementRpcCommandImpl.java
License:Appverse Public License
@Override public void onLogout() { RequestBuilder rb = new RequestBuilder(RequestBuilder.POST, "j_spring_security_logout"); try {/*from w w w . j a v a 2 s .c o m*/ rb.sendRequest(null, new RequestCallback() { @Override public void onError(final Request request, final Throwable caught) { // Logout in server failed } @Override public void onResponseReceived(final Request request, final Response response) { // Reloading the page will clear GWT status. // As the user has been logged out, spring security will // show login page again Window.Location.reload(); } }); } catch (RequestException re) { } }
From source file:org.bonitasoft.console.client.user.task.action.CheckFormMappingAndDisplayPerformTaskPageAction.java
License:Open Source License
protected void executeTask(final String taskId, final TreeIndexed<String> parameters) { RequestBuilder requestBuilder;//from ww w . j av a 2 s. co m requestBuilder = new RequestBuilder(RequestBuilder.POST, "../API/bpm/userTask/" + taskId + "/execution"); requestBuilder.setCallback(new ExecuteTaskCallback(taskId, taskDisplayName)); try { requestBuilder.send(); } catch (final RequestException e) { GWT.log("Error while creating the task execution request", e); } }
From source file:org.bonitasoft.web.toolkit.client.data.api.APICaller.java
License:Open Source License
/** * Add a new item by submitting a form/*from w ww. j a v a2s .c om*/ * * @param form * The form to submit */ public void add(final AbstractForm form, final APICallback callback) { final Map<String, String> values = form.getValues().getValues(); if (this.itemDefinition != null) { ModifierEngine.modify(values, this.itemDefinition.getInputModifiers()); ValidatorEngine.validate(values, this.itemDefinition.getValidators()); } this.send(RequestBuilder.POST, this.url + "/", JSonSerializer.serialize(values), HttpRequest.CONTENT_TYPE_JSON, callback); }
From source file:org.bonitasoft.web.toolkit.client.data.api.APICaller.java
License:Open Source License
/** * Add a new item by submitting a form/*w ww . j ava2 s .c o m*/ * * @param item * The item to submit */ public void add(final IItem item, final APICallback callback) { ValidatorEngine.validate(item, true); this.send(RequestBuilder.POST, this.url + "/", new JSonItemWriter<Item>(item).toString(), HttpRequest.CONTENT_TYPE_JSON, callback); }
From source file:org.bonitasoft.web.toolkit.client.data.api.request.APIAddRequest.java
License:Open Source License
@Override public void run() { this.request = new RequestBuilder(RequestBuilder.POST, this.itemDefinition.getAPIUrl() + "/"); super.run();//www .j a v a 2s. c o m }
From source file:org.bonitasoft.web.toolkit.client.data.api.request.HttpRequest.java
License:Open Source License
/** * Send a POST HTTP request/* w ww.j a va 2 s .co m*/ * * @param callback * The APICallback to call onSuccess or onError. * @param datas * The data to send * @param url * The URL of the API */ public void send(final String url, final String datas, final HttpCallback callback) { this.send(RequestBuilder.POST, url, datas, null, callback); }
From source file:org.bonitasoft.web.toolkit.client.ui.action.form.SendFormAction.java
License:Open Source License
/** * Function to build the request and execute the POST action. */// w w w. j a v a 2 s . c o m @Override public void execute() { new HttpRequest().send(RequestBuilder.POST, this.resourceUrl, getForm().toJson(), HttpRequest.CONTENT_TYPE_JSON, this.callBack); }
From source file:org.celstec.arlearn2.gwtcommonlib.client.auth.OauthTwitter.java
License:Open Source License
public static void autenticate() { String url = "https://api.twitter.com/oauth/request_token"; RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, url); // builder.setHeader("Content-Type", "application/json"); builder.setHeader("Authorization", "oauth_callback=\"http%3A%2F%2Fmyapp.com%3A3005%2Ftwitter%2Fprocess_callback\""); try {/*from w ww .j av a 2s . co m*/ Request request = builder.sendRequest("", new RequestCallback() { @Override public void onResponseReceived(Request request, Response response) { System.out.println("response received"); if (200 == response.getStatusCode()) { } } @Override public void onError(Request request, Throwable exception) { } }); } catch (RequestException e) { e.printStackTrace(); } }
From source file:org.cleanlogic.ol4gwt.showcase.examples.VectorWFSGetFeature.java
License:Apache License
@Override public void buildPanel() { StyleOptions styleOptions = new StyleOptions(); styleOptions.stroke = StrokeStyle.create(Color.create(0, 0, 255, 1.0), 2); VectorLayerOptions vectorLayerOptions = new VectorLayerOptions(); vectorLayerOptions.source = vectorSource; // vectorLayerOptions.style = new Style[] {new Style(styleOptions)}; VectorLayer vectorLayer = new VectorLayer(vectorLayerOptions); BingMapsSourceOptions bingMapsSourceOptions = new BingMapsSourceOptions(); bingMapsSourceOptions.imagerySet = "Aerial"; bingMapsSourceOptions.key = "AkGbxXx6tDWf1swIhPJyoAVp06H0s0gDTYslNWWHZ6RoPqMpB9ld5FY1WutX8UoF"; TileLayer raster = TileLayer.create(new BingMapsSource(bingMapsSourceOptions)); ViewOptions viewOptions = new ViewOptions(); viewOptions.center = Coordinate.create(-8908887.277395891, 5381918.072437216); viewOptions.maxZoom = 19;/*from www . j av a 2 s.c o m*/ viewOptions.zoom = 12; MapOptions mapOptions = new MapOptions(); mapOptions.layers = new Collection<>(new BaseLayer[] { raster, vectorLayer }); mapOptions.view = new View(viewOptions); final MapPanel mapPanel = new MapPanel(mapOptions); mapPanel.setHeight("400px"); Filter filter = FilterUtils.and(new IsLikeFilter("name", "Mississippi*"), new EqualToFilter("waterway", "riverbank")); GetFeatureOptions getFeatureOptions = new GetFeatureOptions(); getFeatureOptions.srsName = "EPSG:3857"; getFeatureOptions.featureNS = "http://openstreemap.org"; getFeatureOptions.featurePrefix = "osm"; getFeatureOptions.featureTypes = new String[] { "water_areas" }; getFeatureOptions.outputFormat = "application/json"; getFeatureOptions.filter = filter; WFSFormat wfsFormat = new WFSFormat(); Node node = wfsFormat.writeGetFeature(getFeatureOptions); RequestBuilder requestBuilder = new RequestBuilder(RequestBuilder.POST, "https://ahocevar.com/geoserver/wfs"); requestBuilder.setRequestData(new XMLSerializer().serializeToString(node)); requestBuilder.setCallback(new RequestCallback() { @Override public void onResponseReceived(Request request, Response response) { GeoJSONFormat format = new GeoJSONFormat(); Feature[] features = format.readFeatures(response.getText()); vectorSource.addFeatures(features); mapPanel.getMap().getView().fit(vectorSource.getExtent()); } @Override public void onError(Request request, Throwable throwable) { GWT.log(throwable.toString()); } }); contentPanel.add(new HTML( "<p>This example generates a GetFeature request which uses a PropertyIsEqualTo and a PropertyIsLike filter, and then posts the request to load the features that match the query.</p>")); contentPanel.add(mapPanel); initWidget(contentPanel); try { requestBuilder.send(); } catch (RequestException ex) { GWT.log(ex.getLocalizedMessage()); } }