tags:

views:

302

answers:

2

My code is

            FormPanel form =new FormPanel();
            VerticalPanel holder = new VerticalPanel();
            holder.add(new Label("User ID"));
            nameTextBox = new TextBox();
            nameTextBox.setName("userid");
            holder.add(nameTextBox);

             submitButton = new Button("Submit");
             holder.add(submitButton);
            form.add(holder);

            submitButton.addClickListener(new ClickListener() {

            @Override
            public void onClick(Widget sender) {
                    form.submit();
            }

            });

            form.addFormHandler(new FormHandler() {
                    public void onSubmit(FormSubmitEvent event) {


           }

           public void onSubmitComplete(FormSubmitCompleteEvent event) {

        }
      });

but when i submit form i get error

[ERROR] Uncaught exception escaped com.google.gwt.core.client.JavaScriptException: (TypeError): form.submit is not a function

please tell me the right way..

+1  A: 

Which version of gwt you are using and give me the import statement of "Form" class.

BlackPanther
import com.google.gwt.user.client.ui.FormPanel;
Tushar Ahirrao
In your code you mentioned this " Form form =new Form();" (First line of your code).But you are importing Formpanel .Can you please clarify this.
BlackPanther
Call the form.setAction("your URL") method also.http://google-web-toolkit.googlecode.com/svn/javadoc/1.4/com/google/gwt/user/client/ui/FormPanel.html
BlackPanther
+1  A: 

Just add form.setAction("/pathofthesubmission");

or in case your sending a file, also add the following:

form.setEncoding(FormPanel.ENCODING_MULTIPART); form.setMethod(FormPanel.METHOD_POST);

dkberktas