本文整理汇总了Java中com.google.gwt.http.client.RequestException类的典型用法代码示例。如果您正苦于以下问题:Java RequestException类的具体用法?Java RequestException怎么用?Java RequestException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RequestException类属于com.google.gwt.http.client包,在下文中一共展示了RequestException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCancel
import com.google.gwt.http.client.RequestException; //导入依赖的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.");
}
}
}
示例2: doJsonRequest
import com.google.gwt.http.client.RequestException; //导入依赖的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);
}
}
示例3: init
import com.google.gwt.http.client.RequestException; //导入依赖的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");
}
}
示例4: testBadSerialization3
import com.google.gwt.http.client.RequestException; //导入依赖的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
}
示例5: testManualSend
import com.google.gwt.http.client.RequestException; //导入依赖的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());
}
示例6: testManualSend
import com.google.gwt.http.client.RequestException; //导入依赖的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;
}
});
}
示例7: doStop
import com.google.gwt.http.client.RequestException; //导入依赖的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());
}
}
}
示例8: start
import com.google.gwt.http.client.RequestException; //导入依赖的package包/类
void start(RequestCallback callback) {
// taskRunningCnt++;
// showDebugTask();
// runningList.add(this);
if (_state!= State.START) {
throw new IllegalStateException("Server task must be in the START state to call start(). "+
"Current state: "+ _state+
" You can return to the start state using reset()");
}
_state= State.WORKING;
if(isAutoMask) {
mask();
}
_activeCallback= callback;
try {
// startTime= System.currentTimeMillis();
doTask(callback);
} catch (RequestException e) {
doFailure(e);
}
}
示例9: load
import com.google.gwt.http.client.RequestException; //导入依赖的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();
}
}
示例10: dispatch
import com.google.gwt.http.client.RequestException; //导入依赖的package包/类
private void dispatch(RequestBuilder.Method method, RequestCallback callback) {
ensureHeaders();
// Execute filters on this request
final List<RequestFilter> filters = filterManager.getRequestFilters();
for (RequestFilter filter : filters) {
filter.filter(this);
}
String body = serializePayload();
ServerConnection connection = server.getConnection();
try {
connection.sendRequest(timeout, user, password, headers, method, uri, body, callback);
} catch (final RequestException e) {
throw new RequestDispatchException("It was not possible to dispatch the request.", e);
}
}
示例11: sendRequest
import com.google.gwt.http.client.RequestException; //导入依赖的package包/类
@Override
public void sendRequest(int timeout, @Nullable String user, @Nullable String password, @Nullable Headers headers,
RequestBuilder.Method method, String url, String data, RequestCallback callback)
throws RequestException {
final RequestBuilder requestBuilder = new RequestBuilder(method, url);
if (timeout > 0) requestBuilder.setTimeoutMillis(timeout);
if (user != null) requestBuilder.setUser(user);
if (password != null) requestBuilder.setPassword(password);
if (user != null && password != null) requestBuilder.setIncludeCredentials(true);
if (headers != null) {
for (Header header : headers) {
requestBuilder.setHeader(header.getName(), header.getValue());
}
}
requestBuilder.sendRequest(data, callback);
}
示例12: ajax
import com.google.gwt.http.client.RequestException; //导入依赖的package包/类
private void ajax(final String resource, final String body,
final AjaxCallback callback) {
final boolean has_body = body != null;
final RequestBuilder builder =
new RequestBuilder(has_body ? RequestBuilder.POST : RequestBuilder.GET,
server + resource);
// Doesn't work on Chrome due to ES bug #828.
//if (has_body) {
// builder.setHeader("Content-Type", "application/json");
//}
try {
builder.sendRequest(body, callback);
} catch (RequestException e) {
status.setText("Failed to setup AJAX call to " + server + resource
+ ": " + e);
}
}
示例13: executeSqlRequest
import com.google.gwt.http.client.RequestException; //导入依赖的package包/类
@Override
public void executeSqlRequest(final DatabaseConfigurationDTO configuration,
final int resultLimit,
final String sqlRequest,
final MultipleRequestExecutionMode execMode,
final AsyncRequestCallback<String> asyncRequestCallback)
throws RequestException {
final String url = formatUrl(restServiceContext, ServicePaths.EXECUTE_SQL_REQUEST_PATH, "", null);
final RequestParameterDTO requestParameterDTO = dtoFactory.createDto(RequestParameterDTO.class)
.withDatabase(configuration)
.withResultLimit(resultLimit)
.withSqlRequest(sqlRequest)
.withMultipleRequestExecutionMode(execMode);
final AsyncRequest postRequest = asyncRequestFactory.createPostRequest(url, requestParameterDTO, false);
postRequest.send(asyncRequestCallback);
}
示例14: fetch
import com.google.gwt.http.client.RequestException; //导入依赖的package包/类
@Override
public void fetch() {
try {
datasourceClientService.getAvailableDrivers(new AsyncRequestCallback<String>(new StringUnmarshaller()) {
@Override
protected void onSuccess(String result) {
DriversDTO driversDto = dtoFactory.createDtoFromJson(result, DriversDTO.class);
drivers = driversDto.getDrivers();
eventBus.fireEvent(new JdbcDriversFetchedEvent(drivers));
}
@Override
protected void onFailure(Throwable exception) {
notificationManager.showNotification(new Notification("Failed getting available JDBC drivers from server: "
+ exception.getMessage(), Type.ERROR));
}
});
} catch (RequestException e) {
notificationManager.showNotification(new Notification("Failed getting available JDBC drivers from server: " + e.getMessage(),
Type.ERROR));
}
}
示例15: onClickTestConnectionButton
import com.google.gwt.http.client.RequestException; //导入依赖的package包/类
@Override
public void onClickTestConnectionButton() {
if (getView().isPasswordFieldDirty()) {
try {
service.encryptText(getView().getPassword(), new AsyncRequestCallback<String>(new StringUnmarshaller()) {
@Override
protected void onSuccess(final String encryptedText) {
TextDTO encryptedTextDTO = dtoFactory.createDtoFromJson(encryptedText, TextDTO.class);
getView().setEncryptedPassword(encryptedTextDTO.getValue(), false);
doOnClickTestConnectionButton();
}
@Override
protected void onFailure(Throwable exception) {
Log.error(DefaultNewDatasourceConnectorViewImpl.class, exception);
}
});
} catch (RequestException e2) {
Log.error(DefaultNewDatasourceConnectorViewImpl.class, e2);
}
}
else {
doOnClickTestConnectionButton();
}
}