tags:

views:

992

answers:

2

I've been trying this for a few days now with no luck.

final FormPanel form = new FormPanel(new NamedFrame("test"));
form.setAction("/designer");
form.setMethod(FormPanel.METHOD_POST);
VerticalPanel panel = new VerticalPanel();
form.setWidget(panel);

final TextBox tb = new TextBox();
tb.setName("style");
panel.add(tb);
panel.add(new Button("Submit", new ClickHandler() {
public void onClick(ClickEvent event) {
   Window.alert("submitting to:" + form.getTarget());
   form.submit();
    }
}));
form.addSubmitCompleteHandler(new SubmitCompleteHandler() {
public void onSubmitComplete(SubmitCompleteEvent event) {
  Window.alert("complete");
  Window.alert(event.getResults());
}
});

In Hosted Mode, nothing happens after the "Submitting to" alert fires. In Chrome, the form loads in a separate tab, but the POST itself is empty. In Firefox and IE, again, nothing happens after the alert. Any ideas?

I've set up a servlet at /designer that outputs the request header and body from any page requests. I can hit this servlet from a plain HTML page and see the expected output. From GWT, no request ever appears (except for Chrome, in which the request shows up, but with an empty body).

+1  A: 

Your code is almost identical to the example on the FormPanel API, therefore I must assume that the logic is correct.

Does a servlet exist at "/designer"? The documentation for SubmitCompleteHandler states that the onSubmitComplete event only fires if the submit is successful.

Here is a thread containing some sample code for writing a servlet that handles the form post: http://groups.google.com/group/Google-Web-Toolkit/browse_thread/thread/77e68fcb9097debc

Templar
+1  A: 

Try moving form.setWidget(panel); to the bottom.

Also, make sure that you add the form to the container panel i.e. add(form);, not the vertical panel.

Nick Hristov