当前位置: 首页>>代码示例>>Java>>正文


Java RequestBuilder.send方法代码示例

本文整理汇总了Java中com.google.gwt.http.client.RequestBuilder.send方法的典型用法代码示例。如果您正苦于以下问题:Java RequestBuilder.send方法的具体用法?Java RequestBuilder.send怎么用?Java RequestBuilder.send使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.gwt.http.client.RequestBuilder的用法示例。


在下文中一共展示了RequestBuilder.send方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: doJsonRequest

import com.google.gwt.http.client.RequestBuilder; //导入方法依赖的package包/类
private void doJsonRequest(String url, String username, String password, JSONControllerCallback callback, Integer timeout) {
	RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, url);
	Request request = null;
	
	// Add accept header
	builder.setHeader("Accept", "application/json");
	
	if (username != null && username.length() > 0) {
		if (password == null) password = "";
		
		// Add authentication header
		String authStr = username + ":" + password;
		String authEnc = "Basic " + BrowserUtils.base64Encode(authStr);
		builder.setHeader("Authorization", authEnc);
	}
	
	builder.setCallback(callback);
	
	if (timeout != null) {
		builder.setTimeoutMillis(timeout);
	}
	
   try {
 		request = builder.send();
   } catch (RequestException e) {
 		callback.onError(request, e);
   }
}
 
开发者ID:openremote,项目名称:WebConsole,代码行数:29,代码来源:JSONControllerConnector.java

示例2: testBadSerialization3

import com.google.gwt.http.client.RequestBuilder; //导入方法依赖的package包/类
public void testBadSerialization3() throws RequestException {
	final boolean[] callbackFired = new boolean[] { false };

	RequestBuilder rb = getService().echoRequestBuilder(
			new MixedSerializable.NonSerializableSub(),
			new AsyncCallback<MixedSerializable>() {
				@Override
				public void onFailure(Throwable caught) {
					assertFalse("callback fired twice", callbackFired[0]);
					callbackFired[0] = true;
				}

				@Override
				public void onSuccess(MixedSerializable result) {
					fail("RPC request should have failed");
				}
			});

	assertFalse(callbackFired[0]); // should fail when send() is called
	rb.send();
	assertTrue(callbackFired[0]); // should have happened now
}
 
开发者ID:jcricket,项目名称:gwt-syncproxy,代码行数:23,代码来源:RunTimeSerializationErrorsTest.java

示例3: testManualSend

import com.google.gwt.http.client.RequestBuilder; //导入方法依赖的package包/类
public void testManualSend() throws RequestException {
	RemoteServiceServletTestServiceAsync service = getAsyncService();

	delayTestFinishForRpc();

	RequestBuilder builder = service
			.testExpectCustomHeader(new AsyncCallback<Void>() {

				@Override
				public void onFailure(Throwable caught) {
					TestSetValidator.rethrowException(caught);
				}

				@Override
				public void onSuccess(Void result) {
					assertTrue(!RemoteServiceServletTest.this.req
							.isPending());
					finishTest();
				}
			});

	builder.setHeader("X-Custom-Header", "true");
	this.req = builder.send();
	assertTrue(this.req.isPending());
}
 
开发者ID:jcricket,项目名称:gwt-syncproxy,代码行数:26,代码来源:RemoteServiceServletTest.java

示例4: sendBatch

import com.google.gwt.http.client.RequestBuilder; //导入方法依赖的package包/类
private void sendBatch(String payload, List<BatchedRequest> currentBatch) {
    // XXX use super.send?
    RequestBuilder builder = createRequestBuilder();
    configureRequestBuilder(builder);

    builder.setRequestData(payload);
    builder.setCallback(createRequestCallbackBatch(currentBatch));

    try {
        wireLogger.finest("Sending fire request");
        builder.send();
    } catch (RequestException e) {
        wireLogger.log(Level.SEVERE, " (" + e.getMessage()
         + ")", e);
    }
}
 
开发者ID:salk31,项目名称:gwt-rf-queue,代码行数:17,代码来源:QosRequestTransport.java

示例5: makeRequest

import com.google.gwt.http.client.RequestBuilder; //导入方法依赖的package包/类
@Override
public Request makeRequest(RequestBuilder builder) {
    try{
        return builder.send();
    } catch(Exception e){
        throw new RuntimeException(e.toString(), e);
    }
}
 
开发者ID:kebernet,项目名称:shortyz,代码行数:9,代码来源:PuzzleServiceProxy.java

示例6: jsonRequest

import com.google.gwt.http.client.RequestBuilder; //导入方法依赖的package包/类
public static void jsonRequest(String baseUrl,
                               String cmd,
                               List<Param> paramList,
                               RequestCallback cb) throws RequestException {
    String url = makeURL(baseUrl, cmd, paramList, false);
    RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, url);
    builder.setCallback(cb);
    builder.send();
}
 
开发者ID:lsst,项目名称:firefly,代码行数:10,代码来源:JsonUtils.java

示例7: sendSourceRequest

import com.google.gwt.http.client.RequestBuilder; //导入方法依赖的package包/类
/**
 * Send a request for source code.
 * 
 * @param callback the {@link RequestCallback} to send
 * @param urlSuffix the URL to target, relative to the Showcase module's base URL.
 */
private void sendSourceRequest(RequestCallback callback, String urlSuffix) {
  // When Super Dev Mode is on, we will load it from the code server, not the original server.
  String url = GWT.getModuleBaseForStaticFiles() + urlSuffix;
  RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, url);
  builder.setCallback(callback);
  try {
    builder.send();
  } catch (RequestException e) {
    callback.onError(null, e);
  }
}
 
开发者ID:Peergos,项目名称:Peergos,代码行数:18,代码来源:ContentWidget.java

示例8: run

import com.google.gwt.http.client.RequestBuilder; //导入方法依赖的package包/类
@Override
public void run() {
    RequestBuilder rq = new RequestBuilder(RequestBuilder.POST, getPingUrl());
    rq.setTimeoutMillis(offlinePingInterval);
    rq.setCallback(OfflineModeEntrypoint.this);
    try {
        logger.info("Sending a ping request to the server.");
        rq.send();
    } catch (Exception e) {
        onError(null, e);
    }
}
 
开发者ID:vaadin,项目名称:touchkit,代码行数:13,代码来源:OfflineModeEntrypoint.java

示例9: send

import com.google.gwt.http.client.RequestBuilder; //导入方法依赖的package包/类
@Override
public Request send(Method method, RequestBuilder builder) throws RequestException {
    builder.setHeader("X-XSRF-TOKEN", Cookies.getCookie("XSRF-TOKEN"));
    setHeaders(builder);
    return builder.send();
}
 
开发者ID:GwtDomino,项目名称:domino,代码行数:7,代码来源:DominoRequestDispatcher.java

示例10: call

import com.google.gwt.http.client.RequestBuilder; //导入方法依赖的package包/类
@Override public Request call(RequestBuilder requestBuilder) {
    try { return requestBuilder.send(); } catch (RequestException e) { throw new RuntimeException(e); }
}
 
开发者ID:intendia-oss,项目名称:autorest,代码行数:4,代码来源:RequestResourceBuilder.java

示例11: send

import com.google.gwt.http.client.RequestBuilder; //导入方法依赖的package包/类
/**
 * Sends the request with its optional parameter(s) (including {@code POST} parameters).
 * 
 * @param callback
 *          The {@code RequestCallback}.
 * @throws ServletRequestException
 *           If an error occurs during request call.
 */
public void send(final RequestCallback callback) throws ServletRequestException {

	final RequestBuilder requestBuilder = new RequestBuilder(requestMethod, urlBuilder.toString());

	requestBuilder.setCallback(callback != null ? callback : Void);

	final StringBuilder builder = new StringBuilder();

	if (ClientUtils.isNotEmpty(requestAttributes)) {

		final Iterator<String> iterator = requestAttributes.keySet().iterator();

		while (iterator.hasNext()) {
			final String next = iterator.next();
			final String attribute = requestAttributes.get(next);

			if (attribute != null) {
				builder.append(URL.encodeQueryString(next));
				builder.append('=');
				builder.append(URL.encodeQueryString(attribute));
				if (iterator.hasNext()) {
					builder.append('&');
				}
			}
		}
	}

	if (isPostMethod()) {
		requestBuilder.setHeader("Content-Type", "application/x-www-form-urlencoded");
		requestBuilder.setRequestData(builder.length() > 0 ? builder.toString() : null);
	}

	try {

		requestBuilder.send();

	} catch (final RequestException e) {
		throw new ServletRequestException("Servlet request '" + builder + "' execution fails.", e);
	}
}
 
开发者ID:sigmah-dev,项目名称:sigmah,代码行数:49,代码来源:ServletRequestBuilder.java

示例12: sendTextToServer

import com.google.gwt.http.client.RequestBuilder; //导入方法依赖的package包/类
private void sendTextToServer() {
    statusLabel.setText("");
    conceptList.clear();

    // don't do anything if we have no text
    final String text = mainTextArea.getText();
    if (text.length() < 1) {
        statusLabel.setText(messages.pleaseEnterTextLabel());
        return;
    }

    // disable interaction while we wait for the response
    glassPanel.setPositionAndShow();

    // build up the AnalysisRequest JSON object
    // start with any options
    final JSONArray options = new JSONArray();
    setSemanticTypesOption(types, options);
    // defaults
    options.set(options.size(), new JSONString("word_sense_disambiguation"));
    options.set(options.size(), new JSONString("composite_phrases 8"));
    options.set(options.size(), new JSONString("no_derivational_variants"));
    options.set(options.size(), new JSONString("strict_model"));
    options.set(options.size(), new JSONString("ignore_word_order"));
    options.set(options.size(), new JSONString("allow_large_n"));
    options.set(options.size(), new JSONString("restrict_to_sources SNOMEDCT_US"));

    final JSONObject analysisRequest = new JSONObject();
    analysisRequest.put("text", new JSONString(text));
    analysisRequest.put("options", options);

    // send the input to the server
    final RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, webserviceUrl);
    builder.setHeader("Content-Type", MediaType.APPLICATION_JSON);
    builder.setRequestData(analysisRequest.toString());

    // create the async callback
    builder.setCallback(new SnomedRequestCallback(conceptList, statusLabel, glassPanel, typeCodeToDescription));

    // send the request
    try { builder.send(); }
    catch (final RequestException e) {
        statusLabel.setText(messages.problemPerformingAnalysisLabel());
        GWT.log("There was a problem performing the analysis: " + e.getMessage(), e);
        glassPanel.hide();
    }
}
 
开发者ID:NICTA,项目名称:t3as-snomedct-service,代码行数:48,代码来源:AnalyseHandler.java


注:本文中的com.google.gwt.http.client.RequestBuilder.send方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。