本文整理汇总了Java中com.google.gwt.http.client.Request类的典型用法代码示例。如果您正苦于以下问题:Java Request类的具体用法?Java Request怎么用?Java Request使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Request类属于com.google.gwt.http.client包,在下文中一共展示了Request类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: shouldFireOnLoad_afterLastScriptLoaded
import com.google.gwt.http.client.Request; //导入依赖的package包/类
@Test
public void shouldFireOnLoad_afterLastScriptLoaded() {
// given
ScriptUrl[] scripts = new ScriptUrl[]{firstScript, secondScript};
Request request = mock(Request.class);
Response response = mock(Response.class);
when(response.getText()).thenReturn(RESPONSE_TEXT);
// when
testObj.injectScripts(scripts, synchronousScriptsCallback);
verify(requestWrapper).get(eq(FIRST_SCRIPT_URL), requestCallbackCaptor.capture());
RequestCallback requestCallback = requestCallbackCaptor.getValue();
requestCallback.onResponseReceived(request, response);
// then
verify(scriptInjectorWrapper).fromString(RESPONSE_TEXT);
verify(requestWrapper).get(SECOND_SCRIPT_URL, requestCallback);
requestCallback.onResponseReceived(request, response);
verify(synchronousScriptsCallback).onLoad();
}
示例2: getErrorCallback
import com.google.gwt.http.client.Request; //导入依赖的package包/类
protected RestErrorCallback getErrorCallback() {
return new RestErrorCallback() {
@Override
public boolean error(Request request, Throwable throwable) {
autoMessageBox.hide();
String message = "";
int defaultCodeError = Response.SC_NOT_MODIFIED;
try {
throw throwable;
} catch (ResponseException e) {
Response response = e.getResponse();
message = response.getStatusText();
defaultCodeError = response.getStatusCode();
} catch (Throwable t) {
message = t.getMessage();
}
messageDialogBuilder.createError(UIMessages.INSTANCE.warning() + " " + defaultCodeError, message).show();
return false;
}
};
}
示例3: getErrorCallback
import com.google.gwt.http.client.Request; //导入依赖的package包/类
private RestErrorCallback getErrorCallback() {
return new RestErrorCallback() {
@Override
public boolean error(Request request, Throwable throwable) {
autoMessageBox.hide();
String message = "";
int defaultCodeError = Response.SC_NOT_MODIFIED;
try {
throw throwable;
} catch (ResponseException e) {
Response response = e.getResponse();
message = response.getStatusText();
defaultCodeError = response.getStatusCode();
} catch (Throwable t) {
message = t.getMessage();
}
messageDialogBuilder.createError(UIMessages.INSTANCE.warning() + " " + defaultCodeError, message).show();
return false;
}
};
}
示例4: doJsonRequest
import com.google.gwt.http.client.Request; //导入依赖的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);
}
}
示例5: onResponseReceived
import com.google.gwt.http.client.Request; //导入依赖的package包/类
@Override
public void onResponseReceived(Request request, Response response) {
String text = response.getText();
PopupPanel popup = new PopupPanel(true);
popup.add(new HTML("<strong>Saved edits for:<p></p></strong>"+text+"<p></p>Click outside box to dismiss."));
popup.setPopupPosition(200, Window.getClientHeight()/3);
popup.show();
CellFormatter formatter = datatable.getCellFormatter();
for (Iterator dirtyIt = dirtyrows.keySet().iterator(); dirtyIt.hasNext();) {
Integer widgetrow = (Integer) dirtyIt.next();
for (int i = 0; i < headers.length; i++) {
formatter.removeStyleName(widgetrow, i, "dirty");
}
CheckBox box = (CheckBox) datatable.getWidget(widgetrow, 0);
box.setValue(false);
}
dirtyrows.clear();
}
示例6: testBadSerialization2
import com.google.gwt.http.client.Request; //导入依赖的package包/类
public void testBadSerialization2() {
final boolean[] callbackFired = new boolean[] { false };
Request req = getService().echoRequest(
new MixedSerializable.NonSerializableSub(),
new AsyncCallback<MixedSerializable>() {
@Override
public void onFailure(Throwable caught) {
callbackFired[0] = true;
}
@Override
public void onSuccess(MixedSerializable result) {
fail("RPC request should have failed");
}
});
assertTrue(callbackFired[0]); // should have happened synchronously
assertFalse(req.isPending());
req.cancel();
}
示例7: listPuzzles
import com.google.gwt.http.client.Request; //导入依赖的package包/类
@Override
public Request listPuzzles(final AsyncCallback<PuzzleDescriptor[]> callback) {
return super.listPuzzles( new AsyncCallback<PuzzleDescriptor[]>(){
@Override
public void onFailure(Throwable caught) {
if(caught instanceof InvocationException){
RetryLocalStorageServiceProxy.super.listPuzzles(callback);
} else {
callback.onFailure(caught);
}
}
@Override
public void onSuccess(PuzzleDescriptor[] result) {
callback.onSuccess(result);
}
});
}
示例8: savePuzzle
import com.google.gwt.http.client.Request; //导入依赖的package包/类
@Override
public Request savePuzzle(final Long listingId, final Puzzle puzzle, final AsyncCallback callback) {
if(!WindowContext.INSTANCE.isInitialized()){
WindowContext.INSTANCE.initialize( new WindowContextCallback(){
@Override
public void onInitialized() {
saveInternal(listingId, puzzle, callback);
}
});
} else {
saveInternal(listingId, puzzle, callback);
}
return new FakeRequest();
}
示例9: doStop
import com.google.gwt.http.client.Request; //导入依赖的package包/类
public void doStop() {
for (TabItem item : advanced.getItems()) {
final CIModel model = (CIModel)item.getData("model");
// Do a HTTP request..
RequestBuilder req = new RequestBuilder(RequestBuilder.GET, getStopURL(model));
try {
Info.display("Stop", "Send stop to " + model.getDisplayName());
req.sendRequest(null, new RequestCallback() {
public void onResponseReceived(Request request, Response response) {
Info.display("Stop", "COMPLETED. Stop sent to " + model.getDisplayName());
}
public void onError(Request arg0, Throwable arg1) {
Info.display("Stop", "FAILED. to stop " + model.getDisplayName());
}
});
} catch (RequestException e) {
Info.display("Stop", "ERROR. to stop " + model.getDisplayName());
}
}
}
示例10: doInvoke
import com.google.gwt.http.client.Request; //导入依赖的package包/类
@Override
protected <T> Request doInvoke(ResponseReader responseReader, final String methodName, RpcStatsContext statsContext, String requestData, final AsyncCallback<T> callback) {
return super.doInvoke(responseReader, methodName, statsContext, requestData, new AsyncCallback<T>() {
@Override
public void onFailure(Throwable caught) {
UniTimeNotifications.error("Request " + methodName.replace("_Proxy", "") + " failed: " + caught.getMessage(), caught);
callback.onFailure(caught);
}
@Override
public void onSuccess(T result) {
callback.onSuccess(result);
}
});
}
示例11: lodaDataFromURL
import com.google.gwt.http.client.Request; //导入依赖的package包/类
private void lodaDataFromURL(final String url) {
final String urlBase = GWT.getHostPageBaseURL() + "gwtOpenLayersProxy";
try {
autoMessageBox.show();
RestClient.create(URLFileRestService.class, urlBase,
new RemoteCallback<String>() {
@Override
public void callback(String response) {
parseCsvData(response);
autoMessageBox.hide();
}
}, new RestErrorCallback() {
@Override
public boolean error(Request message,
Throwable throwable) {
autoMessageBox.hide();
showAlert("Error"
+ UIMessages.INSTANCE.unexpectedError());
return false;
}
}, Response.SC_OK).getContent(url);
} catch (Exception e) {
autoMessageBox.hide();
showAlert("Error loading data..." + e.getMessage());
}
}
示例12: createLayerFromURL
import com.google.gwt.http.client.Request; //导入依赖的package包/类
protected void createLayerFromURL() {
final ProgressBarDialog autoMessageBox = new ProgressBarDialog(false,
UIMessages.INSTANCE.processing());
try {
autoMessageBox.show();
RestClient.create(URLFileRestService.class, URL_BASE,
new RemoteCallback<String>() {
@Override
public void callback(String response) {
final VectorLayerConfig layerConfig = getVectorLayerConfig();
layerConfig.setGeoDataString(response);
VectorLayer layer = VectorLayerFactory
.createVectorLayerFromGeoData(layerConfig);
LayerLoader.load(layer);
autoMessageBox.hide();
}
}, new RestErrorCallback() {
@Override
public boolean error(Request message,
Throwable throwable) {
autoMessageBox.hide();
showDialog("Error",
UIMessages.INSTANCE.unexpectedError());
return false;
}
}, Response.SC_OK).getContent(getUrl());
} catch (Exception e) {
autoMessageBox.hide();
showDialog(
UIMessages.INSTANCE.errorLoadingLayer(getVectorLayerConfig()
.getLayerName()),
UIMessages.INSTANCE.unexpectedError());
}
}
示例13: getRequestRegisteredPoint
import com.google.gwt.http.client.Request; //导入依赖的package包/类
private void getRequestRegisteredPoint(final VehicleJSO vehicle, final String startDate, final String endDate) {
autoMessageBox.setProgressStatusMessage(UISgfMessages.INSTANCE.getGPSData());
RestClient.create(SGFRegisteredPointService.class, SGFServiceInfo.getURL(),
new RemoteCallback<String>() {
@Override
public void callback(String pointRegisterListResponseJson) {
PointRegisterListResponseJSO pointRegisterResponse = JsonUtils
.safeEval(pointRegisterListResponseJson);
PointRegisterJSO[] pointRegisters = pointRegisterResponse
.getPointRegisterListEmbededJSO().getPointRegister();
List<PointRegisterJSO> points = Arrays.asList(pointRegisters);
if(points.isEmpty()) {
messageDialogBuilder.createInfo(UIMessages.INSTANCE.edtAlertDialogTitle(), UISgfMessages.INSTANCE.gpsDataNotFound()).show();
return;
}
createRouteLayer(vehicle, startDate, points);
autoMessageBox.hide();
}
},
new RestErrorCallback() {
@Override
public boolean error(Request message, Throwable throwable) {
autoMessageBox.hide();
messageDialogBuilder.createInfo(UISgfMessages.INSTANCE.errorDetected(), throwable.getMessage()).show();
return false;
}
}, Response.SC_OK).getRegisteredPoints(session.getToken(), vehicle.getId(), startDate, endDate, REGISTERED_POINTS_TO_LOAD, "date,desc");
}
示例14: loadVehicles
import com.google.gwt.http.client.Request; //导入依赖的package包/类
private void loadVehicles(String token, int companyId) {
autoMessageBox = new ProgressBarDialog(false,
UIMessages.INSTANCE.processing());
autoMessageBox.show();
RestClient.create(SGFVehicleService.class, SGFServiceInfo.getURL(),
new RemoteCallback<String>() {
@Override
public void callback(String vehicleListResponseJson) {
VehicleListResponseJSO vehicleListResponse = JsonUtils
.safeEval(vehicleListResponseJson);
List<VehicleJSO> vehicles = Arrays
.asList(vehicleListResponse
.getVehicleListEmbededJSO()
.getVehicles());
vehicleDialog.setVehicle(vehicles);
autoMessageBox.hide();
vehicleDialog.show();
}
},
new RestErrorCallback() {
@Override
public boolean error(Request message, Throwable throwable) {
autoMessageBox.hide();
messageDialogBuilder.createInfo(
UISgfMessages.INSTANCE.errorDetected(),
throwable.getMessage()).show();
return false;
}
}, Response.SC_OK).get(token, companyId, 100, "id");
}
示例15: getErrorCallback
import com.google.gwt.http.client.Request; //导入依赖的package包/类
private RestErrorCallback getErrorCallback() {
return new RestErrorCallback() {
@Override
public boolean error(Request request, Throwable throwable) {
autoMessageBox.hide();
String message = "";
int defaultCodeError = Response.SC_NOT_MODIFIED;
try {
throw throwable;
} catch (ResponseException e) {
Response response = e.getResponse();
message = response.getStatusText();
defaultCodeError = response.getStatusCode();
} catch (Throwable t) {
message = t.getMessage();
}
messageDialogBuilder.createError(
UIMessages.INSTANCE.warning() + " " + defaultCodeError,
message).show();
return false;
}
};
}