use of org.gwtproject.user.client.ui.FormPanel.SubmitEvent in project gwtproject by treblereel.
the class FormPanelTest method testCancelSubmit.
public void testCancelSubmit() {
TextBox tb = new TextBox();
tb.setName("q");
FormPanel form = new FormPanel();
form.setWidget(tb);
form.setAction("http://www.google.com/search");
form.addSubmitHandler(new SubmitHandler() {
@Override
public void onSubmit(SubmitEvent event) {
event.cancel();
}
});
form.addSubmitCompleteHandler(new SubmitCompleteHandler() {
@Override
public void onSubmitComplete(SubmitCompleteEvent event) {
fail("Form was canceled and should not have been submitted");
}
});
form.submit();
}
use of org.gwtproject.user.client.ui.FormPanel.SubmitEvent in project gwtproject by treblereel.
the class FormPanelTest method testNamedTargetSubmitEvent.
public void testNamedTargetSubmitEvent() {
// Create a form and frame in the document we can wrap.
String iframeId = Document.get().createUniqueId();
String iframeName = Document.get().createUniqueId();
final Element container = Document.get().createDivElement();
container.setInnerHTML("<form method='post' target='" + iframeName + "' action='" + "formHandler?sendHappyHtml'>" + "<input type='submit' id='submitBtn'></input></form>" + "<iframe src=\"javascript:\'\'\" id='" + iframeId + "' " + "name='" + iframeName + "'></iframe>");
Document.get().getBody().appendChild(container);
// Wrap the form and make sure its target frame is intact.
FormPanel form = FormPanel.wrap(container.getFirstChildElement());
assertEquals(iframeName, form.getTarget());
// Ensure that no synthesized iframe was created.
assertNull(form.getSynthesizedIFrame());
// Submit the form using the submit button and make sure the submit event fires.
delayTestFinish(TEST_DELAY);
form.addSubmitHandler(new SubmitHandler() {
@Override
public void onSubmit(SubmitEvent event) {
finishTest();
}
});
Document.get().getElementById("submitBtn").<InputElement>cast().click();
}
Aggregations