Observable DataProxy ScriptTagProxy
Package: | Ext.data |
Defined In: | ScriptTagProxy.js |
Class: | ScriptTagProxy |
Extends: | DataProxy |
Note that if you are retrieving data from a page that is in a domain that is NOT the same as the originating domain
of the running page, you must use this class, rather than HttpProxy.
The content passed back from a server resource requested by a ScriptTagProxy must be executable JavaScript
source code because it is used as the source inside a <script> tag.
In order for the browser to process the returned data, the server must wrap the data object with a call to a callback function, the name of which is passed as a parameter by the ScriptTagProxy. Below is a Java example for a servlet which returns data for either a ScriptTagProxy, or an HttpProxy depending on whether the callback name was passed:
boolean scriptTag = false;
String cb = request.getParameter("callback");
if (cb != null) {
scriptTag = true;
response.setContentType("text/javascript");
} else {
response.setContentType("application/x-json");
}
Writer out = response.getWriter();
if (scriptTag) {
out.write(cb + "(");
}
out.print(dataBlock.toJsonString());
if (scriptTag) {
out.write(");");
}
Config Options | Defined By | |
---|---|---|
callbackParam : String (Optional) The name of the parameter to pass to the server which tells the server the name of the callback function s...
(Optional) The name of the parameter to pass to the server which tells the server the name of the callback function set up by the load call to process the returned data object. Defaults to "callback".
The server-side processing must read this parameter value, and generate javascript output which calls this named function passing the data object as its only parameter. |
ScriptTagProxy | |
listeners : Object A config object containing one or more event handlers to be added to this object during initialization. This should b...
A config object containing one or more event handlers to be added to this object during initialization. This should be a valid listeners config object as specified in the addListener example for attaching multiple handlers at once.
|
Observable | |
nocache : Boolean
(optional) Defaults to true. Disable caching by adding a unique parameter name to the request.
|
ScriptTagProxy | |
timeout : Number
(optional) The number of milliseconds to wait for a response. Defaults to 30 seconds.
|
ScriptTagProxy | |
url : String
The URL from which to request the data object.
|
ScriptTagProxy |
Method | Defined By | |
---|---|---|
ScriptTagProxy( Object config )
Parameters:
|
ScriptTagProxy | |
abort() : void Abort the current server request.
Abort the current server request.
Parameters:
|
ScriptTagProxy | |
addEvents( Object object ) : void Used to define events on this Observable
Used to define events on this Observable
Parameters:
|
Observable | |
addListener( String eventName , Function handler , [Object scope ], [Object options ] ) : void Appends an event handler to this component
Appends an event handler to this component
Parameters:
|
Observable | |
fireEvent( String eventName , Object... args ) : Boolean Fires the specified event with the passed parameters (minus the event name).
Fires the specified event with the passed parameters (minus the event name).
Parameters:
|
Observable | |
hasListener( String eventName ) : Boolean Checks to see if this object has any listeners for a specified event
Checks to see if this object has any listeners for a specified event
Parameters:
|
Observable | |
load( Object params , Ext.data.DataReader reader , Function callback , Object scope , Object arg ) : void Load data from the configured URL, read the data object into
a block of Ext.data.Records using the passed Ext.data.Da...
Load data from the configured URL, read the data object into
a block of Ext.data.Records using the passed Ext.data.DataReader implementation, and
process that block using the passed callback.
Parameters:
|
ScriptTagProxy | |
on( String eventName , Function handler , [Object scope ], [Object options ] ) : void Appends an event handler to this element (shorthand for addListener)
Appends an event handler to this element (shorthand for addListener)
Parameters:
|
Observable | |
purgeListeners() : void Removes all listeners for this object
Removes all listeners for this object
Parameters:
|
Observable | |
relayEvents( Object o , Array events ) : void Relays selected events from the specified Observable as if the events were fired by this.
Relays selected events from the specified Observable as if the events were fired by this.
Parameters:
|
Observable | |
removeListener( String eventName , Function handler , [Object scope ] ) : void Removes a listener
Removes a listener
Parameters:
|
Observable | |
resumeEvents() : void Resume firing events. (see suspendEvents)
Resume firing events. (see suspendEvents)
Parameters:
|
Observable | |
suspendEvents() : void Suspend the firing of all events. (see resumeEvents)
Suspend the firing of all events. (see resumeEvents)
Parameters:
|
Observable | |
un( String eventName , Function handler , [Object scope ] ) : void Removes a listener (shorthand for removeListener)
Removes a listener (shorthand for removeListener)
Parameters:
|
Observable |
Event | Defined By | |
---|---|---|
beforeload : ( Object this , Object params ) Fires before a network request is made to retrieve a data object.
Fires before a network request is made to retrieve a data object.
Listeners will be called with the following arguments:
|
DataProxy | |
load : ( Object this , Object o , Object arg ) Fires before the load method's callback is called.
Fires before the load method's callback is called.
Listeners will be called with the following arguments:
|
DataProxy | |
loadexception : ( Object this , Object options , Object arg , Error e ) Fires if an exception occurs in the Proxy during data loading. This event can be fired for one of two reasons:
The l...
Fires if an exception occurs in the Proxy during data loading. This event can be fired for one of two reasons:
Listeners will be called with the following arguments:
|
ScriptTagProxy |