try {
// ResponseHandler returns xhtml or xforms or whatever
// browsable, capable of handling its content
ResponseHandler<Browsable> responseHandler = new BrowsableResponseHandler();
FormRequest formRequest = getCurrentResource().getFormRequest(name, values);
System.out.println("submitting form " + name + " with " + formRequest);
URI uri = formRequest.getURI();
if (!uri.isAbsolute()) {
uri = new URI(context.toASCIIString() + uri.toASCIIString());
}
HttpMethod method = formRequest.getMethod();
switch (method) {
case GET: {
uri = new URI(uri.getScheme(), uri.getAuthority(), uri.getPath(), formRequest.getRequestBody(), null);
HttpGet httpGet = createGet(uri);
currentResource = httpClient.execute(httpGet, responseHandler);
break;
}
case POST: {
HttpPost httpPost = new HttpPost(uri);
StringEntity entity = new StringEntity(formRequest.getRequestBody(), ContentType.create(
formRequest.getContentType(), formRequest.getEncoding()));
httpPost.setEntity(entity);
currentResource = httpClient.execute(httpPost, responseHandler);
break;
}
default: