當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。