X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/c930e9176a5a85509c5b0230e2bff5c22a591432..c8256059947f3aa8f5b0a9a2acf55e2142bb4742:/docs/source/Action.html diff --git a/docs/source/Action.html b/docs/source/Action.html index 8be40ba5..155d8be1 100644 --- a/docs/source/Action.html +++ b/docs/source/Action.html @@ -1,11 +1,18 @@ - - - The source code - - - - -
/** + + + + The source code + + + + +
/*!
+ * Ext JS Library 3.2.1
+ * Copyright(c) 2006-2010 Ext JS, Inc.
+ * licensing@extjs.com
+ * http://www.extjs.com/license
+ */
+
/** * @class Ext.form.Action *

The subclasses of this class provide actions to perform upon {@link Ext.form.BasicForm Form}s.

*

Instances of this class are only created by a {@link Ext.form.BasicForm Form} when @@ -114,6 +121,11 @@ Ext.form.Action.prototype = { * during the time the action is being processed. */ +

/** + * @cfg {Boolean} submitEmptyText If set to true, the emptyText value will be sent with the form + * when it is submitted. Defaults to true. + */ +
/** * The type of action this Action instance performs. * Currently only "submit" and "load" are supported. @@ -332,10 +344,20 @@ Ext.extend(Ext.form.Action.Submit, Ext.form.Action, { // private run : function(){ - var o = this.options; - var method = this.getMethod(); - var isGet = method == 'GET'; + 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), @@ -344,6 +366,13 @@ Ext.extend(Ext.form.Action.Submit, Ext.form.Action, { 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); @@ -359,8 +388,8 @@ Ext.extend(Ext.form.Action.Submit, Ext.form.Action, { } if(result.errors){ this.form.markInvalid(result.errors); - this.failureType = Ext.form.Action.SERVER_INVALID; } + this.failureType = Ext.form.Action.SERVER_INVALID; this.form.afterAction(this, false); }, @@ -423,7 +452,7 @@ myFormPanel.{@link Ext.form.FormPanel#getForm getForm}().{@link Ext.form.BasicFo params: { consignmentRef: myConsignmentRef }, - failure: function(form, action() { + failure: function(form, action) { Ext.Msg.alert("Load failed", action.result.errorMessage); } }); @@ -498,62 +527,90 @@ Ext.extend(Ext.form.Action.Load, Ext.form.Action, {
/** * @class Ext.form.Action.DirectLoad * @extends Ext.form.Action.Load - * Provides Ext.direct support for loading form data. This example illustrates usage - * of Ext.Direct to load a submit a form through Ext.Direct. + *

Provides Ext.direct support for loading form data.

+ *

This example illustrates usage of Ext.Direct to load a form through Ext.Direct.

*

 var myFormPanel = new Ext.form.FormPanel({
     // configs for FormPanel
     title: 'Basic Information',
-    border: false,
+    renderTo: document.body,
+    width: 300, height: 160,
     padding: 10,
-    buttons:[{
-        text: 'Submit',
-        handler: function(){
-            basicInfo.getForm().submit({
-                params: {
-                    uid: 5
-                }
-            });
-        }
-    }],
-    
+
     // configs apply to child items
     defaults: {anchor: '100%'},
     defaultType: 'textfield',
-    items: [
-        // form fields go here
-    ],
-    
+    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
-    },    
-    paramOrder: ['uid']
+    },
+    // 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: {
-        uid: 5
+        foo: 'bar',
+        uid: 34
     }
 });
+ * 
+ * The data packet sent to the server will resemble something like: + *

+[
+    {
+        "action":"Profile","method":"getBasicInfo","type":"rpc","tid":2,
+        "data":[34,"bar"] // note the order of the params
+    }
+]
+ * 
+ * The form will process a data packet returned by the server that is similar + * to the following format: + *

+[
+    {
+        "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"
+            }
+        }
+    }
+]
  * 
*/ Ext.form.Action.DirectLoad = Ext.extend(Ext.form.Action.Load, { - constructor: function(form, opts) { + constructor: function(form, opts) { Ext.form.Action.DirectLoad.superclass.constructor.call(this, form, opts); }, - type: 'directload', - + type : 'directload', + run : function(){ var args = this.getParams(); - args.push(this.success, this); + args.push(this.success, this); this.form.api.load.apply(window, args); }, - - getParams: function() { + + getParams : function() { var buf = [], o = {}; var bp = this.form.baseParams; var p = this.options.params; @@ -571,23 +628,114 @@ Ext.form.Action.DirectLoad = Ext.extend(Ext.form.Action.Load, { // 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) { + processResponse : function(result) { this.result = result; - return result; + return result; + }, + + success : function(response, trans){ + if(trans.type == Ext.Direct.exceptions.SERVER){ + response = {}; + } + Ext.form.Action.DirectLoad.superclass.success.call(this, response); } });
/** * @class Ext.form.Action.DirectSubmit * @extends Ext.form.Action.Submit - * Provides Ext.direct support for submitting form data. - * See {@link Ext.form.Action.DirectLoad}. + *

Provides Ext.direct support for submitting form data.

+ *

This example illustrates usage of Ext.Direct to submit a form through Ext.Direct.

+ *

+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']
+});
+ * 
+ * The data packet sent to the server will resemble something like: + *

+{
+    "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"
+        }
+    }
+}
+ * 
+ * The form will process a data packet returned by the server that is similar + * to the following: + *

+// 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"
+        }
+}
+ * 
+ * Also see the discussion in {@link Ext.form.Action.DirectLoad}. */ Ext.form.Action.DirectSubmit = Ext.extend(Ext.form.Action.Submit, { - constructor: function(form, opts) { + constructor : function(form, opts) { Ext.form.Action.DirectSubmit.superclass.constructor.call(this, form, opts); }, - type: 'directsubmit', + type : 'directsubmit', // override of Submit run : function(){ var o = this.options; @@ -601,30 +749,36 @@ Ext.form.Action.DirectSubmit = Ext.extend(Ext.form.Action.Submit, { this.form.afterAction(this, false); } }, - - getParams: function() { + + 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) { + processResponse : function(result) { this.result = result; - return 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 + 'directload' : Ext.form.Action.DirectLoad, + 'directsubmit' : Ext.form.Action.DirectSubmit }; -
- +
+ \ No newline at end of file