/** * FormPanel用法 * @author crane.ding * @version 1.0 2008-9-26 */ public class Hello implements EntryPoint {
public void onModuleLoad() { HorizontalPanel outer = new HorizontalPanel(); final FormPanel formPanel = new FormPanel(); final TextBox box = new TextBox(); final Button button = new Button("ok", new ClickListener() { public void onClick(Widget sender) { formPanel.submit(); } });
box.setName("textbox");
formPanel.setAction(GWT.getModuleBaseURL() + "/myFormHandler"); formPanel.setEncoding(FormPanel.ENCODING_URLENCODED); formPanel.setMethod(FormPanel.METHOD_GET); formPanel.addFormHandler(new FormHandler() { public void onSubmit(FormSubmitEvent event) { if (box.getText().trim().equals("")) { Window.alert("请输入"); event.setCancelled(true); } }
public void onSubmitComplete(FormSubmitCompleteEvent event) { Window.alert(event.getResults()); } });