Roughian Examples Site Map - GWT Examples - Tutorials

FormPanel


Version 1.1 onwards

A FormPanel - A Panel That Is A Form



Notes


A panel that lets you interact with servers which expect a traditional form. You get the results back and can do whatever you like with them.

Widgets Values Will Get Submitted For...

TextBox
PasswordTextBox
RadioButton
CheckBox
TextArea
ListBox
FileUpload
Hidden

FileUpload will ONLY work if it is within a form


Code

final FormPanel form = new FormPanel();
form.setEncoding(FormPanel.ENCODING_MULTIPART);
form.setMethod(FormPanel.METHOD_POST);
form.addStyleName("table-center");
form.addStyleName("demo-FormPanel");

VerticalPanel holder = new VerticalPanel();

holder.add(new Label("User ID"));
TextBox userid = new TextBox();
userid.setName("userid");
holder.add(userid);

holder.add(new Label("Password"));
PasswordTextBox passwd = new PasswordTextBox();
passwd.setName("passwd");
holder.add(passwd);

holder.add(new Button("Submit", new ClickListener()
{
    public void onClick(Widget sender)
    {
        // form.submit();
    }
}));

form.add(holder);

// form.setAction("url");

form.addFormHandler(new FormHandler()
{
    public void onSubmit(FormSubmitEvent event)
    {
        // if (something_is_wrong)
        // {
        // Take some action
        // event.setCancelled(true);
        // }
    }

    public void onSubmitComplete(
        FormSubmitCompleteEvent event)
    {
        Window.alert(event.getResults());
    }
});

RootPanel.get("demo").add(form);