Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package org.jboss.errai.ui.client.widget;

Base class for Templated widgets that require native form support for asynchronous GET or POST requests.

Calls to AbstractForm.submit() trigger a form submission that is null-routed and targets a hidden iframe.

The typical usage will be for login forms, where calling AbstractForm.submit() after a successful login will prompt the browser to remember a user's credentials.

If you use an AbstractForm and still encounter issues getting proper browser form support:

  • make sure that your text-fields are actual form inputs
  • make sure the UI "submit" button triggers a ClickHandler that calls AbstractFormsubmit()
  • make sure the UI "submit" button does not directly trigger submission (i.e. it should not have type="submit"

    Max Barkley <>
 public abstract class AbstractForm extends Composite {
   public static final String DEFAULT_FORM_ACTION = "";
   public static final String ERRAI_FORM_FRAME_ID = "ERRAI-FORM-FRAME";
   private IFrameElement iFrame;
   private void setupIFrame() {
      = getOrMakeIFrame();
     final String uniqueId = ;
   private void prepareFormForSubmission(final FormElement form) {

Subclasses may override this method if they want the form to submit to a different url than AbstractForm.DEFAULT_FORM_ACTION.

The value that will be set to the AbstractForm.getFormElement() action attribute before submission.
   protected String getFormAction() {
     return ;
   private IFrameElement getOrMakeIFrame() {
     IFrameElement iFrame = null;
     try {
       iFrame = (IFrameElement) Document.get().getElementById();
     catch (Exception e) {
     if (iFrame == null)
       iFrame = Document.get().createIFrameElement();
     return iFrame;

Submit the form returned from AbstractForm.getFormElement(). Before the form is submitted, it will be modifed so that it targets a hidden iframe with the id AbstractForm.ERRAI_FORM_FRAME_ID with the action set to the return value of AbstractForm.getFormAction().
  public void submit() {
    final FormElement form = getFormElement();


The form element that will be submitted when AbstractForm.submit() is called.
  protected abstract FormElement getFormElement();
New to GrepCode? Check out our FAQ X