tags:

views:

103

answers:

3

I want to navigate away from my GWT app using a POST request. If it was a GET I could just use Window.Location and if I didn't need it to be dynamic I could hardcode a Form and submit it. The FormPanel seems to be the answer for creating and submitting forms, but it does it asynchronously, and I want the user's browser to follow the form submit, navigating away from my app, rather than just displaying the results.

Anybody know how to do this in Google Web Toolkit?

A: 

Havn't done this myself but I think you should be able to create a FormPanel and then cast its element to FormElement and call submit on the FormElement.

FormPanel formPanel = new ...
FormElement form = FormElement.as(formPanel.getElement());
form.submit();
pathed
A: 
Tom
why this doesn't work is probably because gwt runs it's javascript in an IFrame, so you add the form to the iframe, try instead $doc.body.appendChild(form);
pathed
A: 

Ok, got it!

Passing null to the String contructor of the FormPanel says "replace the current page".

i.e. new FormPanel((String)null);

This page was useful: http://www.coderanch.com/t/120264/GWT/GWT-HTTP-post-requests

Tom