本文整理汇总了Java中com.google.gwt.http.client.RequestCallback类的典型用法代码示例。如果您正苦于以下问题:Java RequestCallback类的具体用法?Java RequestCallback怎么用?Java RequestCallback使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RequestCallback类属于com.google.gwt.http.client包,在下文中一共展示了RequestCallback类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: shouldFireOnLoad_afterLastScriptLoaded
import com.google.gwt.http.client.RequestCallback; //导入依赖的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: doStop
import com.google.gwt.http.client.RequestCallback; //导入依赖的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());
}
}
}
示例3: start
import com.google.gwt.http.client.RequestCallback; //导入依赖的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);
}
}
示例4: load
import com.google.gwt.http.client.RequestCallback; //导入依赖的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();
}
}
示例5: dispatch
import com.google.gwt.http.client.RequestCallback; //导入依赖的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);
}
}
示例6: sendRequest
import com.google.gwt.http.client.RequestCallback; //导入依赖的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);
}
示例7: prepareRequestBuilder
import com.google.gwt.http.client.RequestCallback; //导入依赖的package包/类
private void prepareRequestBuilder(
RequestBuilder requestBuilder,
String responseText,
int statusCode) throws Exception {
final Response response = mock(Response.class);
when(response.getStatusCode()).thenReturn(statusCode);
when(response.getText()).thenReturn(responseText);
when(requestBuilder.sendRequest(anyString(), any(RequestCallback.class)))
.thenAnswer(new Answer<Request>() {
@Override
public Request answer(InvocationOnMock invocation) throws Throwable {
((RequestCallback) invocation.getArguments()[1])
.onResponseReceived(null, response);
return null;
}
});
}
示例8: createRequest
import com.google.gwt.http.client.RequestCallback; //导入依赖的package包/类
@Test
public void createRequest() throws Exception {
prepareRequestBuilder(requestBuilder, response.replace("'", "\""), 200);
restDataConnector.objectCreateOrEditRequested(testKvo, callback);
ArgumentCaptor<String> argument = ArgumentCaptor.forClass(String.class);
verify(requestBuilder).sendRequest(argument.capture(), any(RequestCallback.class));
Assert.assertEquals(response, argument.getValue());
ArgumentCaptor<ObjectManipulationActionResult> omrCapture = ArgumentCaptor
.forClass(ObjectManipulationActionResult.class);
verify(callback).onManipulationResult(omrCapture.capture());
TestUtil.assertEquals(
testKvo,
omrCapture.getValue().getObjectsNewState(),
TestUtil.descriptorStore);
}
示例9: prepareResponse
import com.google.gwt.http.client.RequestCallback; //导入依赖的package包/类
protected void prepareResponse(String resource) throws Exception {
capabilitiesXml = IOUtils.toString(this.getClass().getResourceAsStream(resource), "UTF-8");
DOMParser parser = new DOMParser();
parser.parse(new InputSource(new StringReader(capabilitiesXml)));
capabilitiesDoc = w3cToGoogle(parser.getDocument());
final Response response = mock(Response.class);
when(response.getStatusCode()).thenReturn(200);
when(response.getText()).thenReturn(capabilitiesXml);
when(requestBuilder.sendRequest(anyString(), any(RequestCallback.class))).thenAnswer(new Answer<Request>() {
@Override
public Request answer(InvocationOnMock invocation) throws Throwable {
((RequestCallback) invocation.getArguments()[1]).onResponseReceived(null, response);
return null;
}
});
}
示例10: get
import com.google.gwt.http.client.RequestCallback; //导入依赖的package包/类
public void get(String url, RequestCallback callback) {
try {
new RequestBuilder(RequestBuilder.GET, url).sendRequest("", callback);
} catch (RequestException e) {
logger.error(e);
}
}
示例11: injectScripts
import com.google.gwt.http.client.RequestCallback; //导入依赖的package包/类
public void injectScripts(ScriptUrl[] scripts, SynchronousScriptsCallback callback) {
Stack<ScriptUrl> scriptsStack = new Stack<>();
Collections.addAll(scriptsStack, scripts);
Collections.reverse(scriptsStack);
RequestCallback nextScriptLoaderCallback = createNextScriptLoaderCallback(scriptsStack, callback);
injectScript(scriptsStack, nextScriptLoaderCallback);
}
示例12: makePostRequest
import com.google.gwt.http.client.RequestCallback; //导入依赖的package包/类
public static native void makePostRequest(String url, String postdata,
RequestCallback callback) /*-{
var response = function(obj) {
@com.totsp.crossword.web.gadget.ShortyzGadget::onSuccessInternal(Lcom/totsp/crossword/web/client/GadgetResponse;Lcom/google/gwt/http/client/RequestCallback;)(obj, callback);
};
var params = {};
params[$wnd.gadgets.io.RequestParameters.HEADERS] = {
"Content-Type": "text/x-gwt-rpc"
};
params[$wnd.gadgets.io.RequestParameters.METHOD] = $wnd.gadgets.io.MethodType.POST;
params[$wnd.gadgets.io.RequestParameters.POST_DATA]= postdata;
$wnd.gadgets.io.makeRequest(url, response, params);
}-*/;
示例13: onSuccessInternal
import com.google.gwt.http.client.RequestCallback; //导入依赖的package包/类
static void onSuccessInternal(final GadgetResponse response,
RequestCallback callback) {
try {
callback.onResponseReceived(null, new FakeResponse(response));
} catch (Exception e) {
callback.onError(null, e);
}
}
示例14: makePostRequest
import com.google.gwt.http.client.RequestCallback; //导入依赖的package包/类
public static native void makePostRequest(String url, String postdata,
RequestCallback callback) /*-{
var response = function(obj) {
@com.totsp.crossword.web.wave.ShortyzWave::onSuccessInternal(Lcom/totsp/crossword/web/client/GadgetResponse;Lcom/google/gwt/http/client/RequestCallback;)(obj, callback);
};
var params = {};
params[$wnd.gadgets.io.RequestParameters.HEADERS] = {
"Content-Type": "text/x-gwt-rpc"
};
params[$wnd.gadgets.io.RequestParameters.METHOD] = $wnd.gadgets.io.MethodType.POST;
params[$wnd.gadgets.io.RequestParameters.POST_DATA]= postdata;
$wnd.gadgets.io.makeRequest(url, response, params);
}-*/;
示例15: jsonRequest
import com.google.gwt.http.client.RequestCallback; //导入依赖的package包/类
public static void jsonRequest(String baseUrl,
String cmd,
List<Param> paramList,
RequestCallback cb) throws RequestException {
String url = makeURL(baseUrl, cmd, paramList, false);
RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, url);
builder.setCallback(cb);
builder.send();
}