本文整理汇总了Java中com.google.gwt.http.client.RequestBuilder.POST属性的典型用法代码示例。如果您正苦于以下问题:Java RequestBuilder.POST属性的具体用法?Java RequestBuilder.POST怎么用?Java RequestBuilder.POST使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.google.gwt.http.client.RequestBuilder
的用法示例。
在下文中一共展示了RequestBuilder.POST属性的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setRequestBuilder
/**
* @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;
}
}
示例2: BoshConnector
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");
}
示例3: buildMultipart
private RequestBuilder buildMultipart( String name, String value )
{
String boundary = "AJAX------" + Math.random() + "" + new Date().getTime();
RequestBuilder builderPost = new RequestBuilder( RequestBuilder.POST, url );
builderPost.setHeader( "Content-Type", "multipart/form-data; charset=utf-8; boundary=" + boundary );
builderPost.setCallback( requestCallback );
String CRLF = "\r\n";
String data = "--" + boundary + CRLF;
data += "--" + boundary + CRLF;
data += "Content-Disposition: form-data; ";
data += "name=\"" + name + "\"" + CRLF + CRLF;
data += value + CRLF;
data += "--" + boundary + "--" + CRLF;
builderPost.setRequestData( data );
return builderPost;
}
示例4: ajax
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);
}
}
示例5: submitRegistration
public void submitRegistration(UserResults userResults, RegistrationListener registrationListener, final String reportDateFormat) {
final String registratinoUrl = serviceLocations.registrationUrl();
final RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, registratinoUrl);
builder.setHeader("Content-type", "application/x-www-form-urlencoded");
StringBuilder stringBuilder = new StringBuilder();
for (String key : userResults.getMetadataKeys()) {
String value = URL.encodeQueryString(userResults.getMetadataValue(key));
if (stringBuilder.length() > 0) {
stringBuilder.append("&");
}
stringBuilder.append(key).append("=").append(value);
}
if (stringBuilder.length() > 0) {
stringBuilder.append("&");
}
stringBuilder.append("applicationversion").append("=").append(version.projectVersion()).append("&");
String scoreLog = URL.encodeQueryString(userResults.getScoreLog());
stringBuilder.append("scorelog").append("=").append(scoreLog).append("&");
String restultsData = URL.encodeQueryString(new ResultsSerialiser() {
final DateTimeFormat format = DateTimeFormat.getFormat(reportDateFormat);
@Override
protected String formatDate(Date date) {
return format.format(date);
}
}.serialise(userResults, mateadataFields.postName_email()));
stringBuilder.append("quiz_results=").append(restultsData);
try {
builder.sendRequest(stringBuilder.toString(), geRequestBuilder(builder, registrationListener, registratinoUrl));
} catch (RequestException exception) {
registrationListener.registrationFailed(new RegistrationException(RegistrationException.ErrorType.buildererror, exception));
logger.log(Level.SEVERE, "SubmitRegistration", exception);
}
}
开发者ID:languageininteraction,项目名称:GraphemeColourSynaesthesiaApp,代码行数:34,代码来源:RegistrationService.java
示例6: doRequest
private void doRequest() {
// Encode les paramètres de la requête
StringBuffer requestData = new StringBuffer();
boolean first = true;
for (String key : params.keySet()) {
if (first)
first = false;
else
requestData.append("&");
requestData.append(key);
requestData.append("=");
requestData.append(URL.encodeComponent(params.get(key)));
}
// Exécute la requête
RequestBuilder requestBuilder = new RequestBuilder(
RequestBuilder.POST, Config.getServerUrl() + uri + ".do");
requestBuilder.setHeader(
"Content-type", "application/x-www-form-urlencoded");
try {
this.startTime = System.currentTimeMillis();
request = requestBuilder.sendRequest(requestData.toString(), this);
} catch (RequestException e) {
retry(String.valueOf(e.getMessage()));
}
}
示例7: BoshConnector
public BoshConnector(Observable parentObservable, SessionObject sessionObject) {
super(parentObservable, sessionObject);
String u = sessionObject.getProperty(AbstractBoshConnector.BOSH_SERVICE_URL_KEY);
requestBuilder = new RequestBuilder(RequestBuilder.POST, u);
// in Chrome following line causes error (Connection: close is not
// allowed in new spec)
// requestBuilder.setHeader("Connection", "close");
}
示例8: run
@Override
public void run() {
RequestBuilder rq = new RequestBuilder(RequestBuilder.POST, getPingUrl());
rq.setTimeoutMillis(offlinePingInterval);
rq.setCallback(OfflineModeEntrypoint.this);
try {
logger.info("Sending a ping request to the server.");
rq.send();
} catch (Exception e) {
onError(null, e);
}
}
示例9: isModifyingMethod
private boolean isModifyingMethod(RequestBuilder.Method method) {
return method == RequestBuilder.POST
|| method == RequestBuilder.PUT
|| method == RequestBuilder.DELETE;
}
示例10: submitForm
public Cancellable submitForm(String aAction, RequestBuilder.Method aMethod, String aContentType, Map<String, String> aFormData, final Callback<XMLHttpRequest, XMLHttpRequest> aCallback) {
final XMLHttpRequest req = XMLHttpRequest.create().cast();
String urlPath = aAction != null ? aAction : "";
List<String> parameters = new ArrayList<String>();
for (String paramName : aFormData.keySet()) {
parameters.add(param(paramName, aFormData.get(paramName)));
}
String paramsData = params(parameters.toArray(new String[] {}));
if(aMethod != RequestBuilder.POST){
urlPath += "?" + paramsData;
}
req.open(aMethod.toString(), urlPath);
req.setRequestHeader("Content-Type", aContentType);
req.setOnReadyStateChange(new ReadyStateChangeHandler() {
@Override
public void onReadyStateChange(final XMLHttpRequest xhr) {
if (xhr.getReadyState() == XMLHttpRequest.DONE) {
xhr.clearOnReadyStateChange();
if (aCallback != null) {
try {
if (xhr.getStatus() == Response.SC_OK) {
aCallback.onSuccess(xhr);
} else {
aCallback.onFailure(xhr);
}
} catch (Exception ex) {
Logger.getLogger(Utils.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
}
});
if(aMethod == RequestBuilder.POST){
req.send(paramsData);
} else{
req.send();
}
return new Cancellable() {
@Override
public void cancel() {
req.abort();
}
};
}
示例11: sendTextToServer
private void sendTextToServer() {
statusLabel.setText("");
conceptList.clear();
// don't do anything if we have no text
final String text = mainTextArea.getText();
if (text.length() < 1) {
statusLabel.setText(messages.pleaseEnterTextLabel());
return;
}
// disable interaction while we wait for the response
glassPanel.setPositionAndShow();
// build up the AnalysisRequest JSON object
// start with any options
final JSONArray options = new JSONArray();
setSemanticTypesOption(types, options);
// defaults
options.set(options.size(), new JSONString("word_sense_disambiguation"));
options.set(options.size(), new JSONString("composite_phrases 8"));
options.set(options.size(), new JSONString("no_derivational_variants"));
options.set(options.size(), new JSONString("strict_model"));
options.set(options.size(), new JSONString("ignore_word_order"));
options.set(options.size(), new JSONString("allow_large_n"));
options.set(options.size(), new JSONString("restrict_to_sources SNOMEDCT_US"));
final JSONObject analysisRequest = new JSONObject();
analysisRequest.put("text", new JSONString(text));
analysisRequest.put("options", options);
// send the input to the server
final RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, webserviceUrl);
builder.setHeader("Content-Type", MediaType.APPLICATION_JSON);
builder.setRequestData(analysisRequest.toString());
// create the async callback
builder.setCallback(new SnomedRequestCallback(conceptList, statusLabel, glassPanel, typeCodeToDescription));
// send the request
try { builder.send(); }
catch (final RequestException e) {
statusLabel.setText(messages.problemPerformingAnalysisLabel());
GWT.log("There was a problem performing the analysis: " + e.getMessage(), e);
glassPanel.hide();
}
}
示例12: submitScores
public void submitScores(final boolean isShareData,UserResults userResults, HighScoreListener highScoreListener, final String reportDateFormat) {
final String highScoresUrl = serviceLocations.highScoresUrl();
final RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, highScoresUrl);
builder.setHeader("Content-type", "application/x-www-form-urlencoded");
StringBuilder stringBuilder = new StringBuilder();
if (isShareData) {
for (MetadataField key : userResults.getUserData().getMetadataFields()) {
String value = URL.encodeQueryString(userResults.getUserData().getMetadataValue(key));
if (stringBuilder.length() > 0) {
stringBuilder.append("&");
}
stringBuilder.append(key.getPostName()).append("=").append(value);
}
}
if (stringBuilder.length() > 0) {
stringBuilder.append("&");
}
stringBuilder.append("userid").append("=").append(userResults.getUserData().getUserId()).append("&");
stringBuilder.append("highscore").append("=").append(userResults.getUserData().getBestScore()).append("&");
stringBuilder.append("gamesplayed").append("=").append(userResults.getUserData().getGamesPlayed()).append("&");
stringBuilder.append("applicationversion").append("=").append(version.projectVersion()).append("&");
if (!isShareData) {
stringBuilder.append(metadataFieldProvider.shareMetadataField.getPostName()).append("=").append(userResults.getUserData().getMetadataValue(metadataFieldProvider.shareMetadataField)).append("&");
}
if (isShareData) {
// String scoreLog = URL.encodeQueryString(userResults.getScoreLog());
// stringBuilder.append("scorelog").append("=").append(scoreLog).append("&");
String restultsData = URL.encodeQueryString(new ResultsSerialiser() {
final DateTimeFormat format = DateTimeFormat.getFormat(reportDateFormat);
@Override
protected String formatDate(Date date) {
return format.format(date);
}
}.serialise(userResults));
stringBuilder.append("quest_results=").append(new LocalStorage().getStoredGameData(userResults.getUserData().getUserId())).append(restultsData);
}
try {
builder.sendRequest(stringBuilder.toString(), geRequestBuilder(builder, highScoreListener, highScoresUrl, userResults));
} catch (RequestException exception) {
highScoreListener.scoreSubmissionFailed(new HighScoreException(HighScoreException.ErrorType.buildererror, exception));
logger.log(Level.SEVERE, "SubmitHighScore", exception);
}
}
示例13: dispatch
@Override
public boolean dispatch(TransactionRequest request)
{
String baseUrl = "/r.t";
String url = baseUrl;
I_JsonObject requestJson = m_jsonFactory.createJsonObject();
request.writeJson(m_jsonFactory, m_requestPathMngr, requestJson);
String jsonString = requestJson.toString();
RequestBuilder.Method method = request.getMethod() == E_HttpMethod.GET ? RequestBuilder.GET : RequestBuilder.POST;
boolean isGet = method == RequestBuilder.GET;
if( isGet )
{
String jsonEncoded = URL.encodeQueryString(jsonString);
url += "?"+S_Transaction.JSON_URL_PARAM+"=" + jsonEncoded;
url = URL.encode(url);
//--- DRK > Fringe case precaution that we don't exceed practical URL length restrictions.
//--- In this case, we change the request to a post.
if( url.length() >= m_maxGetUrlLength )
{
url = URL.encode(baseUrl);
method = RequestBuilder.POST;
isGet = false;
}
}
else
{
url = URL.encode(baseUrl);
}
RequestBuilder builder = new RequestBuilder(method, url);
try
{
builder.setHeader("Content-Type", "application/json");
Request nativeRequest = builder.sendRequest(isGet ? null : jsonString, this);
m_nativeRequestMap.put(nativeRequest, request);
}
catch (RequestException e)
{
s_logger.severe(e.toString());
return false;
}
return true;
}
示例14: HTTPClient
/**
* Initialize {@code HTTPClient}.
*
* @param serializer Global serializer.
* @param url HTTP endpoint.
*/
public HTTPClient(Serializer serializer, String url) {
super(serializer);
builder = new RequestBuilder(RequestBuilder.POST, url);
}