GWT simple submit web form - redirect to new page

I have a simple web form written on Google web tools. I want the user to keep track of the new URL when he clicks the submit button. However, I cannot find examples of redirecting the user to the new URL from the GWT code. How can I achieve this?

+4
source share
4 answers

To redirect the user to a new page, use Window.Location.assign() .

For this to happen when the user FormPanel.addSubmitHandler() form, use FormPanel.addSubmitHandler() or addSubmitCompleteHandler() so that redirection occurs when the form is completed.

+4
source

the exact answer:

  form.getElement().<FormElement>cast().setTarget(""); 

with this line you change the target parameter of the form, and now you redirect the main page to the action URL.

be careful that Window.Location.assign () creates a new GET request after your main POST !, so this is not the answer.

+7
source

So what you need to do is use the setAction () method for the FormPanel. And you need to build the form panel as such:

FormPanel form = new FormPanel (new NamedFrame ("_ me"));

This will make the redirect send as usual.

Hope this helps.

+3
source

You can look at an example on roughain http://examples.roughian.com/index.htm#Panels~FormPanel

You can also read javadoc @ http://google-web-toolkit.googlecode.com/svn/javadoc/1.6/com/google/gwt/user/client/ui/FormPanel.html

To have the user switch to using the setAction URL of the setAction method

+1
source

All Articles