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


Java Request类代码示例

本文整理汇总了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();
}
 
开发者ID:YoungDigitalPlanet,项目名称:empiria.player,代码行数:22,代码来源:SynchronousScriptsLoaderTest.java

示例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;
		}
	};
}
 
开发者ID:geowe,项目名称:sig-seguimiento-vehiculos,代码行数:26,代码来源:AbstractGitHubGetListRequest.java

示例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;
		}
	};
}
 
开发者ID:geowe,项目名称:sig-seguimiento-vehiculos,代码行数:26,代码来源:GitHubGetRepositoryListRequest.java

示例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);
   }
}
 
开发者ID:openremote,项目名称:WebConsole,代码行数:29,代码来源:JSONControllerConnector.java

示例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();
}
 
开发者ID:NOAA-PMEL,项目名称:LAS,代码行数:20,代码来源:ColumnEditorWidget.java

示例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();
}
 
开发者ID:jcricket,项目名称:gwt-syncproxy,代码行数:22,代码来源:RunTimeSerializationErrorsTest.java

示例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);
        }

    });
}
 
开发者ID:kebernet,项目名称:shortyz,代码行数:21,代码来源:RetryLocalStorageServiceProxy.java

示例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();
}
 
开发者ID:kebernet,项目名称:shortyz,代码行数:18,代码来源:LocalStorageServiceProxy.java

示例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());
	 } 
 }
}
 
开发者ID:luox12,项目名称:onecmdb,代码行数:26,代码来源:MDRStartWidget.java

示例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);
		}
	});
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:15,代码来源:GwtRpcProxy.java

示例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());
	}
}
 
开发者ID:geowe,项目名称:sig-seguimiento-vehiculos,代码行数:28,代码来源:JoinDataTool.java

示例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());
	}
}
 
开发者ID:geowe,项目名称:sig-seguimiento-vehiculos,代码行数:36,代码来源:URLVectorLayerDef.java

示例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");			
}
 
开发者ID:geowe,项目名称:sig-seguimiento-vehiculos,代码行数:39,代码来源:RouteVehicleTool.java

示例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");
}
 
开发者ID:geowe,项目名称:sig-seguimiento-vehiculos,代码行数:38,代码来源:VehicleTool.java

示例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;
		}
	};
}
 
开发者ID:geowe,项目名称:sig-seguimiento-vehiculos,代码行数:28,代码来源:GitHubCreateFileExporter.java


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