AdfRichUIPeer.createPeerClass(AdfRichUIPeer, "AdfDhtmlFormPeer");
AdfDhtmlFormPeer.InitSubclass = function() {
  AdfRichUIPeer.addSuppressedPPRAttributes(this, "defaultCommand");
  AdfRichUIPeer.addComponentEventHandlers(this, AdfUIInputEvent.KEY_PRESS_EVENT_TYPE);
};
AdfDhtmlFormPeer.prototype.DomReplaceNotify = function(domNode) {
  var component = this.getComponent();
  var clientId = component.getClientId();
  var postscriptId = AdfRichUIPeer.createSubId(clientId, "postscript");
  if (domNode.id == postscriptId) {
    return null;
  }
  return domNode;
};
AdfDhtmlFormPeer.prototype.InitDomElement = function(component, rootElement) {
  AdfDhtmlFormPeer.superclass.InitDomElement.call(this, component, rootElement);
  var page = AdfPage.PAGE;
  var window = page.getDomWindow();
  var func = function anonymous() {
    return true;
  };
  window["_" + component.getClientId() + "Validator"] = func;
};
AdfDhtmlFormPeer.prototype.HandleComponentKeyPress = function(componentEvent) {
  if (componentEvent.getKeyCode() == AdfKeyStroke.ENTER_KEY) {
    var id = AdfDhtmlFormPeer.__GetDefaultCommandTriggerId(componentEvent, true);
    if (id == null) {
      return;
    }
    var defaultCommandOnComp = AdfDhtmlSubformPeer.getDefaultCommandSubform(id);
    var defaultCommandId;
    if (defaultCommandOnComp) {
      defaultCommandId = defaultCommandOnComp.getDefaultCommand();
    } else {
      defaultCommandOnComp = this.getComponent();
      defaultCommandId = defaultCommandOnComp.getDefaultCommand();
    }
    if (defaultCommandId) {
      var defaultCommand = defaultCommandOnComp.findComponent(defaultCommandId);
      if (defaultCommand) {
        var isBusy = defaultCommand.getPeer().isBusy();
        if (!isBusy) {
          AdfActionEvent.queue(defaultCommand, defaultCommand.getPartialSubmit());
        }
      } else {
        AdfLogger.LOGGER.warning("DefaultCommand with the ID of '" + defaultCommandId + "' is not found for component: " + defaultCommandOnComp);
      }
    }
  }
};
AdfDhtmlFormPeer.__GetDefaultCommandTriggerId = function(componentEvent, cancelEvent) {
  var nativeTarget = componentEvent.getNativeEventTarget();
  if (nativeTarget) {
    var tagName = nativeTarget.tagName;
    if (tagName == "A" || tagName == "BUTTON" || tagName == "TEXTAREA" || tagName == "IFRAME" || tagName == "INPUT" && (nativeTarget.type == "submit" || nativeTarget.type == "reset")) {
      return null;
    }
    if (tagName != "SELECT" && cancelEvent) {
      componentEvent.cancel();
    }
    var idNode = nativeTarget;
    var id = idNode.id;
    while (!id) {
      idNode = idNode.parentNode;
      id = idNode.id;
    }
    return id;
  }
  return null;
};
