tags:

views:

7

answers:

0

I am trying to develop a GWT client that will call RESTful web services on the server side. Can you please provide a example code that demonstrates how to send a POST HTTP request using GWT FormPanel ? How should I send the data ? Any help will be appreciated.

My code is like:

// Create the form in GWT 
final FormPanel signUpForm = new FormPanel(); 
signUpForm.setAction("/users");   // Is this required ???? 
signUpForm.setMethod(FormPanel.METHOD_POST); // Is this required since we will be invoking clientresource.post later 

buttonSubmit.addClickHandler(new ClickHandler() { 
  public void onClick(ClickEvent event) { 

    ClientResource r = new ClientResource("/users"); 

    r.setOnResponse(new Uniform() { 
      public void handle(Request request, Response response) { 
        System.out.println("Status = "  + response.getStatus());   
      } 
    }); 

    // Now how to POST THE DATA or send the FORM DATA to the SERVICE AS PARAMETERS ???? 

  } 
});