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:anzsoft.xmpp4gwt.client.Bosh2Connector.java
License:Open Source License
public void setHttpBase(final String boshUrl) { if (boshUrl.startsWith("http://") || boshUrl.startsWith("https://")) { setCrossDomainHttpBase(boshUrl); return;/*from www .java2s . c om*/ } builder = new RequestBuilder(RequestBuilder.POST, boshUrl); builder.setHeader("Connection", "close"); }
From source file:br.com.pegasus.solutions.smartgwt.lib.client.view.impl.advanced.bar.infra.ExporterData.java
License:Apache License
private static void processRequest(String params) { try {/* www .ja v a2 s. c o m*/ RequestBuilder requestBuilder = new RequestBuilder(RequestBuilder.POST, GWT.getModuleBaseURL() + "ExportServlet"); requestBuilder.setHeader("Content-type", "application/x-www-form-urlencoded"); requestBuilder.sendRequest(params, new RequestCallback() { public void onResponseReceived(Request request, Response response) { if (200 == response.getStatusCode()) { ExporterData.callExportServlet .fireEvent(new ClickEvent(ExporterData.callExportServlet.getJsObj())); } else { MessageUtil .showError("An Error occurred response status code: " + response.getStatusCode()); } } public void onError(Request request, Throwable exception) { MessageUtil.showError(exception.getMessage()); } }); } catch (RequestException e) { MessageUtil.showError(e.getMessage()); } }
From source file:br.com.pegasus.solutions.smartgwt.lib.client.view.impl.util.HttpRequestUtil.java
License:Apache License
/** * make servlet request/*from w w w . ja v a 2s . co m*/ * * @param servletName {@link String} * @param params {@link String} * @param iRequestBuilderSucessAction {@link IRequestBuilderFailedAction} * @param iFailedAction {@link IRequestBuilderFailedAction} * @throws RequestException * @return void */ public static void doPostServletRequest(String servletName, String params, final IRequestBuilderSucessAction iRequestBuilderSucessAction, final IRequestBuilderFailedAction iFailedAction) throws RequestException { doRequest(iRequestBuilderSucessAction, iFailedAction, GWT.getModuleBaseURL() + servletName, params, RequestBuilder.POST); }
From source file:ca.upei.ic.timetable.client.Remote.java
License:Apache License
/** * Calls a remote method using HTTP POST * /*from w w w .j ava 2 s .co m*/ * @param method * @param contentType * @param data * @param callback */ public Request post(String method, String contentType, String data, RequestCallback callback) { StringBuffer q = new StringBuffer(); q.append("?method=" + method); RequestBuilder req = new RequestBuilder(RequestBuilder.POST, url_ + q); req.setHeader("Content-type", contentType); req.setRequestData(data); req.setCallback(callback); Request request = null; try { request = req.send(); } catch (RequestException re) { callback.onError(request, re); } return request; }
From source file:cc.kune.core.client.auth.WaveClientSimpleAuthenticator.java
License:GNU Affero Public License
/** * Do login./*from w w w . j av a 2 s .co m*/ * * @param userWithoutDomain * the user without domain * @param passwd * the passwd * @param callback * the callback */ public void doLogin(final String userWithoutDomain, final String passwd, final AsyncCallback<Void> callback) { final RequestBuilder request = new RequestBuilder(RequestBuilder.POST, "/auth/signin"); final StringBuffer params = new StringBuffer(); params.append("address="); params.append(URL.encodeQueryString(userWithoutDomain)); params.append("&password="); params.append(URL.encodeQueryString(passwd)); params.append("&signIn="); params.append(URL.encodeQueryString("Sign in")); try { request.setHeader("Content-Type", "application/x-www-form-urlencoded"); request.sendRequest(params.toString(), new RequestCallback() { @Override public void onError(final Request request, final Throwable exception) { StackErrorEvent.fire(eventBus, exception); callback.onFailure(exception); } @Override public void onResponseReceived(final Request request, final Response response) { callback.onSuccess(null); } }); } catch (final RequestException e) { StackErrorEvent.fire(eventBus, e); } }
From source file:ccc.client.gwt.core.GWTRequestExecutor.java
License:Open Source License
private Method getMethod(final HttpMethod method) { switch (method) { case GET:/*from w w w .j av a 2s .c o m*/ return RequestBuilder.GET; case POST: return RequestBuilder.POST; case PUT: return RequestBuilder.POST; case DELETE: return RequestBuilder.POST; default: throw new IllegalArgumentException("Unsupported HTTP method: " + method); } }
From source file:ch.unifr.pai.twice.widgets.mpproxy.client.ScreenShotDistributor.java
License:Apache License
/** * Send the screenshot to the server/* ww w. j ava 2s . c o m*/ */ public void sendScreenShot() { String screen = Document.get().getDocumentElement().getInnerHTML(); if (!screen.equals(lastSent) || lastLeft != Window.getScrollLeft() || lastTop != Window.getScrollTop()) { String url = Window.Location.getHref(); URLParser p = new URLParser(url, Rewriter.getServletPath(Window.Location.getHref())); RequestBuilder rb = new RequestBuilder(RequestBuilder.POST, GWT.getModuleBaseURL() + "manager?url=" + p.getProxyBasePath() + "&width=" + Window.getClientWidth() + "&height=" + Window.getClientHeight() + "&top=" + Window.getScrollTop() + "&left=" + Window.getScrollLeft()); lastSent = screen; lastLeft = Window.getScrollLeft(); lastTop = Window.getScrollTop(); screen = screen.replace('\n', ' '); screen = screen.replaceAll("<body", "<body><div class=\"readOnlyView\" style=\"width:" + Window.getClientWidth() + "; height:" + Window.getClientHeight() + ";\""); screen = screen.replaceAll("<\\/body>", "</div></body>"); screen = screen.replaceAll("(<script).*?(\\/script>)", ""); try { rb.sendRequest(screen, new RequestCallback() { @Override public void onResponseReceived(Request request, Response response) { // TODO Auto-generated method stub } @Override public void onError(Request request, Throwable exception) { Window.alert("Screenshot sent"); } }); } catch (RequestException e) { e.printStackTrace(); } } }
From source file:colt.json.gwt.client.JsonClient.java
License:Apache License
public void invoke(final String _url, final String _serviceName, String requestData, final IAsyncJSON result) { try {//w w w . j a va2 s . c om RequestBuilder requestBuilder = new RequestBuilder(RequestBuilder.POST, URL.encode(_url + _serviceName)); requestBuilder.setHeader("content-type", "application/x-www-form-urlencoded"); Request request = requestBuilder.sendRequest(requestData, new RequestCallback() { public void onError(Request request, Throwable exception) { result.error(exception); } public void onResponseReceived(Request request, Response response) { if (200 == response.getStatusCode()) { String text = response.getText(); JSONValue parser = JSONParser.parse(text); JSONObject jobj = parser.isObject(); result.done(jobj); } else { result.error(new RuntimeException(_url + _serviceName + " :(")); } } }); } catch (RequestException e) { Window.alert(e.getMessage()); result.error(e); } }
From source file:com.ait.tooling.nativetools.client.rpc.JSONCommandRequest.java
License:Open Source License
public JSONCommandRequest(final String url, final boolean usexsrf) { super(true);/*ww w .j av a 2 s .c o m*/ m_usexsrf = usexsrf; m_postURL = URL.encode(StringOps.requireTrimOrNull(url)); m_builder = new RequestBuilder(Objects.requireNonNull(RequestBuilder.POST), m_postURL); doPrepareBuilderInit(m_builder); }
From source file:com.ait.toolkit.cordova.client.plugins.blackberry.pushwoosh.PushWooshBlackBerry.java
License:Open Source License
public void register() { RequestBuilder req = new RequestBuilder(RequestBuilder.POST, getBaseUrl() + "registerDevice"); req.setHeader("Content-type", "application/json; charset=utf-8"); req.setRequestData(getPushWooshRegisterPayload()); req.setCallback(new RequestCallback() { @Override/*from w ww . ja v a2s . c o m*/ public void onResponseReceived(Request request, Response response) { if (response.getStatusCode() == 200) { registerCallback.onSuccess(response.getText()); } else { registerCallback.onError(-1); } } @Override public void onError(Request request, Throwable exception) { registerCallback.onError(-1); } }); try { req.send(); } catch (RequestException e) { e.printStackTrace(); } }