All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.vaadin.polymer.iron.widget.IronForm Maven / Gradle / Ivy

The newest version!
/*
 * This code was generated with Vaadin Web Component GWT API Generator, 
 * from iron-form project by The Polymer Authors
 * that is licensed with http://polymer.github.io/LICENSE.txt license.
 */
package com.vaadin.polymer.iron.widget;

import com.vaadin.polymer.iron.*;

import com.vaadin.polymer.iron.widget.event.IronFormErrorEvent;
import com.vaadin.polymer.iron.widget.event.IronFormErrorEventHandler;

import com.vaadin.polymer.iron.widget.event.IronFormInvalidEvent;
import com.vaadin.polymer.iron.widget.event.IronFormInvalidEventHandler;

import com.vaadin.polymer.iron.widget.event.IronFormPresubmitEvent;
import com.vaadin.polymer.iron.widget.event.IronFormPresubmitEventHandler;

import com.vaadin.polymer.iron.widget.event.IronFormResetEvent;
import com.vaadin.polymer.iron.widget.event.IronFormResetEventHandler;

import com.vaadin.polymer.iron.widget.event.IronFormResponseEvent;
import com.vaadin.polymer.iron.widget.event.IronFormResponseEventHandler;

import com.vaadin.polymer.iron.widget.event.IronFormSubmitEvent;
import com.vaadin.polymer.iron.widget.event.IronFormSubmitEventHandler;

import com.vaadin.polymer.*;
import com.vaadin.polymer.elemental.*;
import com.vaadin.polymer.PolymerWidget;
import com.google.gwt.core.client.JsArray;
import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.core.client.JavaScriptObject;

/**
 * 

<iron-form> is an HTML <form> element that can validate and submit any custom
elements that implement Polymer.IronFormElementBehavior, as well as any
native HTML elements. For more information on which attributes are
available on the native form element, see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form

*

It supports both get and post methods, and uses an iron-ajax element to
submit the form data to the action URL.

*

Example:

*
<form is="iron-form" id="form" method="post" action="/form/handler">
 *   <paper-input name="name" label="name"></paper-input>
 *   <input name="address">
 *   ...
 * </form>
 * 
 * 
 * 

By default, a native <button> element will submit this form. However, if you
want to submit it from a custom element’s click handler, you need to explicitly
call the form’s submit method.

*

Example:

*
<paper-button raised onclick="submitForm()">Submit</paper-button>
 * 
 * function submitForm() {
 *   document.getElementById('form').submit();
 * }
 * 
 * 
 * 

To customize the request sent to the server, you can listen to the iron-form-presubmit
event, and modify the form’siron-ajax
object. However, If you want to not use iron-ajax at all, you can cancel the
event and do your own custom submission:

*

Example of modifying the request, but still using the build-in form submission:

*
form.addEventListener('iron-form-presubmit', function() {
 *   this.request.method = 'put';
 *   this.request.params = someCustomParams;
 * });
 * 
 * 
 * 

Example of bypassing the build-in form submission:

*
form.addEventListener('iron-form-presubmit', function(event) {
 *   event.preventDefault();
 *   var firebase = new Firebase(form.getAttribute('action'));
 *   firebase.set(form.serialize());
 * });
 * 
 * 
 * 
*/ public class IronForm extends PolymerWidget { /** * Default Constructor. */ public IronForm() { this(""); } /** * Constructor used by UIBinder to create widgets with content. */ public IronForm(String html) { super(IronFormElement.TAG, IronFormElement.SRC, html); } /** * Gets a handle to the Polymer object's underlying DOM element. */ public IronFormElement getPolymerElement() { return (IronFormElement) getElement(); } /** *

HTTP request headers to send.

*

Note: setting a Content-Type header here will override the value
specified by the contentType property of this element.

* * JavaScript Info: * @property headers * @type Object * */ public JavaScriptObject getHeaders() { return getPolymerElement().getHeaders(); } /** *

HTTP request headers to send.

*

Note: setting a Content-Type header here will override the value
specified by the contentType property of this element.

* * JavaScript Info: * @property headers * @type Object * */ public void setHeaders(JavaScriptObject value) { getPolymerElement().setHeaders(value); } /** *

iron-ajax request object used to submit the form.

* * JavaScript Info: * @property request * @type Object * */ public JavaScriptObject getRequest() { return getPolymerElement().getRequest(); } /** *

iron-ajax request object used to submit the form.

* * JavaScript Info: * @property request * @type Object * */ public void setRequest(JavaScriptObject value) { getPolymerElement().setRequest(value); } /** *

By default, the form will display the browser’s native validation
UI (i.e. popup bubbles and invalid styles on invalid fields). You can
manually disable this; however, if you do, note that you will have to
manually style invalid native HTML fields yourself, as you are
explicitly preventing the native form from doing so.

* * JavaScript Info: * @property disableNativeValidationUi * @type Boolean * */ public boolean getDisableNativeValidationUi() { return getPolymerElement().getDisableNativeValidationUi(); } /** *

By default, the form will display the browser’s native validation
UI (i.e. popup bubbles and invalid styles on invalid fields). You can
manually disable this; however, if you do, note that you will have to
manually style invalid native HTML fields yourself, as you are
explicitly preventing the native form from doing so.

* * JavaScript Info: * @property disableNativeValidationUi * @type Boolean * */ public void setDisableNativeValidationUi(boolean value) { getPolymerElement().setDisableNativeValidationUi(value); } /** *

Set the withCredentials flag when sending data.

* * JavaScript Info: * @property withCredentials * @type Boolean * */ public boolean getWithCredentials() { return getPolymerElement().getWithCredentials(); } /** *

Set the withCredentials flag when sending data.

* * JavaScript Info: * @property withCredentials * @type Boolean * */ public void setWithCredentials(boolean value) { getPolymerElement().setWithCredentials(value); } /** *

Content type to use when sending data. If the contentType property
is set and a Content-Type header is specified in the headers
property, the headers property value will take precedence.
If Content-Type is set to a value listed below, then
the body (typically used with POST requests) will be encoded accordingly.

*
    *
  • content-type="application/json"
      *
    • body is encoded like {"foo":"bar baz","x":1}
    • *
    *
  • *
  • content-type="application/x-www-form-urlencoded"
      *
    • body is encoded like foo=bar+baz&x=1
    • *
    *
  • *
* * JavaScript Info: * @property contentType * @type String * */ public String getContentType() { return getPolymerElement().getContentType(); } /** *

Content type to use when sending data. If the contentType property
is set and a Content-Type header is specified in the headers
property, the headers property value will take precedence.
If Content-Type is set to a value listed below, then
the body (typically used with POST requests) will be encoded accordingly.

*
    *
  • content-type="application/json"
      *
    • body is encoded like {"foo":"bar baz","x":1}
    • *
    *
  • *
  • content-type="application/x-www-form-urlencoded"
      *
    • body is encoded like foo=bar+baz&x=1
    • *
    *
  • *
* * JavaScript Info: * @property contentType * @type String * */ public void setContentType(String value) { getPolymerElement().setContentType(value); } // Needed in UIBinder /** *

iron-ajax request object used to submit the form.

* * JavaScript Info: * @attribute request * */ public void setRequest(String value) { Polymer.property(this.getPolymerElement(), "request", value); } // Needed in UIBinder /** *

HTTP request headers to send.

*

Note: setting a Content-Type header here will override the value
specified by the contentType property of this element.

* * JavaScript Info: * @attribute headers * */ public void setHeaders(String value) { Polymer.property(this.getPolymerElement(), "headers", value); } /** *

Submits the form.

* * JavaScript Info: * @method submit * * */ public void submit() { getPolymerElement().submit(); } /** *

Validates all the required elements (custom and native) in the form.

* * JavaScript Info: * @method validate * * @return {boolean} */ public boolean validate() { return getPolymerElement().validate(); } /** *

Returns a json object containing name/value pairs for all the registered
custom components and native elements of the form. If there are elements
with duplicate names, then their values will get aggregated into an
array of values.

* * JavaScript Info: * @method serialize * * @return {JavaScriptObject} */ public JavaScriptObject serialize() { return getPolymerElement().serialize(); } /** *

Fired after the form is submitted and an error is received. An
IronRequestElement is included as the event.detail object.

* * JavaScript Info: * @event iron-form-error */ public HandlerRegistration addIronFormErrorHandler(IronFormErrorEventHandler handler) { return addDomHandler(handler, IronFormErrorEvent.TYPE); } /** *

Fired if the form cannot be submitted because it’s invalid.

* * JavaScript Info: * @event iron-form-invalid */ public HandlerRegistration addIronFormInvalidHandler(IronFormInvalidEventHandler handler) { return addDomHandler(handler, IronFormInvalidEvent.TYPE); } /** *

Fired before the form is submitted.

* * JavaScript Info: * @event iron-form-presubmit */ public HandlerRegistration addIronFormPresubmitHandler(IronFormPresubmitEventHandler handler) { return addDomHandler(handler, IronFormPresubmitEvent.TYPE); } /** *

Fired after the form is reset.

* * JavaScript Info: * @event iron-form-reset */ public HandlerRegistration addIronFormResetHandler(IronFormResetEventHandler handler) { return addDomHandler(handler, IronFormResetEvent.TYPE); } /** *

Fired after the form is submitted and a response is received. An
IronRequestElement is included as the event.detail object.

* * JavaScript Info: * @event iron-form-response */ public HandlerRegistration addIronFormResponseHandler(IronFormResponseEventHandler handler) { return addDomHandler(handler, IronFormResponseEvent.TYPE); } /** *

Fired after the form is submitted.

* * JavaScript Info: * @event iron-form-submit */ public HandlerRegistration addIronFormSubmitHandler(IronFormSubmitEventHandler handler) { return addDomHandler(handler, IronFormSubmitEvent.TYPE); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy