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


Java RequestBuilder类代码示例

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


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

示例1: onCancel

import com.google.gwt.http.client.RequestBuilder; //导入依赖的package包/类
@Override
public void onCancel(CancelEvent event) {
	if (event.getID().equals("Correlation")) {
		currentURL = currentURL + "&cancel=true";
		RequestBuilder sendRequest = new RequestBuilder(
				RequestBuilder.GET, currentURL);
		try {

			lasAnnotationsPanel
					.setError("Fetching plot annotations...");
			sendRequest.sendRequest(null, lasRequestCallback);
		} catch (RequestException e) {
			Window.alert("Unable to cancel request.");
		}
	}
}
 
开发者ID:NOAA-PMEL,项目名称:LAS,代码行数:17,代码来源:Correlation.java

示例2: 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

示例3: onCancel

import com.google.gwt.http.client.RequestBuilder; //导入依赖的package包/类
@Override
public void onCancel(CancelEvent event) {
    if (event.getID().equals(ID)) {
        currentURL = currentURL + "&cancel=true";
        RequestBuilder sendRequest = new RequestBuilder(RequestBuilder.GET, currentURL);
        try {

            lasAnnotationsPanel.setError("Fetching plot annotations...");
            updating = true;
            // sendRequest.sendRequest(null, 33Callback);
            // Using LASRequestEvent Controller so a cancel in one
            // OutputPanel cancels related requests too
            LASRequestEvent lasRequestEvent = new LASRequestEvent(sendRequest, "lasRequestCallback", getName());
            eventBus.fireEventFromSource(lasRequestEvent, thisOutputPanel);
            // } catch (RequestException e) {
        } catch (Exception e) {
            Window.alert("Unable to cancel request.");
        }
    }
}
 
开发者ID:NOAA-PMEL,项目名称:LAS,代码行数:21,代码来源:OutputPanel.java

示例4: init

import com.google.gwt.http.client.RequestBuilder; //导入依赖的package包/类
public void init(LASRequest request, String cruiseid) {
  	message.setVisible(false);
  	request.setOperation("Cruise_List", "v7");
  	List<Map<String, String>> c = request.getVariableConstraints();
  	for (Iterator cIt = c.iterator(); cIt.hasNext();) {
	Map<String, String> map = (Map<String, String>) cIt.next();
	String varid = map.get("varID");
	if ( varid.equals(cruiseid)) {
		
	} else {
		
	}
}
String url = Util.getProductServer()+"?xml="+URL.encode(request.toString());
  	RequestBuilder sendRequest = new RequestBuilder(RequestBuilder.GET, UriUtils.sanitizeUri(url));
try {
	sendRequest.sendRequest(null, iconListRequestCallback);
} catch (RequestException e) {
	message.setVisible(true);
	message.setHTML("Unable to icon list");
}
  }
 
开发者ID:NOAA-PMEL,项目名称:LAS,代码行数:23,代码来源:CruiseIconWidget.java

示例5: setRequestBuilder

import com.google.gwt.http.client.RequestBuilder; //导入依赖的package包/类
/**
 * @param requestBuilder
 *            the requestBuilder to set
 */
void setRequestBuilder(RequestBuilder requestBuilder) {
	this.requestBuilder = requestBuilder;
	this.url = this.requestBuilder.getUrl();
	String httpMethod = this.requestBuilder.getHTTPMethod();
	if (RequestBuilder.GET.toString().equalsIgnoreCase(httpMethod)) {
		this.method = RequestBuilder.GET;
	} else if (RequestBuilder.POST.toString().equalsIgnoreCase(httpMethod)) {
		this.method = RequestBuilder.POST;
	} else if (RequestBuilder.DELETE.toString().equalsIgnoreCase(httpMethod)) {
		this.method = RequestBuilder.DELETE;
	} else if (RequestBuilder.HEAD.toString().equalsIgnoreCase(httpMethod)) {
		this.method = RequestBuilder.HEAD;
	} else if (RequestBuilder.PUT.toString().equalsIgnoreCase(httpMethod)) {
		this.method = RequestBuilder.PUT;
	}
}
 
开发者ID:NOAA-PMEL,项目名称:LAS,代码行数:21,代码来源:LASRequestEvent.java

示例6: 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

示例7: 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

示例8: testManualSend

import com.google.gwt.http.client.RequestBuilder; //导入依赖的package包/类
public void testManualSend() throws RequestException {
	fail("Request Builder Not Supported");
	final RemoteServiceServletTestServiceAsync service = getAsyncService();

	delayTestFinishForRpc();

	setTask(new AsyncTask<Void, Void, Void>() {

		@Override
		protected Void doInBackground(Void... arg0) {
			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");
			try {
				RemoteServiceServletTest.this.req = builder.send();
			} catch (RequestException e) {
				throw new RuntimeException(e);
			}
			assertTrue(RemoteServiceServletTest.this.req.isPending());
			return null;
		}
	});
}
 
开发者ID:jcricket,项目名称:gwt-syncproxy,代码行数:37,代码来源:RemoteServiceServletTest.java

示例9: shouldEncodeUrlAndUpdateProject

import com.google.gwt.http.client.RequestBuilder; //导入依赖的package包/类
@Test
public void shouldEncodeUrlAndUpdateProject() {
  when(requestFactory.createRequest(
          any(RequestBuilder.Method.class), anyString(), any(ProjectConfig.class), anyBoolean()))
      .thenReturn(asyncRequest);
  when(prjConfig1.getPath()).thenReturn(TEXT);

  client.updateProject(prjConfig1);

  verify(requestFactory).createRequest(eq(PUT), anyString(), eq(prjConfig1), eq(false));
  verify(asyncRequest).header(CONTENT_TYPE, APPLICATION_JSON);
  verify(asyncRequest).header(ACCEPT, APPLICATION_JSON);
  verify(loaderFactory).newLoader("Updating project...");
  verify(asyncRequest).loader(messageLoader);
  verify(unmarshaller).newUnmarshaller(ProjectConfigDto.class);
  verify(asyncRequest).send(unmarshallablePrjConf);
}
 
开发者ID:eclipse,项目名称:che,代码行数:18,代码来源:ProjectServiceClientTest.java

示例10: doStop

import com.google.gwt.http.client.RequestBuilder; //导入依赖的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

示例11: BoshConnector

import com.google.gwt.http.client.RequestBuilder; //导入依赖的package包/类
public BoshConnector(Context context) {
	super(context);

	String u = context.getSessionObject().getProperty(AbstractBoshConnector.BOSH_SERVICE_URL_KEY);

	Boolean ignoreServerHost = context.getSessionObject().getProperty(BOSH_IGNORE_SERVER_HOST);
	if (ignoreServerHost == null || !ignoreServerHost) {
		// if we support change of destination by host attribute sent by server
		// then parse url to get current hostname
		MatchResult result = URL_PARSER.exec(u);
		host = result.getGroup(2);
	}
	requestBuilder = new RequestBuilder(RequestBuilder.POST, u);
	// in Chrome following line causes error (Connection: close is not
	// allowed in new spec)
	// requestBuilder.setHeader("Connection", "close");
}
 
开发者ID:horsefaced,项目名称:jaxmpp-android,代码行数:18,代码来源:BoshConnector.java

示例12: doFinish

import com.google.gwt.http.client.RequestBuilder; //导入依赖的package包/类
@Override
protected void doFinish(RequestBuilder rb) {
    super.doFinish(rb);

    if (checkUserInfo) {
        String userToken = Cookies.getCookie(LoginManagerImpl.COOKIE_USER_KEY);
        userToken = userToken == null ? "" : userToken.replaceAll("\"", "");
        String user = userToken.contains("/") ? userToken.split("/", 2)[1] : null;
        LoginManager loginManager= Application.getInstance().getLoginManager();
        if (user != null && loginManager!=null && loginManager.getLoginInfo()!=null) {
            if (!loginManager.getLoginInfo().getLoginName().equals(user)) {
                loginManager.refreshUserInfo(true);
            }
        }
    }
}
 
开发者ID:lsst,项目名称:firefly,代码行数:17,代码来源:ServiceLocator.java

示例13: load

import com.google.gwt.http.client.RequestBuilder; //导入依赖的package包/类
public void load(String url, final String regionName) {
    RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, url);
    try {
        builder.sendRequest(null, new RequestCallback(){
            public void onResponseReceived(com.google.gwt.http.client.Request req, Response res) {
                updateHtml(res.getText(), regionName);
            }

            public void onError(com.google.gwt.http.client.Request request, Throwable exception) {
            }
        });
    } catch (RequestException e) {
        e.printStackTrace();
    }

}
 
开发者ID:lsst,项目名称:firefly,代码行数:17,代码来源:HtmlRegionLoader.java

示例14: requestLogout

import com.google.gwt.http.client.RequestBuilder; //导入依赖的package包/类
public Cancellable requestLogout(final Callback<XMLHttpRequest, XMLHttpRequest> aCallback) throws Exception {
	String query = param(PlatypusHttpRequestParams.TYPE, String.valueOf(Requests.rqLogout));
	return startApiRequest(null, query, null, RequestBuilder.GET, null, new CallbackAdapter<XMLHttpRequest, XMLHttpRequest>() {

		@Override
		protected void doWork(XMLHttpRequest aResult) throws Exception {
			principal = null;
			aCallback.onSuccess(aResult);
		}

		@Override
		public void onFailure(XMLHttpRequest reason) {
			aCallback.onFailure(reason);
		}

	});
}
 
开发者ID:marat-gainullin,项目名称:platypus-js,代码行数:18,代码来源:AppClient.java

示例15: startDownloadRequest

import com.google.gwt.http.client.RequestBuilder; //导入依赖的package包/类
public void startDownloadRequest(String aUrlPrefix, final int aRequestType, Map<String, String> aParams, RequestBuilder.Method aMethod) throws Exception {
	final Frame frame = new Frame();
	frame.setVisible(false);

	frame.addLoadHandler(new LoadHandler() {

		@Override
		public void onLoad(LoadEvent event) {
			Timer timer = new Timer() {

				@Override
				public void run() {
					frame.removeFromParent();
				}
			};
			timer.schedule(2000);
		}
	});
	String query = "";
	for (Map.Entry<String, String> ent : aParams.entrySet()) {
		query += param(ent.getKey(), ent.getValue()) + "&";
	}
	query += param(PlatypusHttpRequestParams.TYPE, String.valueOf(aRequestType));
	frame.setUrl(apiUrl + aUrlPrefix + "?" + query);
	RootPanel.get().add(frame);
}
 
开发者ID:marat-gainullin,项目名称:platypus-js,代码行数:27,代码来源:AppClient.java


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