Doing PUT DELETE and Other Niceties with GWT

You probably are REST lovers like I personally am.

Thus you were probably quite frustrated when seeing that a GWT (Google Web Toolkit) client cannot send other requests than POST or GET.
Well here is the solution:

public class RequestBuilderForAnyHTTPMethodTypeExample extends RequestBuilder {

/**
* Constructor that allows a developer to override the HTTP method
* restrictions imposed by the RequestBuilder class. Note if you override the
* RequestBuilder's HTTP method restrictions in this manner, your application
* may not work correctly on Safari browsers.
*
* @param httpMethod any non-null, non-empty string is considered valid
* @param url any non-null, non-empty string is considered valid
*
* @throws IllegalArgumentException if httpMethod or url are empty
* @throws NullPointerException if httpMethod or url are null
*/
public RequestBuilderForAnyHTTPMethodTypeExample(String httpMethod, String url) {
super(httpMethod, url);
}

i.e. simply subclass the RequestBuilder

Source: (see the bottom of the page).

Leave a comment

Your comment