Cancel form submission

How can I cancel a form submission using GWT?

I need to check the form and process some data before submitting it.

So far I have done the following: the problem is that the form is submitted even if SubmitEvent is canceled.

form.addSubmitHandler( new SubmitHandler() { @Override public void onSubmit(SubmitEvent event) { if(validate()) { // i do some processing here form.submit(); } else event.cancel(); // submits anyway } }); 

Is this a GWT problem? How can I do it?

edit: I just found out that if it was a button that uses click.submit () when clicked, the send event is canceled. However, if the SubmitButton button is pressed, the event is not canceled.

So, I think this is the behavior of the browser. However, I need to find a way ...

edit: it just turned out that this happens only in development mode, I still have not tried stupidly to use external development mode.

+4
source share
1 answer

This is a problem that occurs only in development mode.

I reported a problem: http://code.google.com/p/google-web-toolkit/issues/detail?id=5067

+3
source

Source: https://habr.com/ru/post/1314061/


All Articles