| commit | 0390a8ceb4636ac2c04968caba52a44f5923a243 | [log] [tgz] |
|---|---|---|
| author | jlabanca@google.com <jlabanca@google.com@8db76d5a-ed1c-0410-87a9-c151d255dfc7> | Thu Sep 18 19:31:46 2008 +0000 |
| committer | jlabanca@google.com <jlabanca@google.com@8db76d5a-ed1c-0410-87a9-c151d255dfc7> | Thu Sep 18 19:31:46 2008 +0000 |
| tree | 304b4c237a0bc9bda8a065ff6d11707d4f59c31c | |
| parent | 4ff1f052ddf633b20de61137db6dc6a55603d9b5 [diff] |
Add a FormPanel.reset() method. Patch by: jlabanca Review by: ajr Issue: 32 git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@3665 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/user/src/com/google/gwt/user/client/ui/FormPanel.java b/user/src/com/google/gwt/user/client/ui/FormPanel.java index d8a06e4..08cb5ba 100644 --- a/user/src/com/google/gwt/user/client/ui/FormPanel.java +++ b/user/src/com/google/gwt/user/client/ui/FormPanel.java
@@ -327,6 +327,13 @@ } /** + * Resets the form, clearing all fields. + */ + public void reset() { + impl.reset(getElement()); + } + + /** * Sets the 'action' associated with this form. This is the URL to which it * will be submitted. *
diff --git a/user/src/com/google/gwt/user/client/ui/impl/FormPanelImpl.java b/user/src/com/google/gwt/user/client/ui/impl/FormPanelImpl.java index 27ecc4d..73b9854 100644 --- a/user/src/com/google/gwt/user/client/ui/impl/FormPanelImpl.java +++ b/user/src/com/google/gwt/user/client/ui/impl/FormPanelImpl.java
@@ -83,6 +83,15 @@ }-*/; /** + * Resets a form. + * + * @param form the form to be reset + */ + public native void reset(Element form) /*-{ + form.reset(); + }-*/; + + /** * Sets the form element's encoding. * * @param form the form whose encoding is to be set
diff --git a/user/test/com/google/gwt/user/client/ui/FormPanelTest.java b/user/test/com/google/gwt/user/client/ui/FormPanelTest.java index 1e81102..90f6ba4 100644 --- a/user/test/com/google/gwt/user/client/ui/FormPanelTest.java +++ b/user/test/com/google/gwt/user/client/ui/FormPanelTest.java
@@ -162,6 +162,16 @@ form.submit(); } + public void testReset() { + FormPanel form = new FormPanel(); + TextBox textBox = new TextBox(); + textBox.setText("Hello World"); + form.setWidget(textBox); + assertEquals("Hello World", textBox.getText()); + form.reset(); + assertEquals("", textBox.getText()); + } + public void testSubmitAndHideDialog() { final FormPanel form = new FormPanel(); form.setMethod(FormPanel.METHOD_GET);