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


Java RequestCallback类代码示例

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

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

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

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

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

示例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);
    }
}
 
开发者ID:growbit,项目名称:turbogwt-http,代码行数:20,代码来源:RequestImpl.java

示例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);
}
 
开发者ID:growbit,项目名称:turbogwt-http,代码行数:17,代码来源:ServerConnectionImpl.java

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

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

}
 
开发者ID:inepex,项目名称:ineform,代码行数:20,代码来源:RestDataConnectorComplexTest.java

示例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;
		}
	});
}
 
开发者ID:geomajas,项目名称:geomajas-project-client-gwt2,代码行数:19,代码来源:AbstractWfsServiceTest.java

示例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);
    }
}
 
开发者ID:YoungDigitalPlanet,项目名称:empiria.player,代码行数:8,代码来源:RequestWrapper.java

示例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);
}
 
开发者ID:YoungDigitalPlanet,项目名称:empiria.player,代码行数:10,代码来源:SynchronousScriptsLoader.java

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


}-*/;
 
开发者ID:kebernet,项目名称:shortyz,代码行数:16,代码来源:ShortyzGadget.java

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

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


}-*/;
 
开发者ID:kebernet,项目名称:shortyz,代码行数:16,代码来源:ShortyzWave.java

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


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