Javascript 使用Ext.DIrect提交extjs表单

Javascript 使用Ext.DIrect提交extjs表单,javascript,extjs4,Javascript,Extjs4,我想使用Ext.Direct和iam提交一份表格,遵循文档中提供的所有指导原则,但我仍然收到这个奇怪的错误 Error: Ext.data.Connection.setOptions(): No URL specified 这是我表单的javascript代码 Ext.define('LOGIN.view.SignIn', { extend: 'Ext.form.Panel', alias: 'widget.signin', title: 'Sign-In',

我想使用Ext.Direct和iam提交一份表格,遵循文档中提供的所有指导原则,但我仍然收到这个奇怪的错误

Error: Ext.data.Connection.setOptions(): No URL specified
这是我表单的javascript代码

Ext.define('LOGIN.view.SignIn', {
    extend: 'Ext.form.Panel',
    alias: 'widget.signin',
    title: 'Sign-In',
    items: [{
        xtype: 'textfield',
        name: 'UserName',
        fieldLabel: 'UserName',
        allowBlank: 'false'
    }, {
        xtype: 'textfield',
        name: 'Password',
        fieldLabel: 'Password',
        allowBlank: 'false',
        inputType: 'password'
    }],
    buttons: [{
        text: 'Sign-In',
        handler: function () {
            this.up('form').getForm().submit({});
        }
    }, {
        text: 'Sign-Up -->',
        disabled: true,
        handler: function () {
            this.up('#LoginPanel').getLayout().setActiveItem(1);
        }
    }],
    api: {
        submit: LogIn.SignIn
    }
})

我应该改变什么?

我从框架中找到了答案。
我需要使用以下代码并在构造函数中定义api,因为我猜这个特定的intialConfig不会自动执行

这是密码

Ext.define('LOGIN.view.SignIn', {
    extend: 'Ext.form.Panel',
    alias: 'widget.signin',
    title: 'Sign-In',
    constructor: function (config) {
        Ext.applyIf(config, {
            // defaults for configs that should be passed along to the Basic form constructor go here
            api: {
                submit:LogIn.SignIn
            }
        });
        this.callParent(arguments);
    },
    items: [{
        xtype: 'textfield',
        name: 'UserName',
        fieldLabel: 'UserName',
        allowBlank: 'false'
    }, {
        xtype: 'textfield',
        name: 'Password',
        fieldLabel: 'Password',
        allowBlank: 'false',
        inputType: 'password'
    }],
    buttons: [{
        text: 'Sign-In',
        handler: function () {
            this.up('form').getForm().submit();
        }
    },
        {
            text: 'Sign-Up -->',
            disabled: true,
            handler: function () {
                this.up('#LoginPanel').getLayout().setActiveItem(1);
            }
        }]
})

有一件事需要注意

如果您使用的是extdirectspring,则需要使用以下内容对服务器端方法进行注释:

@ExtDirectMethod(ExtDirectMethodType.FORM_POST)
public ExtDirectFormPostResult doStuff(AddAttachmentRequest request)
{
    return null;
}
还必须使用ExtDirectFormPostResult。如果你不这样做,那就行不通了

如果使用普通extdirect方法,则不会发送任何文件数据

另一端所需的类型也是
MultipartFile
例如:

public class AddAttachmentRequest {

    private long id;
    private MultipartFile file;

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public MultipartFile getFile() {
        return file;
    }

    public void setFile(MultipartFile file) {
        this.file = file;
    }
}