Ext.form.action.Action

Alternate names

Ext.form.Action

Hierarchy

Ext.Base
Ext.form.action.Action

Subclasses

Files

该类的子类提供可以在Form上执行的相关操作。

该类的实例仅仅在Form 中被创建,当它需要执行提交或者加载操作的时候。 该类的配置项列表可以通过Form的相关操作方法来设置: submit, loaddoAction

执行操作的Action实例将会被传递给Form操作 (submit, loaddoAction)success和failure的回调函数, 以及actioncompleteactionfailed 的事件处理。

Defined By

Config options

Ext.form.action.Action
: Function

当接收到一个操作失败数据包,或者在Ajax通讯失败时调用的方法。

Parameters

Ext.form.action.Action
form : Ext.form.Basic

Action调用的BasicForm的实例。必需项。

Action调用的BasicForm的实例。必需项。

Ext.form.action.Action
: Object

附加在AJAX提交和加载请求中的header信息。 相关信息,请查看Ext.data.proxy.Ajax.headers.

Ext.form.action.Action
: String

HTTP方法用于访问所请求的URL。 默认使用BasicForm's method, 除非没有明确地指定'POST'。

Ext.form.action.Action
: Object/String

传递的额外的参数。 这些被添加到表单的Ext.form.Basic.baseParams中,并 和表单的表单项一起提交到指定的URL。

参数作为标准的HTTP参数使用Ext.Object.toQueryString进行编码。

Ext.form.action.Action
reset : Boolean

当指定为true时, 会导致表单在提交成功后执行reset操作。If specified, 更准确的说,这将发生在success函数被回调之前且触发表单的 actioncomplete 事件之前。

当指定为true时, 会导致表单在提交成功后执行reset操作。If specified, 更准确的说,这将发生在success函数被回调之前且触发表单的 actioncomplete 事件之前。

Ext.form.action.Action
scope : Object

调用回调函数的作用域 (回调函数的this引用)。

调用回调函数的作用域 (回调函数的this引用)。

Ext.form.action.Action
: Boolean

如果被置为 true,emptyText值将在form提交时一同发送默认为true。

Defaults to: true

Ext.form.action.Action
: Function

当接收到一个合法的操作成功数据包时调用的方法。

Parameters

Ext.form.action.Action
: Number

在服务端response返回CONNECT_FAILUREfailureType之前等待的毫秒数。 如果没有指定,默认采用form中配置的 timeout属性。

Ext.form.action.Action
url : String

Action调用的URL。默认使用form中配置的url属性。

Action调用的URL。默认使用form中配置的url属性。

Ext.form.action.Action
waitMsg : String

在执行操作期间,调用Ext.window.MessageBox.wait方法时显示的消息。

在执行操作期间,调用Ext.window.MessageBox.wait方法时显示的消息。

Ext.form.action.Action
waitTitle : String

Ext.window.MessageBox.wait在执行操作期间,显示的标题文本。

Ext.window.MessageBox.wait在执行操作期间,显示的标题文本。

Properties

Defined By

Instance Properties

扩展事件

Defaults to: []

Ext.form.action.Action
: String
失败的类型被检查为以下几种类型之一: CLIENT_INVALID, SERVER_INVALID, CONNECT_FAILURE, 或者 LOAD_FAILURE. ...

失败的类型被检查为以下几种类型之一: CLIENT_INVALID, SERVER_INVALID, CONNECT_FAILURE, 或者 LOAD_FAILURE.

用法:

var fp = new Ext.form.Panel({
...
buttons: [{
    text: 'Save',
    formBind: true,
    handler: function(){
        if(fp.getForm().isValid()){
            fp.getForm().submit({
                url: 'form-submit.php',
                waitMsg: 'Submitting your data...',
                success: function(form, action){
                    // server responded with success = true
                    var result = action.result;
                },
                failure: function(form, action){
                    if (action.failureType === Ext.form.action.Action.CONNECT_FAILURE) {
                        Ext.Msg.alert('Error',
                            'Status:'+action.response.status+': '+
                            action.response.statusText);
                    }
                    if (action.failureType === Ext.form.action.Action.SERVER_INVALID){
                        // server responded with success = false
                        Ext.Msg.alert('Invalid', action.result.errormsg);
                    }
                }
            });
        }
    }
},{
    text: 'Reset',
    handler: function(){
        fp.getForm().reset();
    }
}]
Ext.form.action.Action
response : Object

被用来执行action操作的XMLHttpRequest的原始对象。

被用来执行action操作的XMLHttpRequest的原始对象。

Ext.form.action.Action
result : Object

解码好的响应对象,包含一个布尔型的success 参数和其他详细的操作说明参数。

解码好的响应对象,包含一个布尔型的success 参数和其他详细的操作说明参数。

本身 获取当前类的引用,此对象被实例化。不同于 statics, this.self是依赖范围,它意味着要使用动态继承。 ...

本身

获取当前类的引用,此对象被实例化。不同于 statics, this.self是依赖范围,它意味着要使用动态继承。 参见 statics 详细对比

Ext.define('My.Cat', {
    statics: {
        speciesName: 'Cat' // My.Cat.speciesName = 'Cat'
    },

    constructor: function() {
        alert(this.self.speciesName); // 依赖 'this'
    },

    clone: function() {
        return new this.self();
    }
});


Ext.define('My.SnowLeopard', {
    extend: 'My.Cat',
    statics: {
        speciesName: 'Snow Leopard'         // My.SnowLeopard.speciesName = 'Snow Leopard'
    }
});

var cat = new My.Cat();                     // alerts 'Cat' 猫
var snowLeopard = new My.SnowLeopard();     // alerts 'Snow Leopard' 雪豹

var clone = snowLeopard.clone();
alert(Ext.getClassName(clone));             // alerts 'My.SnowLeopard'
Ext.form.action.Action
type : String

Action实例执行的操作类型。当前只支持"submit"和"load"这两种方式。

Action实例执行的操作类型。当前只支持"submit"和"load"这两种方式。

Defined By

Static Properties

Ext.form.action.Action
: Stringstatic

客户端验证失败造成action提交中止时返回的Failure类型。 客户端验证已执行除非设置Ext.form.action.Submit.clientValidation属性为false。

Defaults to: "client"

Ext.form.action.Action
: Stringstatic

当一个通讯错误发生在准备发送一个请求到服务端时返回的Failure类型。 这时检查response会提供更多的信息。

Defaults to: "connect"

Ext.form.action.Action
: Stringstatic

当response的success 属性被设置为false,或者response的data属性没有包含任何值时返回的Failure类型。

Defaults to: "load"

Ext.form.action.Action
: Stringstatic

服务端处理失败并且 resultsuccess 属性被设置为false时返回的Failure类型。

在这种情况下,错误信息被包含在 result的errors属性中。

Defaults to: "server"

Methods

Defined By

Instance Methods

Ext.form.action.Action
new( [Object config] ) : Object

创建一个Action。

Parameters

  • config : Object (optional)

    Config object.

Returns

( Object config )private

添加配置

Parameters

Parameters

( Object name, Object member )private

Parameters

( Object xtype )private

添加 Xtype

Parameters

( Array/Arguments ) : Objectdeprecatedprotected
调用原来的方法,这是以前的override重写 Ext.define('My.Cat', { constructor: function() { alert("I'm a cat!"); } }); ...

调用原来的方法,这是以前的override重写

Ext.define('My.Cat', {
    constructor: function() {
        alert("I'm a cat!");
    }
});

My.Cat.override({
    constructor: function() {
        alert("I'm going to be a cat!");

        this.callOverridden();

        alert("Meeeeoooowwww");
    }
});

var kitty = new My.Cat(); // alerts "I'm going to be a cat!"
                          // alerts "I'm a cat!"
                          // alerts "Meeeeoooowwww"

This method has been deprecated since 4.1

版本 使用 callParent 代替.

Parameters

  • : Array/Arguments

    参数的参数,数组或'参数'对象 来自当前方法,例如: this.callOverridden(arguments)

Returns

  • Object

    返回调用重写方法的结果。

( Array/Arguments args ) : Objectprotected

所谓的"parent"方法是指当前的方法。 这是以前的方法派生或重写(参见 Ext.define)。

 Ext.define('My.Base', {
     constructor: function (x) {
         this.x = x;
     },

     statics: {
         method: function (x) {
             return x;
         }
     }
 });

 Ext.define('My.Derived', {
     extend: 'My.Base',

     constructor: function () {
         this.callParent([21]);
     }
 });

 var obj = new My.Derived();

 alert(obj.x);  // alerts 21

这可以用来重写如下:

 Ext.define('My.DerivedOverride', {
     override: 'My.Derived',

     constructor: function (x) {
         this.callParent([x*2]); // 调用原来的My.Derived构造
     }
 });

 var obj = new My.Derived();

 alert(obj.x);  // 现在提示 42

This also works with static methods.

 Ext.define('My.Derived2', {
     extend: 'My.Base',

     statics: {
         method: function (x) {
             return this.callParent([x*2]); // 调用 My.Base.method
         }
     }
 });

 alert(My.Base.method(10);     // alerts 10
 alert(My.Derived2.method(10); // alerts 20

然后,它也可以重写静态方法。

 Ext.define('My.Derived2Override', {
     override: 'My.Derived2',

     statics: {
         method: function (x) {
             return this.callParent([x*2]); // 调用 My.Derived2.method
         }
     }
 });

 alert(My.Derived2.method(10); // 现在提示 40

Parameters

  • args : Array/Arguments

    这个参数, 通过当前方法得到数组或者 arguments 对象, 例如: this.callParent(arguments)

Returns

  • Object

    返回调用父类的方法的结果。

Ext.form.action.Action
( )private

Creates a callback object.

( Object config )private

拓展

Parameters

( Object name )private

得到配置项

Parameters

得到初始化配置项

Parameters

Ext.form.action.Action
( ) : Stringprivate

Determine the HTTP method to be used for the request.

Returns

Ext.form.action.Action
( ) : Objectprivate

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.

Returns

  • Object

    the full set of parameters

Ext.form.action.Action
( ) : Stringprivate

Build the URL for the AJAX request. Used by the standard AJAX submit and load actions.

Returns

Ext.form.action.Action
( Object response )private

Handles the raw response and builds a result object from it. Must be implemented by subclasses.

Parameters

( Object config )private

根据名称判断配置项是否存在

Parameters

( Object config ) : Objectprotected
这个类的初始化配置。典型例子: Ext.define('My.awesome.Class', { // 这是默认配置 config: { name: 'Awesome', isAwes...

这个类的初始化配置。典型例子:

Ext.define('My.awesome.Class', {
    // 这是默认配置
    config: {
        name: 'Awesome',
        isAwesome: true
    },

    constructor: function(config) {
        this.initConfig(config);
    }
});

var awesome = new My.awesome.Class({
    name: 'Super Awesome'
});

alert(awesome.getName()); // 'Super Awesome' 超级棒

Parameters

Returns

  • Object

    mixins 混入原型 键-值对

( Object name, Object mixinClass )private

内部使用混入预处理器(mixins pre-processor)

Parameters

( Object names, Object callback, Object scope )private

更新配置项

Parameters

( Object fn, Object scope )private

扩展事件

Parameters

Ext.form.action.Action
( Object response )private

Handles a failure response.

Parameters

Ext.form.action.Action
( Object response )private

Callback method that gets invoked when the action completes successfully. Must be implemented by subclasses.

Parameters

Ext.form.action.Action
( Object response ) : Object/Booleanprivate
Validates that a response contains either responseText or responseXML and invokes handleResponse to build the result ...

Validates that a response contains either responseText or responseXML and invokes handleResponse to build the result object.

Parameters

  • response : Object

    The raw response object.

Returns

  • Object/Boolean

    The result object as built by handleResponse, or true if the response had empty responseText and responseXML.

Ext.form.action.Action
( )

使用当前配置执行action操作。

( Object config, Object applyIfNotSet )private

设置配置项

Parameters

获取从该对象被实例化的类的引用。 请注意不同于 self, this.statics()是独立的作用域,无论this是否运行,总是返回其中的调用类。

Ext.define('My.Cat', {
    statics: {
        totalCreated: 0,
        speciesName: 'Cat' // My.Cat.speciesName = 'Cat'
    },

    constructor: function() {
        var statics = this.statics();

        alert(statics.speciesName);     // 总是等于'Cat',无论'this'是什么,
                                        // 相当于:My.Cat.speciesName

        alert(this.self.speciesName);   // 依赖 'this'

        statics.totalCreated++;
    },

    clone: function() {
        var cloned = new this.self;                      // 依赖 'this'

        cloned.groupName = this.statics().speciesName;   // 相当于: My.Cat.speciesName

        return cloned;
    }
});


Ext.define('My.SnowLeopard', {
    extend: 'My.Cat',

    statics: {
        speciesName: 'Snow Leopard'     // My.SnowLeopard.speciesName = 'Snow Leopard'
    },

    constructor: function() {
        this.callParent();
    }
});

var cat = new My.Cat();                 // alerts 'Cat', 然后提示 'Cat'

var snowLeopard = new My.SnowLeopard(); // alerts 'Cat', 然后提示 'Snow Leopard'

var clone = snowLeopard.clone();
alert(Ext.getClassName(clone));         // alerts 'My.SnowLeopard'
alert(clone.groupName);                 // alerts 'Cat'

alert(My.Cat.totalCreated);             // alerts 3

Returns

配置扩展

Defined By

Static Methods

( Object members )static

方法/属性添加到这个类的原型。

Ext.define('My.awesome.Cat', {
    constructor: function() {
        ...
    }
});

 My.awesome.Cat.implement({
     meow: function() {
        alert('Meowww...');
     }
 });

 var kitty = new My.awesome.Cat;
 kitty.meow();

Parameters

添加/重写这个类的静态属性。

Ext.define('My.cool.Class', {
    ...
});

My.cool.Class.addStatics({
    someProperty: 'someValue',      // My.cool.Class.someProperty = 'someValue'
    method1: function() { ... },    // My.cool.Class.method1 = function() { ... };
    method2: function() { ... }     // My.cool.Class.method2 = function() { ... };
});

Parameters

Returns

( Ext.Base fromClass, Array/String members ) : Ext.Baseprivatestatic
这个类的原型借用另一个类的成员 Ext.define('Bank', { money: '$$$', printMoney: function() { alert('$$$$$$$'); } ...

这个类的原型借用另一个类的成员

Ext.define('Bank', {
    money: '$$$',
    printMoney: function() {
        alert('$$$$$$$');
    }
});

Ext.define('Thief', {
    ...
});

Thief.borrow(Bank, ['money', 'printMoney']);

var steve = new Thief();

alert(steve.money); // alerts '$$$'
steve.printMoney(); // alerts '$$$$$$$'

Parameters

Returns

创建这个类的新实例。

Ext.define('My.cool.Class', {
    ...
});

My.cool.Class.create({
    someConfig: true
});

所有参数传递至类的构造。

Returns

创建现有的原型方法的别名。例如: Ext.define('My.cool.Class', { method1: function() { ... ...

创建现有的原型方法的别名。例如:

Ext.define('My.cool.Class', {
    method1: function() { ... },
    method2: function() { ... }
});

var test = new My.cool.Class();

My.cool.Class.createAlias({
    method3: 'method1',
    method4: 'method2'
});

test.method3(); // test.method1()

My.cool.Class.createAlias('method5', 'method3');

test.method5(); // test.method3() -> test.method1()

Parameters

以字符串格式,获取当前类的名称。

Ext.define('My.cool.Class', {
    constructor: function() {
        alert(this.self.getName()); // alerts 'My.cool.Class'
    }
});

My.cool.Class.getName(); // 'My.cool.Class'

Returns

( Object members ) : Ext.Basedeprecatedstatic

重写这个类的成员。通过callParent重写的方法可以调用。

Ext.define('My.Cat', {
    constructor: function() {
        alert("I'm a cat!");
    }
});

My.Cat.override({
    constructor: function() {
        alert("I'm going to be a cat!");

        this.callParent(arguments);

        alert("Meeeeoooowwww");
    }
});

var kitty = new My.Cat(); // alerts "I'm going to be a cat!我要成为一只猫!"
                          // alerts "I'm a cat!我是一只猫!"
                          // alerts "Meeeeoooowwww"

在4.1版本, 直接利用这种方法已经过时了。 使用 Ext.define 代替:

Ext.define('My.CatOverride', {
    override: 'My.Cat',
    constructor: function() {
        alert("I'm going to be a cat!");

        this.callParent(arguments);

        alert("Meeeeoooowwww");
    }
});

以上完成了相同的结果,但可以由Ext.Loader重写, 其目标类和生成过程中,可以决定是否需要根据目标类所需的状态覆盖管理(My.Cat)。

This method has been deprecated since 4.1.0

使用 Ext.define 代替

Parameters

  • members : Object

    添加到这个类的属性。 这应当被指定为一个对象包含一个或多个属性的文字。

Returns