KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > google > gwt > user > client > HTTPRequest


1 /*
2  * Copyright 2006 Google Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5  * use this file except in compliance with the License. You may obtain a copy of
6  * the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13  * License for the specific language governing permissions and limitations under
14  * the License.
15  */

16 package com.google.gwt.user.client;
17
18 import com.google.gwt.core.client.GWT;
19 import com.google.gwt.user.client.impl.HTTPRequestImpl;
20
21 /**
22  * This class allows you to make asynchronous HTTP requests to the originating
23  * server.
24  */

25 public class HTTPRequest {
26
27   private static final HTTPRequestImpl httpRequest = (HTTPRequestImpl) GWT.create(HTTPRequestImpl.class);
28
29   /**
30    * Makes an asynchronous HTTP GET to a remote server.
31    *
32    * @param url the absolute url to GET
33    * @param handler the response handler to be notified when either the request
34    * fails, or is completed successfully
35    * @return <code>false</code> if the invocation fails to issue
36    */

37   public static boolean asyncGet(String JavaDoc url, ResponseTextHandler handler) {
38     return httpRequest.asyncGet(url, handler);
39   }
40
41   /**
42    * Makes an asynchronous HTTP GET to a remote server.
43    *
44    * @param url the absolute url to GET
45    * @param handler the response handler to be notified when either the request
46    * fails, or is completed successfully
47    * @return <code>false</code> if the invocation fails to issue
48    */

49   public static boolean asyncGet(String JavaDoc user, String JavaDoc pwd, String JavaDoc url,
50       ResponseTextHandler handler) {
51     return httpRequest.asyncGet(user, pwd, url, handler);
52   };
53
54   /**
55    * Makes an asynchronous HTTP POST to a remote server.
56    *
57    * @param url the absolute url to which the POST data is delivered
58    * @param postData the data to post
59    * @param handler the response handler to be notified when either the request
60    * fails, or is completed successfully
61    * @return <code>false</code> if the invocation fails to issue
62    */

63   public static boolean asyncPost(String JavaDoc url, String JavaDoc postData,
64       ResponseTextHandler handler) {
65     return httpRequest.asyncPost(url, postData, handler);
66   }
67
68   /**
69    * Makes an asynchronous HTTP POST to a remote server.
70    *
71    * @param url the absolute url to which the POST data is delivered
72    * @param postData the data to post
73    * @param handler the response handler to be notified when either the request
74    * fails, or is completed successfully
75    * @return <code>false</code> if the invocation fails to issue
76    */

77   public static boolean asyncPost(String JavaDoc user, String JavaDoc pwd, String JavaDoc url,
78       String JavaDoc postData, ResponseTextHandler handler) {
79     return httpRequest.asyncPost(user, pwd, url, postData, handler);
80   };
81 }
82
Popular Tags