本文整理汇总了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);
}
}
示例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
}
示例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());
}
示例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);
}
}
示例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);
}
}
示例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();
}
示例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);
}
}
示例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);
}
}
示例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();
}
示例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); }
}
示例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);
}
}
示例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();
}
}