A little out-of-time response but since this problem still exists in 2.5 I 
think it's worth sharing another solution. 

If you put "javascript:" into form's action attribute, nothing will happen 
even if the event is not canceled. I know this isn't helpful in cases where 
you need to validate the form, but in case you (like me) are preventing the 
form submit to send the data using GWT RPC instead of the POST to take 
advantage of the browser's password remembering feature (I'm wrapping 
FormPanel around already existing form) this is actually helpful.

On Saturday, January 29, 2011 8:03:18 PM UTC+1, balkanski wrote:
>
> I have just found the solution for GWT 2.1.1 version. Here it is: 
>
> First you do not use a 'SubmitButton' in your FormPanel, because it 
> turns out that it causes all the troubles. 
>
> Use a 'Button' instead and add a 'ClickHandler' to it, and call 
> 'your_form.submit()' inside the 'onClick()' method. 
>
> You will find that after using 'Button' instead of 'SubmitButton' all 
> the input fields in the form has lost their 
> initial 'submit on Enter' behavior, which was observed at the 
> beginning. 
>
> Now attach to every input field a 'onKeyDown' handler(if you want, of 
> course) and check the event's native key code upon 'ENTER', and if yes 
> - submit the form. 
>
> That is all, now the 'event.cancel()' part in the form's SubmitHandler 
> is perfectly working. 
>
>
> On Jan 5, 10:27 pm, Greg Dougherty <dougherty.greg...@mayo.edu> wrote: 
> > I have the following code in a GWT 2.1.0 project: 
> > 
> > public void onSubmit (FormPanel.SubmitEvent event) 
> > { 
> >         // This event is fired just before the form is submitted. We can 
> take 
> >         // this opportunity to perform validation. 
> >         String filename = gDataFileUploader.getFilename (); 
> >         if (filename.length () == 0) 
> >         { 
> >                 showAlert ("Need a valid File Name in before we can 
> upload a 
> > file!"); 
> >                 event.cancel (); 
> >         } 
> > 
> > } 
> > 
> > Unfortunately, although it is called, the cancel () call doesn't stop 
> > the submit from happening, and doesn't stop onSubmitComplete from 
> > being called.  Is this a GWT bug or a browser bug?  (FireFox 3.6) 
> > 
> > TIA, 
> > 
> > Greg

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-web-toolkit+unsubscr...@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to