【发布时间】:2013-11-29 08:43:36
【问题描述】:
我有一个表单(Ext.form.FormPanel),它基本上是一个登录面板,有两个字段,如用户名和密码,以及一个提交表单的按钮。现在我可以向我的 php 服务提交数据,该服务也返回数据,并且我可以在 action.result 中看到数据(这实际上是一个 UserVO,它具有诸如 user_name、password、user_type、user_id 等字段)。
精确数据的PFB
id
1
user_name
"super@super.com"
password
"cccccccc"
first_name
"Super"
last_name
"Super"
user_type
"Super"
parent_id
0
_explicitType
"certification.vo.UserVO"
success
true
现在我的问题是如何从 action.result 中获取此结果数据,将其解析为 Model 类型并将其存储在我的应用程序中,以便在应用程序(Ext.application)中可用于其他视图使用。
我的用户模型类如下。
Ext.define('Certify.model.UserVO',{
extend: 'Ext.data.Model',
fields: ['id','user_name','password','first_name','last_name','user_type','parent_id','_explicitType']
});
我的申请如下。
Ext.application({
requires : ['Ext.container.Viewport', 'Ext.form.FormPanel', 'Ext.Window', 'Ext.container.Container', 'Ext.Button', 'Ext.app.Controller'],
name : 'Certify',
appFolder : 'app',
models: ['UserVO'],
controllers : ['LoginController'],
launch : function() {
Ext.create('Ext.container.Viewport', {
layout : {
type : 'vbox',
align : 'center',
pack : 'center'
},
items : {
xtype : 'loginview'
}
});
}
});
还有我的表单提交。
var callData = JSON.stringify(callDataObj);
Ext.getCmp('loginForm').getForm().submit({
url : url + "login_json/" + callData,
method : 'POST',
waitTitle : 'Connecting',
waitMsg : 'Sending data...',
success : function(form, action) {
Ext.Msg.alert('Status', 'Login Successful!', function(btn, text) {
if (btn == 'ok') {
var redirect = './superuser.html';
window.location = redirect;
}
});
},
【问题讨论】: