+<!DOCTYPE html>
<html>
<head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>The source code</title>
- <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
- <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
+ <link href="../prettify/prettify.css" type="text/css" rel="stylesheet" />
+ <script type="text/javascript" src="../prettify/prettify.js"></script>
+ <style type="text/css">
+ .highlight { display: block; background-color: #ddd; }
+ </style>
+ <script type="text/javascript">
+ function highlight() {
+ document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
+ }
+ </script>
</head>
-<body onload="prettyPrint();">
- <pre class="prettyprint lang-js">/*!
- * Ext JS Library 3.2.0
- * Copyright(c) 2006-2010 Ext JS, Inc.
- * licensing@extjs.com
- * http://www.extjs.com/license
- */
-<div id="cls-Ext.form.Action"></div>/**
- * @class Ext.form.Action
- * <p>The subclasses of this class provide actions to perform upon {@link Ext.form.BasicForm Form}s.</p>
- * <p>Instances of this class are only created by a {@link Ext.form.BasicForm Form} when
+<body onload="prettyPrint(); highlight();">
+ <pre class="prettyprint lang-js"><span id='Ext-form-action-Action'>/**
+</span> * @class Ext.form.action.Action
+ * @extends Ext.Base
+ * <p>The subclasses of this class provide actions to perform upon {@link Ext.form.Basic Form}s.</p>
+ * <p>Instances of this class are only created by a {@link Ext.form.Basic Form} when
* the Form needs to perform an action such as submit or load. The Configuration options
- * listed for this class are set through the Form's action methods: {@link Ext.form.BasicForm#submit submit},
- * {@link Ext.form.BasicForm#load load} and {@link Ext.form.BasicForm#doAction doAction}</p>
- * <p>The instance of Action which performed the action is passed to the success
- * and failure callbacks of the Form's action methods ({@link Ext.form.BasicForm#submit submit},
- * {@link Ext.form.BasicForm#load load} and {@link Ext.form.BasicForm#doAction doAction}),
- * and to the {@link Ext.form.BasicForm#actioncomplete actioncomplete} and
- * {@link Ext.form.BasicForm#actionfailed actionfailed} event handlers.</p>
- */
-Ext.form.Action = function(form, options){
- this.form = form;
- this.options = options || {};
-};
-
-<div id="prop-Ext.form.Action-CLIENT_INVALID"></div>/**
- * Failure type returned when client side validation of the Form fails
- * thus aborting a submit action. Client side validation is performed unless
- * {@link #clientValidation} is explicitly set to <tt>false</tt>.
- * @type {String}
- * @static
- */
-Ext.form.Action.CLIENT_INVALID = 'client';
-<div id="prop-Ext.form.Action-SERVER_INVALID"></div>/**
- * <p>Failure type returned when server side processing fails and the {@link #result}'s
- * <tt style="font-weight:bold">success</tt> property is set to <tt>false</tt>.</p>
- * <p>In the case of a form submission, field-specific error messages may be returned in the
- * {@link #result}'s <tt style="font-weight:bold">errors</tt> property.</p>
- * @type {String}
- * @static
- */
-Ext.form.Action.SERVER_INVALID = 'server';
-<div id="prop-Ext.form.Action-CONNECT_FAILURE"></div>/**
- * Failure type returned when a communication error happens when attempting
- * to send a request to the remote server. The {@link #response} may be examined to
- * provide further information.
- * @type {String}
- * @static
+ * listed for this class are set through the Form's action methods: {@link Ext.form.Basic#submit submit},
+ * {@link Ext.form.Basic#load load} and {@link Ext.form.Basic#doAction doAction}</p>
+ * <p>The instance of Action which performed the action is passed to the success
+ * and failure callbacks of the Form's action methods ({@link Ext.form.Basic#submit submit},
+ * {@link Ext.form.Basic#load load} and {@link Ext.form.Basic#doAction doAction}),
+ * and to the {@link Ext.form.Basic#actioncomplete actioncomplete} and
+ * {@link Ext.form.Basic#actionfailed actionfailed} event handlers.</p>
*/
-Ext.form.Action.CONNECT_FAILURE = 'connect';
-<div id="prop-Ext.form.Action-LOAD_FAILURE"></div>/**
- * Failure type returned when the response's <tt style="font-weight:bold">success</tt>
- * property is set to <tt>false</tt>, or no field values are returned in the response's
- * <tt style="font-weight:bold">data</tt> property.
- * @type {String}
- * @static
- */
-Ext.form.Action.LOAD_FAILURE = 'load';
+Ext.define('Ext.form.action.Action', {
+ alternateClassName: 'Ext.form.Action',
-Ext.form.Action.prototype = {
-<div id="cfg-Ext.form.Action-url"></div>/**
- * @cfg {String} url The URL that the Action is to invoke.
- */
-<div id="cfg-Ext.form.Action-reset"></div>/**
- * @cfg {Boolean} reset When set to <tt><b>true</b></tt>, causes the Form to be
- * {@link Ext.form.BasicForm.reset reset} on Action success. If specified, this happens
- * <b>before</b> the {@link #success} callback is called and before the Form's
- * {@link Ext.form.BasicForm.actioncomplete actioncomplete} event fires.
- */
-<div id="cfg-Ext.form.Action-method"></div>/**
- * @cfg {String} method The HTTP method to use to access the requested URL. Defaults to the
- * {@link Ext.form.BasicForm}'s method, or if that is not specified, the underlying DOM form's method.
- */
-<div id="cfg-Ext.form.Action-params"></div>/**
- * @cfg {Mixed} params <p>Extra parameter values to pass. These are added to the Form's
- * {@link Ext.form.BasicForm#baseParams} and passed to the specified URL along with the Form's
- * input fields.</p>
- * <p>Parameters are encoded as standard HTTP parameters using {@link Ext#urlEncode}.</p>
- */
-<div id="cfg-Ext.form.Action-timeout"></div>/**
- * @cfg {Number} timeout The number of seconds to wait for a server response before
- * failing with the {@link #failureType} as {@link #Action.CONNECT_FAILURE}. If not specified,
- * defaults to the configured <tt>{@link Ext.form.BasicForm#timeout timeout}</tt> of the
- * {@link Ext.form.BasicForm form}.
- */
-<div id="cfg-Ext.form.Action-success"></div>/**
- * @cfg {Function} success The function to call when a valid success return packet is recieved.
- * The function is passed the following parameters:<ul class="mdetail-params">
- * <li><b>form</b> : Ext.form.BasicForm<div class="sub-desc">The form that requested the action</div></li>
- * <li><b>action</b> : Ext.form.Action<div class="sub-desc">The Action class. The {@link #result}
- * property of this object may be examined to perform custom postprocessing.</div></li>
- * </ul>
- */
-<div id="cfg-Ext.form.Action-failure"></div>/**
- * @cfg {Function} failure The function to call when a failure packet was recieved, or when an
- * error ocurred in the Ajax communication.
- * The function is passed the following parameters:<ul class="mdetail-params">
- * <li><b>form</b> : Ext.form.BasicForm<div class="sub-desc">The form that requested the action</div></li>
- * <li><b>action</b> : Ext.form.Action<div class="sub-desc">The Action class. If an Ajax
- * error ocurred, the failure type will be in {@link #failureType}. The {@link #result}
- * property of this object may be examined to perform custom postprocessing.</div></li>
- * </ul>
- */
-<div id="cfg-Ext.form.Action-scope"></div>/**
- * @cfg {Object} scope The scope in which to call the callback functions (The <tt>this</tt> reference
- * for the callback functions).
- */
-<div id="cfg-Ext.form.Action-waitMsg"></div>/**
- * @cfg {String} waitMsg The message to be displayed by a call to {@link Ext.MessageBox#wait}
- * during the time the action is being processed.
- */
-<div id="cfg-Ext.form.Action-waitTitle"></div>/**
- * @cfg {String} waitTitle The title to be displayed by a call to {@link Ext.MessageBox#wait}
- * during the time the action is being processed.
- */
+<span id='Ext-form-action-Action-cfg-form'> /**
+</span> * @cfg {Ext.form.Basic} form The {@link Ext.form.Basic BasicForm} instance that
+ * is invoking this Action. Required.
+ */
-<div id="cfg-Ext.form.Action-submitEmptyText"></div>/**
- * @cfg {Boolean} submitEmptyText If set to <tt>true</tt>, the emptyText value will be sent with the form
- * when it is submitted. Defaults to <tt>true</tt>.
- */
+<span id='Ext-form-action-Action-cfg-url'> /**
+</span> * @cfg {String} url The URL that the Action is to invoke. Will default to the {@link Ext.form.Basic#url url}
+ * configured on the {@link #form}.
+ */
-<div id="prop-Ext.form.Action-type"></div>/**
- * The type of action this Action instance performs.
- * Currently only "submit" and "load" are supported.
- * @type {String}
- */
- type : 'default',
-<div id="prop-Ext.form.Action-failureType"></div>/**
- * The type of failure detected will be one of these: {@link #CLIENT_INVALID},
- * {@link #SERVER_INVALID}, {@link #CONNECT_FAILURE}, or {@link #LOAD_FAILURE}. Usage:
- * <pre><code>
-var fp = new Ext.form.FormPanel({
+<span id='Ext-form-action-Action-cfg-reset'> /**
+</span> * @cfg {Boolean} reset When set to <tt><b>true</b></tt>, causes the Form to be
+ * {@link Ext.form.Basic#reset reset} on Action success. If specified, this happens
+ * before the {@link #success} callback is called and before the Form's
+ * {@link Ext.form.Basic#actioncomplete actioncomplete} event fires.
+ */
+
+<span id='Ext-form-action-Action-cfg-method'> /**
+</span> * @cfg {String} method The HTTP method to use to access the requested URL. Defaults to the
+ * {@link Ext.form.Basic#method BasicForm's method}, or 'POST' if not specified.
+ */
+
+<span id='Ext-form-action-Action-cfg-params'> /**
+</span> * @cfg {Object/String} params <p>Extra parameter values to pass. These are added to the Form's
+ * {@link Ext.form.Basic#baseParams} and passed to the specified URL along with the Form's
+ * input fields.</p>
+ * <p>Parameters are encoded as standard HTTP parameters using {@link Ext#urlEncode Ext.Object.toQueryString}.</p>
+ */
+
+<span id='Ext-form-action-Action-cfg-headers'> /**
+</span> * @cfg {Object} headers <p>Extra headers to be sent in the AJAX request for submit and load actions. See
+ * {@link Ext.data.Connection#headers}.</p>
+ */
+
+<span id='Ext-form-action-Action-cfg-timeout'> /**
+</span> * @cfg {Number} timeout The number of seconds to wait for a server response before
+ * failing with the {@link #failureType} as {@link Ext.form.action.Action#CONNECT_FAILURE}. If not specified,
+ * defaults to the configured <tt>{@link Ext.form.Basic#timeout timeout}</tt> of the
+ * {@link #form}.
+ */
+
+<span id='Ext-form-action-Action-cfg-success'> /**
+</span> * @cfg {Function} success The function to call when a valid success return packet is received.
+ * The function is passed the following parameters:<ul class="mdetail-params">
+ * <li><b>form</b> : Ext.form.Basic<div class="sub-desc">The form that requested the action</div></li>
+ * <li><b>action</b> : Ext.form.action.Action<div class="sub-desc">The Action class. The {@link #result}
+ * property of this object may be examined to perform custom postprocessing.</div></li>
+ * </ul>
+ */
+
+<span id='Ext-form-action-Action-cfg-failure'> /**
+</span> * @cfg {Function} failure The function to call when a failure packet was received, or when an
+ * error ocurred in the Ajax communication.
+ * The function is passed the following parameters:<ul class="mdetail-params">
+ * <li><b>form</b> : Ext.form.Basic<div class="sub-desc">The form that requested the action</div></li>
+ * <li><b>action</b> : Ext.form.action.Action<div class="sub-desc">The Action class. If an Ajax
+ * error ocurred, the failure type will be in {@link #failureType}. The {@link #result}
+ * property of this object may be examined to perform custom postprocessing.</div></li>
+ * </ul>
+ */
+
+<span id='Ext-form-action-Action-cfg-scope'> /**
+</span> * @cfg {Object} scope The scope in which to call the configured <tt>success</tt> and <tt>failure</tt>
+ * callback functions (the <tt>this</tt> reference for the callback functions).
+ */
+
+<span id='Ext-form-action-Action-cfg-waitMsg'> /**
+</span> * @cfg {String} waitMsg The message to be displayed by a call to {@link Ext.window.MessageBox#wait}
+ * during the time the action is being processed.
+ */
+
+<span id='Ext-form-action-Action-cfg-waitTitle'> /**
+</span> * @cfg {String} waitTitle The title to be displayed by a call to {@link Ext.window.MessageBox#wait}
+ * during the time the action is being processed.
+ */
+
+<span id='Ext-form-action-Action-cfg-submitEmptyText'> /**
+</span> * @cfg {Boolean} submitEmptyText If set to <tt>true</tt>, the emptyText value will be sent with the form
+ * when it is submitted. Defaults to <tt>true</tt>.
+ */
+
+<span id='Ext-form-action-Action-property-type'> /**
+</span> * @property type
+ * The type of action this Action instance performs.
+ * Currently only "submit" and "load" are supported.
+ * @type {String}
+ */
+
+<span id='Ext-form-action-Action-property-failureType'> /**
+</span> * The type of failure detected will be one of these: {@link Ext.form.action.Action#CLIENT_INVALID},
+ * {@link Ext.form.action.Action#SERVER_INVALID}, {@link Ext.form.action.Action#CONNECT_FAILURE}, or
+ * {@link Ext.form.action.Action#LOAD_FAILURE}. Usage:
+ * <pre><code>
+var fp = new Ext.form.Panel({
...
buttons: [{
text: 'Save',
var result = action.{@link #result};
},
failure: function(form, action){
- if (action.{@link #failureType} === Ext.form.Action.{@link #CONNECT_FAILURE}) {
+ if (action.{@link #failureType} === {@link Ext.form.action.Action#CONNECT_FAILURE}) {
Ext.Msg.alert('Error',
'Status:'+action.{@link #response}.status+': '+
action.{@link #response}.statusText);
}
- if (action.failureType === Ext.form.Action.{@link #SERVER_INVALID}){
+ if (action.failureType === {@link Ext.form.action.Action#SERVER_INVALID}){
// server responded with success = false
Ext.Msg.alert('Invalid', action.{@link #result}.errormsg);
}
fp.getForm().reset();
}
}]
- * </code></pre>
- * @property failureType
- * @type {String}
- */
- <div id="prop-Ext.form.Action-response"></div>/**
- * The XMLHttpRequest object used to perform the action.
- * @property response
- * @type {Object}
- */
- <div id="prop-Ext.form.Action-result"></div>/**
- * The decoded response object containing a boolean <tt style="font-weight:bold">success</tt> property and
- * other, action-specific properties.
- * @property result
- * @type {Object}
- */
+ * </code></pre>
+ * @property failureType
+ * @type {String}
+ */
- // interface method
- run : function(options){
+<span id='Ext-form-action-Action-property-response'> /**
+</span> * The raw XMLHttpRequest object used to perform the action.
+ * @property response
+ * @type {Object}
+ */
- },
+<span id='Ext-form-action-Action-property-result'> /**
+</span> * The decoded response object containing a boolean <tt>success</tt> property and
+ * other, action-specific properties.
+ * @property result
+ * @type {Object}
+ */
- // interface method
- success : function(response){
+<span id='Ext-form-action-Action-method-constructor'> /**
+</span> * Creates new Action.
+ * @param {Object} config (optional) Config object.
+ */
+ constructor: function(config) {
+ if (config) {
+ Ext.apply(this, config);
+ }
+ // Normalize the params option to an Object
+ var params = config.params;
+ if (Ext.isString(params)) {
+ this.params = Ext.Object.fromQueryString(params);
+ }
},
- // interface method
- handleResponse : function(response){
+<span id='Ext-form-action-Action-property-run'> /**
+</span> * Invokes this action using the current configuration.
+ */
+ run: Ext.emptyFn,
- },
+<span id='Ext-form-action-Action-method-onSuccess'> /**
+</span> * @private
+ * @method onSuccess
+ * Callback method that gets invoked when the action completes successfully. Must be implemented by subclasses.
+ * @param {Object} response
+ */
+
+<span id='Ext-form-action-Action-method-handleResponse'> /**
+</span> * @private
+ * @method handleResponse
+ * Handles the raw response and builds a result object from it. Must be implemented by subclasses.
+ * @param {Object} response
+ */
- // default connection failure
- failure : function(response){
+<span id='Ext-form-action-Action-method-onFailure'> /**
+</span> * @private
+ * Handles a failure response.
+ * @param {Object} response
+ */
+ onFailure : function(response){
this.response = response;
- this.failureType = Ext.form.Action.CONNECT_FAILURE;
+ this.failureType = Ext.form.action.Action.CONNECT_FAILURE;
this.form.afterAction(this, false);
},
- // private
- // shared code among all Actions to validate that there was a response
- // with either responseText or responseXml
+<span id='Ext-form-action-Action-method-processResponse'> /**
+</span> * @private
+ * Validates that a response contains either responseText or responseXML and invokes
+ * {@link #handleResponse} to build the result object.
+ * @param {Object} response The raw response object.
+ * @return {Object/Boolean} result The result object as built by handleResponse, or <tt>true</tt> if
+ * the response had empty responseText and responseXML.
+ */
processResponse : function(response){
this.response = response;
- if(!response.responseText && !response.responseXML){
+ if (!response.responseText && !response.responseXML) {
return true;
}
- this.result = this.handleResponse(response);
- return this.result;
+ return (this.result = this.handleResponse(response));
},
- // utility functions used internally
- getUrl : function(appendParams){
- var url = this.options.url || this.form.url || this.form.el.dom.action;
- if(appendParams){
- var p = this.getParams();
- if(p){
- url = Ext.urlAppend(url, p);
- }
- }
- return url;
+<span id='Ext-form-action-Action-method-getUrl'> /**
+</span> * @private
+ * Build the URL for the AJAX request. Used by the standard AJAX submit and load actions.
+ * @return {String} The URL.
+ */
+ getUrl: function() {
+ return this.url || this.form.url;
},
- // private
- getMethod : function(){
- return (this.options.method || this.form.method || this.form.el.dom.method || 'POST').toUpperCase();
+<span id='Ext-form-action-Action-method-getMethod'> /**
+</span> * @private
+ * Determine the HTTP method to be used for the request.
+ * @return {String} The HTTP method
+ */
+ getMethod: function() {
+ return (this.method || this.form.method || 'POST').toUpperCase();
},
- // private
- getParams : function(){
- var bp = this.form.baseParams;
- var p = this.options.params;
- if(p){
- if(typeof p == "object"){
- p = Ext.urlEncode(Ext.applyIf(p, bp));
- }else if(typeof p == 'string' && bp){
- p += '&' + Ext.urlEncode(bp);
- }
- }else if(bp){
- p = Ext.urlEncode(bp);
- }
- return p;
+<span id='Ext-form-action-Action-method-getParams'> /**
+</span> * @private
+ * Get the set of parameters specified in the BasicForm's baseParams and/or the params option.
+ * Items in params override items of the same name in baseParams.
+ * @return {Object} the full set of parameters
+ */
+ getParams: function() {
+ return Ext.apply({}, this.params, this.form.baseParams);
},
- // private
- createCallback : function(opts){
- var opts = opts || {};
+<span id='Ext-form-action-Action-method-createCallback'> /**
+</span> * @private
+ * Creates a callback object.
+ */
+ createCallback: function() {
+ var me = this,
+ undef,
+ form = me.form;
return {
- success: this.success,
- failure: this.failure,
- scope: this,
- timeout: (opts.timeout*1000) || (this.form.timeout*1000),
- upload: this.form.fileUpload ? this.success : undefined
+ success: me.onSuccess,
+ failure: me.onFailure,
+ scope: me,
+ timeout: (this.timeout * 1000) || (form.timeout * 1000),
+ upload: form.fileUpload ? me.onSuccess : undef
};
- }
-};
-
-<div id="cls-Ext.form.Action.Submit"></div>/**
- * @class Ext.form.Action.Submit
- * @extends Ext.form.Action
- * <p>A class which handles submission of data from {@link Ext.form.BasicForm Form}s
- * and processes the returned response.</p>
- * <p>Instances of this class are only created by a {@link Ext.form.BasicForm Form} when
- * {@link Ext.form.BasicForm#submit submit}ting.</p>
- * <p><u><b>Response Packet Criteria</b></u></p>
- * <p>A response packet may contain:
- * <div class="mdetail-params"><ul>
- * <li><b><code>success</code></b> property : Boolean
- * <div class="sub-desc">The <code>success</code> property is required.</div></li>
- * <li><b><code>errors</code></b> property : Object
- * <div class="sub-desc"><div class="sub-desc">The <code>errors</code> property,
- * which is optional, contains error messages for invalid fields.</div></li>
- * </ul></div>
- * <p><u><b>JSON Packets</b></u></p>
- * <p>By default, response packets are assumed to be JSON, so a typical response
- * packet may look like this:</p><pre><code>
-{
- success: false,
- errors: {
- clientCode: "Client not found",
- portOfLoading: "This field must not be null"
- }
-}</code></pre>
- * <p>Other data may be placed into the response for processing by the {@link Ext.form.BasicForm}'s callback
- * or event handler methods. The object decoded from this JSON is available in the
- * {@link Ext.form.Action#result result} property.</p>
- * <p>Alternatively, if an {@link #errorReader} is specified as an {@link Ext.data.XmlReader XmlReader}:</p><pre><code>
- errorReader: new Ext.data.XmlReader({
- record : 'field',
- success: '@success'
- }, [
- 'id', 'msg'
- ]
- )
-</code></pre>
- * <p>then the results may be sent back in XML format:</p><pre><code>
-<?xml version="1.0" encoding="UTF-8"?>
-<message success="false">
-<errors>
- <field>
- <id>clientCode</id>
- <msg><![CDATA[Code not found. <br /><i>This is a test validation message from the server </i>]]></msg>
- </field>
- <field>
- <id>portOfLoading</id>
- <msg><![CDATA[Port not found. <br /><i>This is a test validation message from the server </i>]]></msg>
- </field>
-</errors>
-</message>
-</code></pre>
- * <p>Other elements may be placed into the response XML for processing by the {@link Ext.form.BasicForm}'s callback
- * or event handler methods. The XML document is available in the {@link #errorReader}'s {@link Ext.data.XmlReader#xmlData xmlData} property.</p>
- */
-Ext.form.Action.Submit = function(form, options){
- Ext.form.Action.Submit.superclass.constructor.call(this, form, options);
-};
-
-Ext.extend(Ext.form.Action.Submit, Ext.form.Action, {
- <div id="cfg-Ext.form.Action.Submit-errorReader"></div>/**
- * @cfg {Ext.data.DataReader} errorReader <p><b>Optional. JSON is interpreted with
- * no need for an errorReader.</b></p>
- * <p>A Reader which reads a single record from the returned data. The DataReader's
- * <b>success</b> property specifies how submission success is determined. The Record's
- * data provides the error messages to apply to any invalid form Fields.</p>
- */
- <div id="cfg-Ext.form.Action.Submit-clientValidation"></div>/**
- * @cfg {boolean} clientValidation Determines whether a Form's fields are validated
- * in a final call to {@link Ext.form.BasicForm#isValid isValid} prior to submission.
- * Pass <tt>false</tt> in the Form's submit options to prevent this. If not defined, pre-submission field validation
- * is performed.
- */
- type : 'submit',
-
- // private
- run : function(){
- var o = this.options,
- method = this.getMethod(),
- isGet = method == 'GET';
- if(o.clientValidation === false || this.form.isValid()){
- if (o.submitEmptyText === false) {
- var fields = this.form.items,
- emptyFields = [];
- fields.each(function(f) {
- if (f.el.getValue() == f.emptyText) {
- emptyFields.push(f);
- f.el.dom.value = "";
- }
- });
- }
- Ext.Ajax.request(Ext.apply(this.createCallback(o), {
- form:this.form.el.dom,
- url:this.getUrl(isGet),
- method: method,
- headers: o.headers,
- params:!isGet ? this.getParams() : null,
- isUpload: this.form.fileUpload
- }));
- if (o.submitEmptyText === false) {
- Ext.each(emptyFields, function(f) {
- if (f.applyEmptyText) {
- f.applyEmptyText();
- }
- });
- }
- }else if (o.clientValidation !== false){ // client validation failed
- this.failureType = Ext.form.Action.CLIENT_INVALID;
- this.form.afterAction(this, false);
- }
- },
-
- // private
- success : function(response){
- var result = this.processResponse(response);
- if(result === true || result.success){
- this.form.afterAction(this, true);
- return;
- }
- if(result.errors){
- this.form.markInvalid(result.errors);
- }
- this.failureType = Ext.form.Action.SERVER_INVALID;
- this.form.afterAction(this, false);
- },
-
- // private
- handleResponse : function(response){
- if(this.form.errorReader){
- var rs = this.form.errorReader.read(response);
- var errors = [];
- if(rs.records){
- for(var i = 0, len = rs.records.length; i < len; i++) {
- var r = rs.records[i];
- errors[i] = r.data;
- }
- }
- if(errors.length < 1){
- errors = null;
- }
- return {
- success : rs.success,
- errors : errors
- };
- }
- return Ext.decode(response.responseText);
- }
-});
-
-
-<div id="cls-Ext.form.Action.Load"></div>/**
- * @class Ext.form.Action.Load
- * @extends Ext.form.Action
- * <p>A class which handles loading of data from a server into the Fields of an {@link Ext.form.BasicForm}.</p>
- * <p>Instances of this class are only created by a {@link Ext.form.BasicForm Form} when
- * {@link Ext.form.BasicForm#load load}ing.</p>
- * <p><u><b>Response Packet Criteria</b></u></p>
- * <p>A response packet <b>must</b> contain:
- * <div class="mdetail-params"><ul>
- * <li><b><code>success</code></b> property : Boolean</li>
- * <li><b><code>data</code></b> property : Object</li>
- * <div class="sub-desc">The <code>data</code> property contains the values of Fields to load.
- * The individual value object for each Field is passed to the Field's
- * {@link Ext.form.Field#setValue setValue} method.</div></li>
- * </ul></div>
- * <p><u><b>JSON Packets</b></u></p>
- * <p>By default, response packets are assumed to be JSON, so for the following form load call:<pre><code>
-var myFormPanel = new Ext.form.FormPanel({
- title: 'Client and routing info',
- items: [{
- fieldLabel: 'Client',
- name: 'clientName'
- }, {
- fieldLabel: 'Port of loading',
- name: 'portOfLoading'
- }, {
- fieldLabel: 'Port of discharge',
- name: 'portOfDischarge'
- }]
-});
-myFormPanel.{@link Ext.form.FormPanel#getForm getForm}().{@link Ext.form.BasicForm#load load}({
- url: '/getRoutingInfo.php',
- params: {
- consignmentRef: myConsignmentRef
},
- failure: function(form, action) {
- Ext.Msg.alert("Load failed", action.result.errorMessage);
- }
-});
-</code></pre>
- * a <b>success response</b> packet may look like this:</p><pre><code>
-{
- success: true,
- data: {
- clientName: "Fred. Olsen Lines",
- portOfLoading: "FXT",
- portOfDischarge: "OSL"
- }
-}</code></pre>
- * while a <b>failure response</b> packet may look like this:</p><pre><code>
-{
- success: false,
- errorMessage: "Consignment reference not found"
-}</code></pre>
- * <p>Other data may be placed into the response for processing the {@link Ext.form.BasicForm Form}'s
- * callback or event handler methods. The object decoded from this JSON is available in the
- * {@link Ext.form.Action#result result} property.</p>
- */
-Ext.form.Action.Load = function(form, options){
- Ext.form.Action.Load.superclass.constructor.call(this, form, options);
- this.reader = this.form.reader;
-};
-
-Ext.extend(Ext.form.Action.Load, Ext.form.Action, {
- // private
- type : 'load',
-
- // private
- run : function(){
- Ext.Ajax.request(Ext.apply(
- this.createCallback(this.options), {
- method:this.getMethod(),
- url:this.getUrl(false),
- headers: this.options.headers,
- params:this.getParams()
- }));
- },
-
- // private
- success : function(response){
- var result = this.processResponse(response);
- if(result === true || !result.success || !result.data){
- this.failureType = Ext.form.Action.LOAD_FAILURE;
- this.form.afterAction(this, false);
- return;
- }
- this.form.clearInvalid();
- this.form.setValues(result.data);
- this.form.afterAction(this, true);
- },
-
- // private
- handleResponse : function(response){
- if(this.form.reader){
- var rs = this.form.reader.read(response);
- var data = rs.records && rs.records[0] ? rs.records[0].data : null;
- return {
- success : rs.success,
- data : data
- };
- }
- return Ext.decode(response.responseText);
- }
-});
+ statics: {
+<span id='Ext-form-action-Action-property-CLIENT_INVALID'> /**
+</span> * @property CLIENT_INVALID
+ * Failure type returned when client side validation of the Form fails
+ * thus aborting a submit action. Client side validation is performed unless
+ * {@link Ext.form.action.Submit#clientValidation} is explicitly set to <tt>false</tt>.
+ * @type {String}
+ * @static
+ */
+ CLIENT_INVALID: 'client',
+
+<span id='Ext-form-action-Action-property-SERVER_INVALID'> /**
+</span> * @property SERVER_INVALID
+ * <p>Failure type returned when server side processing fails and the {@link #result}'s
+ * <tt>success</tt> property is set to <tt>false</tt>.</p>
+ * <p>In the case of a form submission, field-specific error messages may be returned in the
+ * {@link #result}'s <tt>errors</tt> property.</p>
+ * @type {String}
+ * @static
+ */
+ SERVER_INVALID: 'server',
+
+<span id='Ext-form-action-Action-property-CONNECT_FAILURE'> /**
+</span> * @property CONNECT_FAILURE
+ * Failure type returned when a communication error happens when attempting
+ * to send a request to the remote server. The {@link #response} may be examined to
+ * provide further information.
+ * @type {String}
+ * @static
+ */
+ CONNECT_FAILURE: 'connect',
+
+<span id='Ext-form-action-Action-property-LOAD_FAILURE'> /**
+</span> * @property LOAD_FAILURE
+ * Failure type returned when the response's <tt>success</tt>
+ * property is set to <tt>false</tt>, or no field values are returned in the response's
+ * <tt>data</tt> property.
+ * @type {String}
+ * @static
+ */
+ LOAD_FAILURE: 'load'
-<div id="cls-Ext.form.Action.DirectLoad"></div>/**
- * @class Ext.form.Action.DirectLoad
- * @extends Ext.form.Action.Load
- * <p>Provides Ext.direct support for loading form data.</p>
- * <p>This example illustrates usage of Ext.Direct to <b>load</b> a form through Ext.Direct.</p>
- * <pre><code>
-var myFormPanel = new Ext.form.FormPanel({
- // configs for FormPanel
- title: 'Basic Information',
- renderTo: document.body,
- width: 300, height: 160,
- padding: 10,
-
- // configs apply to child items
- defaults: {anchor: '100%'},
- defaultType: 'textfield',
- items: [{
- fieldLabel: 'Name',
- name: 'name'
- },{
- fieldLabel: 'Email',
- name: 'email'
- },{
- fieldLabel: 'Company',
- name: 'company'
- }],
-
- // configs for BasicForm
- api: {
- // The server-side method to call for load() requests
- load: Profile.getBasicInfo,
- // The server-side must mark the submit handler as a 'formHandler'
- submit: Profile.updateBasicInfo
- },
- // specify the order for the passed params
- paramOrder: ['uid', 'foo']
-});
-
-// load the form
-myFormPanel.getForm().load({
- // pass 2 arguments to server side getBasicInfo method (len=2)
- params: {
- foo: 'bar',
- uid: 34
}
});
- * </code></pre>
- * The data packet sent to the server will resemble something like:
- * <pre><code>
-[
- {
- "action":"Profile","method":"getBasicInfo","type":"rpc","tid":2,
- "data":[34,"bar"] // note the order of the params
- }
-]
- * </code></pre>
- * The form will process a data packet returned by the server that is similar
- * to the following format:
- * <pre><code>
-[
- {
- "action":"Profile","method":"getBasicInfo","type":"rpc","tid":2,
- "result":{
- "success":true,
- "data":{
- "name":"Fred Flintstone",
- "company":"Slate Rock and Gravel",
- "email":"fred.flintstone@slaterg.com"
- }
- }
- }
-]
- * </code></pre>
- */
-Ext.form.Action.DirectLoad = Ext.extend(Ext.form.Action.Load, {
- constructor: function(form, opts) {
- Ext.form.Action.DirectLoad.superclass.constructor.call(this, form, opts);
- },
- type : 'directload',
-
- run : function(){
- var args = this.getParams();
- args.push(this.success, this);
- this.form.api.load.apply(window, args);
- },
-
- getParams : function() {
- var buf = [], o = {};
- var bp = this.form.baseParams;
- var p = this.options.params;
- Ext.apply(o, p, bp);
- var paramOrder = this.form.paramOrder;
- if(paramOrder){
- for(var i = 0, len = paramOrder.length; i < len; i++){
- buf.push(o[paramOrder[i]]);
- }
- }else if(this.form.paramsAsHash){
- buf.push(o);
- }
- return buf;
- },
- // Direct actions have already been processed and therefore
- // we can directly set the result; Direct Actions do not have
- // a this.response property.
- processResponse : function(result) {
- this.result = result;
- return result;
- },
-
- success : function(response, trans){
- if(trans.type == Ext.Direct.exceptions.SERVER){
- response = {};
- }
- Ext.form.Action.DirectLoad.superclass.success.call(this, response);
- }
-});
-
-<div id="cls-Ext.form.Action.DirectSubmit"></div>/**
- * @class Ext.form.Action.DirectSubmit
- * @extends Ext.form.Action.Submit
- * <p>Provides Ext.direct support for submitting form data.</p>
- * <p>This example illustrates usage of Ext.Direct to <b>submit</b> a form through Ext.Direct.</p>
- * <pre><code>
-var myFormPanel = new Ext.form.FormPanel({
- // configs for FormPanel
- title: 'Basic Information',
- renderTo: document.body,
- width: 300, height: 160,
- padding: 10,
- buttons:[{
- text: 'Submit',
- handler: function(){
- myFormPanel.getForm().submit({
- params: {
- foo: 'bar',
- uid: 34
- }
- });
- }
- }],
-
- // configs apply to child items
- defaults: {anchor: '100%'},
- defaultType: 'textfield',
- items: [{
- fieldLabel: 'Name',
- name: 'name'
- },{
- fieldLabel: 'Email',
- name: 'email'
- },{
- fieldLabel: 'Company',
- name: 'company'
- }],
-
- // configs for BasicForm
- api: {
- // The server-side method to call for load() requests
- load: Profile.getBasicInfo,
- // The server-side must mark the submit handler as a 'formHandler'
- submit: Profile.updateBasicInfo
- },
- // specify the order for the passed params
- paramOrder: ['uid', 'foo']
-});
- * </code></pre>
- * The data packet sent to the server will resemble something like:
- * <pre><code>
-{
- "action":"Profile","method":"updateBasicInfo","type":"rpc","tid":"6",
- "result":{
- "success":true,
- "id":{
- "extAction":"Profile","extMethod":"updateBasicInfo",
- "extType":"rpc","extTID":"6","extUpload":"false",
- "name":"Aaron Conran","email":"aaron@extjs.com","company":"Ext JS, LLC"
- }
- }
-}
- * </code></pre>
- * The form will process a data packet returned by the server that is similar
- * to the following:
- * <pre><code>
-// sample success packet (batched requests)
-[
- {
- "action":"Profile","method":"updateBasicInfo","type":"rpc","tid":3,
- "result":{
- "success":true
- }
- }
-]
-
-// sample failure packet (one request)
-{
- "action":"Profile","method":"updateBasicInfo","type":"rpc","tid":"6",
- "result":{
- "errors":{
- "email":"already taken"
- },
- "success":false,
- "foo":"bar"
- }
-}
- * </code></pre>
- * Also see the discussion in {@link Ext.form.Action.DirectLoad}.
- */
-Ext.form.Action.DirectSubmit = Ext.extend(Ext.form.Action.Submit, {
- constructor : function(form, opts) {
- Ext.form.Action.DirectSubmit.superclass.constructor.call(this, form, opts);
- },
- type : 'directsubmit',
- // override of Submit
- run : function(){
- var o = this.options;
- if(o.clientValidation === false || this.form.isValid()){
- // tag on any additional params to be posted in the
- // form scope
- this.success.params = this.getParams();
- this.form.api.submit(this.form.el.dom, this.success, this);
- }else if (o.clientValidation !== false){ // client validation failed
- this.failureType = Ext.form.Action.CLIENT_INVALID;
- this.form.afterAction(this, false);
- }
- },
-
- getParams : function() {
- var o = {};
- var bp = this.form.baseParams;
- var p = this.options.params;
- Ext.apply(o, p, bp);
- return o;
- },
- // Direct actions have already been processed and therefore
- // we can directly set the result; Direct Actions do not have
- // a this.response property.
- processResponse : function(result) {
- this.result = result;
- return result;
- },
-
- success : function(response, trans){
- if(trans.type == Ext.Direct.exceptions.SERVER){
- response = {};
- }
- Ext.form.Action.DirectSubmit.superclass.success.call(this, response);
- }
-});
-
-Ext.form.Action.ACTION_TYPES = {
- 'load' : Ext.form.Action.Load,
- 'submit' : Ext.form.Action.Submit,
- 'directload' : Ext.form.Action.DirectLoad,
- 'directsubmit' : Ext.form.Action.DirectSubmit
-};
-</pre>
+</pre>
</body>
-</html>
\ No newline at end of file
+</html>