Simple Form Question

11 views
Skip to first unread message

marsh...@gmail.com

unread,
Aug 31, 2006, 3:52:30 PM8/31/06
to Google Web Toolkit
Hi:

I'm using the FormPanel because I've got a FileUpload widget.

In old school, form submission goes to the server and results in a new
HTML page getting sent back to the browser. This is the effect I was
hoping for. In GWT, after form.submit, control returns to the GWT
entry point through the FormHandler.onSubmitComplete.

How can I get the effect of submitting the form and then having my
servlet (which processes the form) generate a new HTML page to replace
the current GWT entry point?

All the HTML I want to display came back in
FormSubmitCompleteEvent.getResults()

so is there a simple call I can make to replace the current page with
the HTML???

marsh...@gmail.com

unread,
Aug 31, 2006, 9:22:17 PM8/31/06
to Google Web Toolkit
After playing around the best I could do was:

// the <html> tag has a rootElement id in it so this will replace the
document HTML
// with what comes back from the submit.
FormHandler.onSubmitComplete(FormSubmitCompleteEvent event) {
Element root = DOM.getElementById("rootElement");
DOM.setInnerHTML(root,html);

This doesn't really work for me though because my servlet is returning
an HTML page that contains a GWT entry point which makes an RPC at
onLoad time.

So we really need a FormPanel that can submit to the server and not do
a callback to the GWT page that submitted...

How bout a constructor like: FormPanel(boolean returnResultsToCaller)

Vivian Li

unread,
Sep 7, 2006, 4:04:18 AM9/7/06
to Google-We...@googlegroups.com

 Hi Marshall62,
   If you want to simply submit a form and replace the GWT application with the results of the form, see here: http://code.google.com/webtoolkit/documentation/com.google.gwt.user.client.ui.FormPanel.html#FormPanel(java.lang.String)

  Just use null for the target of the FormPanel. Here is some sample code:

        FlowPanel fp = new FlowPanel();
        final FormPanel form=new FormPanel((String)null);
        form.setEncoding(FormPanel.ENCODING_URLENCODED);
        form.setAction("http://www.google.com/search ");

        TextBox tb=new TextBox();
        tb.setName("q");
        Button b=new Button("Search");
        b.addClickListener(new ClickListener() {
            public void onClick(Widget sender) {
                form.submit();
            }
        });
        fp.add(tb);
        fp.add(b);
        form.add(fp);

-Vivian

marsh...@gmail.com

unread,
Sep 7, 2006, 11:29:34 AM9/7/06
to Google Web Toolkit
Thanks. Thats what I needed!

Reply all
Reply to author
Forward
0 new messages