com.vaadin.polymer.iron.widget.IronAjax Maven / Gradle / Ivy
/*
* This code was generated with Vaadin Web Component GWT API Generator,
* from iron-ajax 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.ErrorEvent;
import com.vaadin.polymer.iron.widget.event.ErrorEventHandler;
import com.vaadin.polymer.iron.widget.event.RequestEvent;
import com.vaadin.polymer.iron.widget.event.RequestEventHandler;
import com.vaadin.polymer.iron.widget.event.ResponseEvent;
import com.vaadin.polymer.iron.widget.event.ResponseEventHandler;
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;
/**
* The iron-ajax
element exposes network request functionality.
* <iron-ajax
* auto
* url="https://www.googleapis.com/youtube/v3/search"
* params='{"part":"snippet", "q":"polymer", "key": "YOUTUBE_API_KEY", "type": "video"}'
* handle-as="json"
* on-response="handleResponse"
* debounce-duration="300"></iron-ajax>
*
*
*
With auto
set to true
, the element performs a request whenever
its url
, params
or body
properties are changed. Automatically generated
requests will be debounced in the case that multiple attributes are changed
sequentially.
* Note: The params
attribute must be double quoted JSON.
* You can trigger a request explicitly by calling generateRequest
on the
element.
*/
public class IronAjax extends PolymerWidget {
/**
* Default Constructor.
*/
public IronAjax() {
this("");
}
/**
* Constructor used by UIBinder to create widgets with content.
*/
public IronAjax(String html) {
super(IronAjaxElement.TAG, IronAjaxElement.SRC, html);
}
/**
* Gets a handle to the Polymer object's underlying DOM element.
*/
public IronAjaxElement getPolymerElement() {
return (IronAjaxElement) getElement();
}
/**
* An Array of all in-flight requests originating from this iron-ajax
element.
*
* JavaScript Info:
* @property activeRequests
* @type Array
*
*/
public JsArray getActiveRequests() {
return getPolymerElement().getActiveRequests();
}
/**
* An Array of all in-flight requests originating from this iron-ajax
element.
*
* JavaScript Info:
* @property activeRequests
* @type Array
*
*/
public void setActiveRequests(JsArray value) {
getPolymerElement().setActiveRequests(value);
}
/**
* By default, iron-ajax’s events do not bubble. Setting this attribute will cause its
request and response events as well as its iron-ajax-request, -response, and -error
events to bubble to the window object. The vanilla error event never bubbles when
using shadow dom even if this.bubbles is true because a scoped flag is not passed with
it (first link) and because the shadow dom spec did not used to allow certain events,
including events named error, to leak outside of shadow trees (second link).
https://www.w3.org/TR/shadow-dom/#scoped-flag
https://www.w3.org/TR/2015/WD-shadow-dom-20151215/#events-that-are-not-leaked-into-ancestor-trees
*
* JavaScript Info:
* @property bubbles
* @type Boolean
*
*/
public boolean getBubbles() {
return getPolymerElement().getBubbles();
}
/**
* By default, iron-ajax’s events do not bubble. Setting this attribute will cause its
request and response events as well as its iron-ajax-request, -response, and -error
events to bubble to the window object. The vanilla error event never bubbles when
using shadow dom even if this.bubbles is true because a scoped flag is not passed with
it (first link) and because the shadow dom spec did not used to allow certain events,
including events named error, to leak outside of shadow trees (second link).
https://www.w3.org/TR/shadow-dom/#scoped-flag
https://www.w3.org/TR/2015/WD-shadow-dom-20151215/#events-that-are-not-leaked-into-ancestor-trees
*
* JavaScript Info:
* @property bubbles
* @type Boolean
*
*/
public void setBubbles(boolean value) {
getPolymerElement().setBubbles(value);
}
/**
* Set the withCredentials flag on the request.
*
* JavaScript Info:
* @property withCredentials
* @type Boolean
*
*/
public boolean getWithCredentials() {
return getPolymerElement().getWithCredentials();
}
/**
* Set the withCredentials flag on the request.
*
* JavaScript Info:
* @property withCredentials
* @type Boolean
*
*/
public void setWithCredentials(boolean value) {
getPolymerElement().setWithCredentials(value);
}
/**
* Length of time in milliseconds to debounce multiple automatically generated requests.
*
* JavaScript Info:
* @property debounceDuration
* @type Number
*
*/
public double getDebounceDuration() {
return getPolymerElement().getDebounceDuration();
}
/**
* Length of time in milliseconds to debounce multiple automatically generated requests.
*
* JavaScript Info:
* @property debounceDuration
* @type Number
*
*/
public void setDebounceDuration(double value) {
getPolymerElement().setDebounceDuration(value);
}
/**
* If true, error messages will automatically be logged to the console.
*
* JavaScript Info:
* @property verbose
* @type Boolean
*
*/
public boolean getVerbose() {
return getPolymerElement().getVerbose();
}
/**
* If true, error messages will automatically be logged to the console.
*
* JavaScript Info:
* @property verbose
* @type Boolean
*
*/
public void setVerbose(boolean value) {
getPolymerElement().setVerbose(value);
}
/**
* If true, automatically performs an Ajax request when either url
or
params
changes.
*
* JavaScript Info:
* @property auto
* @type Boolean
*
*/
public boolean getAuto() {
return getPolymerElement().getAuto();
}
/**
* If true, automatically performs an Ajax request when either url
or
params
changes.
*
* JavaScript Info:
* @property auto
* @type Boolean
*
*/
public void setAuto(boolean value) {
getPolymerElement().setAuto(value);
}
/**
* Set the timeout flag on the request.
*
* JavaScript Info:
* @property timeout
* @type Number
*
*/
public double getTimeout() {
return getPolymerElement().getTimeout();
}
/**
* Set the timeout flag on the request.
*
* JavaScript Info:
* @property timeout
* @type Number
*
*/
public void setTimeout(double value) {
getPolymerElement().setTimeout(value);
}
/**
* Toggle whether XHR is synchronous or asynchronous. Don’t change this
to true unless You Know What You Are Doing™.
*
* JavaScript Info:
* @property sync
* @type Boolean
*
*/
public boolean getSync() {
return getPolymerElement().getSync();
}
/**
* Toggle whether XHR is synchronous or asynchronous. Don’t change this
to true unless You Know What You Are Doing™.
*
* JavaScript Info:
* @property sync
* @type Boolean
*
*/
public void setSync(boolean value) {
getPolymerElement().setSync(value);
}
/**
* lastRequest’s error, if any.
*
* JavaScript Info:
* @property lastError
* @type Object
*
*/
public JavaScriptObject getLastError() {
return getPolymerElement().getLastError();
}
/**
* lastRequest’s error, if any.
*
* JavaScript Info:
* @property lastError
* @type Object
*
*/
public void setLastError(JavaScriptObject value) {
getPolymerElement().setLastError(value);
}
/**
* The most recent request made by this iron-ajax element.
*
* JavaScript Info:
* @property lastRequest
* @type Object
*
*/
public JavaScriptObject getLastRequest() {
return getPolymerElement().getLastRequest();
}
/**
* The most recent request made by this iron-ajax element.
*
* JavaScript Info:
* @property lastRequest
* @type Object
*
*/
public void setLastRequest(JavaScriptObject value) {
getPolymerElement().setLastRequest(value);
}
/**
* lastRequest’s response.
* Note that lastResponse and lastError are set when lastRequest finishes,
so if loading is true, then lastResponse and lastError will correspond
to the result of the previous request.
* The type of the response is determined by the value of handleAs
at
the time that the request was generated.
*
* JavaScript Info:
* @property lastResponse
* @type Object
*
*/
public JavaScriptObject getLastResponse() {
return getPolymerElement().getLastResponse();
}
/**
* lastRequest’s response.
* Note that lastResponse and lastError are set when lastRequest finishes,
so if loading is true, then lastResponse and lastError will correspond
to the result of the previous request.
* The type of the response is determined by the value of handleAs
at
the time that the request was generated.
*
* JavaScript Info:
* @property lastResponse
* @type Object
*
*/
public void setLastResponse(JavaScriptObject value) {
getPolymerElement().setLastResponse(value);
}
/**
* HTTP request headers to send.
* Example:
* <iron-ajax
* auto
* url="http://somesite.com"
* headers='{"X-Requested-With": "XMLHttpRequest"}'
* handle-as="json"></iron-ajax>
*
*
*
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.
* Example:
* <iron-ajax
* auto
* url="http://somesite.com"
* headers='{"X-Requested-With": "XMLHttpRequest"}'
* handle-as="json"></iron-ajax>
*
*
*
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);
}
/**
* An object that contains query parameters to be appended to the
specified url
when generating a request. If you wish to set the body
content when making a POST request, you should use the body
property
instead.
*
* JavaScript Info:
* @property params
* @type Object
*
*/
public JavaScriptObject getParams() {
return getPolymerElement().getParams();
}
/**
* An object that contains query parameters to be appended to the
specified url
when generating a request. If you wish to set the body
content when making a POST request, you should use the body
property
instead.
*
* JavaScript Info:
* @property params
* @type Object
*
*/
public void setParams(JavaScriptObject value) {
getPolymerElement().setParams(value);
}
/**
* Body content to send with the request, typically used with “POST”
requests.
* If body is a string it will be sent unmodified.
* If Content-Type is set to a value listed below, then
the body 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
*
*
*
* Otherwise the body will be passed to the browser unmodified, and it
will handle any encoding (e.g. for FormData, Blob, ArrayBuffer).
*
* JavaScript Info:
* @property body
* @type Object
*
*/
public JavaScriptObject getBody() {
return getPolymerElement().getBody();
}
/**
* Body content to send with the request, typically used with “POST”
requests.
* If body is a string it will be sent unmodified.
* If Content-Type is set to a value listed below, then
the body 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
*
*
*
* Otherwise the body will be passed to the browser unmodified, and it
will handle any encoding (e.g. for FormData, Blob, ArrayBuffer).
*
* JavaScript Info:
* @property body
* @type Object
*
*/
public void setBody(JavaScriptObject value) {
getPolymerElement().setBody(value);
}
/**
* True while lastRequest is in flight.
*
* JavaScript Info:
* @property loading
* @type Boolean
*
*/
public boolean getLoading() {
return getPolymerElement().getLoading();
}
/**
* True while lastRequest is in flight.
*
* JavaScript Info:
* @property loading
* @type Boolean
*
*/
public void setLoading(boolean value) {
getPolymerElement().setLoading(value);
}
/**
* The HTTP method to use such as ‘GET’, ‘POST’, ‘PUT’, or ‘DELETE’.
Default is ‘GET’.
*
* JavaScript Info:
* @property method
* @type String
*
*/
public String getMethod() {
return getPolymerElement().getMethod();
}
/**
* The HTTP method to use such as ‘GET’, ‘POST’, ‘PUT’, or ‘DELETE’.
Default is ‘GET’.
*
* JavaScript Info:
* @property method
* @type String
*
*/
public void setMethod(String value) {
getPolymerElement().setMethod(value);
}
/**
* Prefix to be stripped from a JSON response before parsing it.
* In order to prevent an attack using CSRF with Array responses
(http://haacked.com/archive/2008/11/20/anatomy-of-a-subtle-json-vulnerability.aspx/)
many backends will mitigate this by prefixing all JSON response bodies
with a string that would be nonsensical to a JavaScript parser.
*
* JavaScript Info:
* @property jsonPrefix
* @type String
*
*/
public String getJsonPrefix() {
return getPolymerElement().getJsonPrefix();
}
/**
* Prefix to be stripped from a JSON response before parsing it.
* In order to prevent an attack using CSRF with Array responses
(http://haacked.com/archive/2008/11/20/anatomy-of-a-subtle-json-vulnerability.aspx/)
many backends will mitigate this by prefixing all JSON response bodies
with a string that would be nonsensical to a JavaScript parser.
*
* JavaScript Info:
* @property jsonPrefix
* @type String
*
*/
public void setJsonPrefix(String value) {
getPolymerElement().setJsonPrefix(value);
}
/**
* The URL target of the request.
*
* JavaScript Info:
* @property url
* @type String
*
*/
public String getUrl() {
return getPolymerElement().getUrl();
}
/**
* The URL target of the request.
*
* JavaScript Info:
* @property url
* @type String
*
*/
public void setUrl(String value) {
getPolymerElement().setUrl(value);
}
/**
* Specifies what data to store in the response
property, and
to deliver as event.detail.response
in response
events.
* One of:
* text
: uses XHR.responseText
.
* xml
: uses XHR.responseXML
.
* json
: uses XHR.responseText
parsed as JSON.
* arraybuffer
: uses XHR.response
.
* blob
: uses XHR.response
.
* document
: uses XHR.response
.
*
* JavaScript Info:
* @property handleAs
* @type String
*
*/
public String getHandleAs() {
return getPolymerElement().getHandleAs();
}
/**
* Specifies what data to store in the response
property, and
to deliver as event.detail.response
in response
events.
* One of:
* text
: uses XHR.responseText
.
* xml
: uses XHR.responseXML
.
* json
: uses XHR.responseText
parsed as JSON.
* arraybuffer
: uses XHR.response
.
* blob
: uses XHR.response
.
* document
: uses XHR.response
.
*
* JavaScript Info:
* @property handleAs
* @type String
*
*/
public void setHandleAs(String value) {
getPolymerElement().setHandleAs(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.
* Varies the handling of the body
param.
*
* 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.
* Varies the handling of the body
param.
*
* JavaScript Info:
* @property contentType
* @type String
*
*/
public void setContentType(String value) {
getPolymerElement().setContentType(value);
}
// Needed in UIBinder
/**
* An Array of all in-flight requests originating from this iron-ajax
element.
*
* JavaScript Info:
* @attribute active-requests
*
*/
public void setActiveRequests(String value) {
Polymer.property(this.getPolymerElement(), "activeRequests", value);
}
// Needed in UIBinder
/**
* Length of time in milliseconds to debounce multiple automatically generated requests.
*
* JavaScript Info:
* @attribute debounce-duration
*
*/
public void setDebounceDuration(String value) {
Polymer.property(this.getPolymerElement(), "debounceDuration", value);
}
// Needed in UIBinder
/**
* Set the timeout flag on the request.
*
* JavaScript Info:
* @attribute timeout
*
*/
public void setTimeout(String value) {
Polymer.property(this.getPolymerElement(), "timeout", value);
}
// Needed in UIBinder
/**
* The most recent request made by this iron-ajax element.
*
* JavaScript Info:
* @attribute last-request
*
*/
public void setLastRequest(String value) {
Polymer.property(this.getPolymerElement(), "lastRequest", value);
}
// Needed in UIBinder
/**
* lastRequest’s response.
* Note that lastResponse and lastError are set when lastRequest finishes,
so if loading is true, then lastResponse and lastError will correspond
to the result of the previous request.
* The type of the response is determined by the value of handleAs
at
the time that the request was generated.
*
* JavaScript Info:
* @attribute last-response
*
*/
public void setLastResponse(String value) {
Polymer.property(this.getPolymerElement(), "lastResponse", value);
}
// Needed in UIBinder
/**
* HTTP request headers to send.
* Example:
* <iron-ajax
* auto
* url="http://somesite.com"
* headers='{"X-Requested-With": "XMLHttpRequest"}'
* handle-as="json"></iron-ajax>
*
*
*
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);
}
// Needed in UIBinder
/**
* An object that contains query parameters to be appended to the
specified url
when generating a request. If you wish to set the body
content when making a POST request, you should use the body
property
instead.
*
* JavaScript Info:
* @attribute params
*
*/
public void setParams(String value) {
Polymer.property(this.getPolymerElement(), "params", value);
}
// Needed in UIBinder
/**
* Body content to send with the request, typically used with “POST”
requests.
* If body is a string it will be sent unmodified.
* If Content-Type is set to a value listed below, then
the body 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
*
*
*
* Otherwise the body will be passed to the browser unmodified, and it
will handle any encoding (e.g. for FormData, Blob, ArrayBuffer).
*
* JavaScript Info:
* @attribute body
*
*/
public void setBody(String value) {
Polymer.property(this.getPolymerElement(), "body", value);
}
// Needed in UIBinder
/**
* lastRequest’s error, if any.
*
* JavaScript Info:
* @attribute last-error
*
*/
public void setLastError(String value) {
Polymer.property(this.getPolymerElement(), "lastError", value);
}
/**
* Performs an AJAX request to the specified URL.
*
* JavaScript Info:
* @method generateRequest
*
* @return {JavaScriptObject}
*/
public JavaScriptObject generateRequest() {
return getPolymerElement().generateRequest();
}
/**
* Request options suitable for generating an iron-request
instance based
on the current state of the iron-ajax
instance’s properties.
*
* JavaScript Info:
* @method toRequestOptions
*
* @return {Object}
*/
public Object toRequestOptions() {
return getPolymerElement().toRequestOptions();
}
/**
* Fired when an error is received.
*
* JavaScript Info:
* @event error
*/
public HandlerRegistration addErrorHandler(ErrorEventHandler handler) {
return addDomHandler(handler, ErrorEvent.TYPE);
}
/**
* Fired when a request is sent.
*
* JavaScript Info:
* @event request
*/
public HandlerRegistration addRequestHandler(RequestEventHandler handler) {
return addDomHandler(handler, RequestEvent.TYPE);
}
/**
* Fired when a response is received.
*
* JavaScript Info:
* @event response
*/
public HandlerRegistration addResponseHandler(ResponseEventHandler handler) {
return addDomHandler(handler, ResponseEvent.TYPE);
}
}