Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/extjs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Extjs Sencha Touch 2和Ext.Direct API调用-登录表单_Extjs_Sencha Touch 2 - Fatal编程技术网

Extjs Sencha Touch 2和Ext.Direct API调用-登录表单

Extjs Sencha Touch 2和Ext.Direct API调用-登录表单,extjs,sencha-touch-2,Extjs,Sencha Touch 2,所以主要的问题是:有人知道我需要如何更改调用方法以与Sencha Touch 2兼容吗 说明: 我有一个带有C#后端的大型Extjs应用程序。我已经有了一个带有页面的移动站点,但是没有一个需要提交表单数据。尝试创建登录页面时出现了问题 在桌面上,使用extjs和Ext.direct,有登录表单,它们工作正常,但相同的编码模式似乎不适用于Sencha Touch 2 Ext.define('PF.view.phone.login.Form', { extend: 'Ext.form.Panel',

所以主要的问题是:有人知道我需要如何更改调用方法以与Sencha Touch 2兼容吗

说明: 我有一个带有C#后端的大型Extjs应用程序。我已经有了一个带有页面的移动站点,但是没有一个需要提交表单数据。尝试创建登录页面时出现了问题

在桌面上,使用extjs和Ext.direct,有登录表单,它们工作正常,但相同的编码模式似乎不适用于Sencha Touch 2

Ext.define('PF.view.phone.login.Form', {
extend: 'Ext.form.Panel',
alias: 'widget.phoneloginform',
requires: ['Ext.form.FieldSet', 'Ext.form.Password', 'Ext.Label', 'Ext.Img'],
autoheight: true,
initialize: function () {
    this.build();
    this.callParent();
    Ext.apply(this, {
        api: {
            submit: LoginActionImpl.login
        }
    });
    scope: this
},
config: {
    title: 'Login',
    items: [
        {
            xtype: 'label',
            html: 'Client Login',
            itemId: 'clientLoginLabel',
            style: 'text-align: left; font-size: 1.1em',
            margin: '10 0 20 0'
        }, {
            xtype: 'fieldset',
            /*Temporary style*/
            margin: '10 17% 10 17% ',
            items: [
                {
                    xtype: 'textfield',
                    itemId: 'loginUsername',
                    name: 'loginUsername',
                    label: 'Username',
                    required: true
                }, {
                    xtype: 'passwordfield',
                    itemId: 'loginPassword',
                    name: 'loginPassword',
                    label: 'Password',
                    required: true
                }, {
                    xtype: 'toolbar',
                    layout: {
                        pack: 'right'
                    },
                    ui: 'plain',
                    items: [{
                        xtype: 'button',
                        itemId: 'loginButton',
                        text: 'Login',
                        ui: 'confirm'
                    }, {
                        xtype: 'button',
                        itemId: 'clearButton',
                        text: 'Clear',
                        ui: 'decline'
                    }]
                }
            ]
        }
   ]
},
build: function () {
    this.down('#clearButton').setHandler(this.clear);
    this.down('#loginButton').setHandler(this.login);
},
clear: function (btn, evt) {
    btn.up('phoneloginform').reset();

},
login: function (btn, evt) {
    /* Need help here */
    /* Below is what would normally be used in the rest of the application */
    this.submit({
        success: this.onLoginSuccess,
        failure: function (form, action) {
            this.onLoginFailure(action.result);
        },
        scope: this
    });
},
onLoginSuccess: function (arguments) {

    Ext.dispatch('login/success');
},
onLoginFailure: function (result) {

    // Here we need to check the actual results to determine why the login failed.
    //
    // A return code of -2 indicates account locked - otherwise we just assume an invalid attempt.
    //
    if (result.returnCode == -2) {
        this.getComponent("loginUsername").markInvalid(t('ptl_mbl_user_status_locked_password'));
        this.getComponent("loginUsername").markInvalid(t('ptl_mbl_user_status_locked_password'));
    }
    else {
        this.getComponent("loginUsername").markInvalid(t('wms_username_password_incorrect_error'));
        this.getComponent("loginPassword").markInvalid(t('wms_username_password_incorrect_error'));
    }
    Ext.dispatch('login/fail', result.returnCode);
},

getUsername: function () {
    if (this.username) {
        this.username = this.getValues()['#loginUsername'];
    }
},

getPassword: function () {
    if (this.password) {
        this.password = this.getValues()['#loginPassword'];
    }
}
});
C#法的方法是:

    [DirectMethodForm]
    public JObject login(HttpRequest request)
    {
        String username = request["loginUsername"];
        String password = request["loginPassword"];
        this.setDB(request["db"]);

        int loginReturnCode = this.getUserDetailsService().login(username, password, this.getDB(), true);

        JObject jsonObject;
        if (loginReturnCode == 0)
        {
            jsonObject = new JObject(
                new JProperty("loginUsername", username),
                new JProperty("loginPassword", password),
                new JProperty("db", this.getDB()),
                new JProperty("success", true));
        }
        else
        {
            jsonObject = new JObject(
                new JProperty("errors", new JArray(new[] { loginReturnCode.ToString() })),
                new JProperty("returnCode", loginReturnCode),
                new JProperty("failed", true));
        }

        return jsonObject;
    }
我想重复使用的东西是不能改变的

在浏览浏览器中的代码时,问题出现在“sencha touch all.js”文件中的“urlpappend”方法中,其中“url”参数为null,因此调用永远不会到达C#代码

然而,在使用Ext.direct时,我以前从未需要设置该变量。我没有单独的web服务,因此实际的web服务调用不可用


提前感谢。

Touch要求您使用setter,您不能直接在类上应用属性。感谢您的回复。对不起,我不知道你说的是什么房产?你是说用户名和密码设置器吗?不是,你在课堂上调用
apply
。您需要使用setter。此外,您还有一个随机的
范围:这个
位于该方法中。从Sencha论坛发现,Sencha Touch 2.2.x不支持通过Ext.Direct提交表单。它直到2.3.0才被添加。无论如何,谢谢你的回复!
    urlAppend : function(url, string) {
    if (!Ext.isEmpty(string)) {
        return url + (url.indexOf('?') === -1 ? '?' : '&') + string;
    }

    return url;
},