com.vaadin.polymer.iron.widget.IronForm Maven / Gradle / Ivy
/*
* 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.element.*;
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.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.PolymerWidget;
import com.vaadin.polymer.elemental.*;
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.
* 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();
* }
*
*
*
*/
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);
getPolymerElement().addEventListener(
com.vaadin.polymer.iron.element.event.IronFormErrorEvent.NAME,
new com.vaadin.polymer.iron.element.event.IronFormErrorEvent.Listener() {
@Override
protected void handleEvent(com.vaadin.polymer.iron.element.event.IronFormErrorEvent event) {
fireEvent(new IronFormErrorEvent(event));
}
});
getPolymerElement().addEventListener(
com.vaadin.polymer.iron.element.event.IronFormInvalidEvent.NAME,
new com.vaadin.polymer.iron.element.event.IronFormInvalidEvent.Listener() {
@Override
protected void handleEvent(com.vaadin.polymer.iron.element.event.IronFormInvalidEvent event) {
fireEvent(new IronFormInvalidEvent(event));
}
});
getPolymerElement().addEventListener(
com.vaadin.polymer.iron.element.event.IronFormResponseEvent.NAME,
new com.vaadin.polymer.iron.element.event.IronFormResponseEvent.Listener() {
@Override
protected void handleEvent(com.vaadin.polymer.iron.element.event.IronFormResponseEvent event) {
fireEvent(new IronFormResponseEvent(event));
}
});
getPolymerElement().addEventListener(
com.vaadin.polymer.iron.element.event.IronFormSubmitEvent.NAME,
new com.vaadin.polymer.iron.element.event.IronFormSubmitEvent.Listener() {
@Override
protected void handleEvent(com.vaadin.polymer.iron.element.event.IronFormSubmitEvent event) {
fireEvent(new IronFormSubmitEvent(event));
}
});
}
/**
* Gets a handle to the Polymer object's underlying DOM element.
*/
public IronFormElement getPolymerElement() {
return (IronFormElement) getElement();
}
/**
* Content type to use when sending data.
*
* JavaScript Info:
* @property contentType
* @type String
*
*/
public String getContentType(){
return getPolymerElement().getContentType();
}
/**
* Content type to use when sending data.
*
* JavaScript Info:
* @property contentType
* @type String
*
*/
public void setContentType(String value) {
getPolymerElement().setContentType(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);
}
/**
* 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
*
*/
public void serialize() {
getPolymerElement().serialize();
}
/**
* Called to submit the form.
*
* JavaScript Info:
* @method submit
*
*/
public void submit() {
getPolymerElement().submit();
}
/**
*
*
* JavaScript Info:
* @property extends
* @type string
*
*/
public String getExtends(){
return getPolymerElement().getExtends();
}
/**
*
*
* JavaScript Info:
* @property extends
* @type string
*
*/
public void setExtends(String value) {
getPolymerElement().setExtends(value);
}
/**
* Fired after the form is submitted and an error is received.
*
* JavaScript Info:
* @property listeners
* @type Object
*
*/
public JavaScriptObject getListeners(){
return getPolymerElement().getListeners();
}
/**
* Fired after the form is submitted and an error is received.
*
* JavaScript Info:
* @property listeners
* @type Object
*
*/
public void setListeners(JavaScriptObject value) {
getPolymerElement().setListeners(value);
}
/**
* Fired after the form is submitted and an error is received.
*
* JavaScript Info:
* @event iron-form-error
*/
public HandlerRegistration addIronFormErrorHandler(IronFormErrorEventHandler handler) {
return addHandler(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 addHandler(handler, IronFormInvalidEvent.TYPE);
}
/**
* Fired after the form is submitted and a response is received.
*
* JavaScript Info:
* @event iron-form-response
*/
public HandlerRegistration addIronFormResponseHandler(IronFormResponseEventHandler handler) {
return addHandler(handler, IronFormResponseEvent.TYPE);
}
/**
* Fired after the form is submitted.
*
* JavaScript Info:
* @event iron-form-submit
*/
public HandlerRegistration addIronFormSubmitHandler(IronFormSubmitEventHandler handler) {
return addHandler(handler, IronFormSubmitEvent.TYPE);
}
}