Ext.onReady(function() {
// alert('hello');
// 使用表单提示
Ext.QuickTips.init();
Ext.form.Field.prototype.msgTarget = "side";
// 定义一个输入表单
var simple = new Ext.FormPanel( {
labelWidth : 40,
baseCls : "x-plain",
defaultType : "textfield",
reader : new Ext.data.JsonReader( {
root : 'user'
}, [ {
name : 'username',
mapping : 'username',
type : 'string'
}, {
name : 'password',
mapping : 'password',
type : 'string'
} ]),
defaults : {
width : 180
},
items : [ {
fieldLabel : " 帐号",
// name:"user.username",
name : 'username',
allowBlank : false,
blankText : " 帐号不能为空"
}, {
inputType : "password",
fieldLabel : " 密码",
// name:"user.password",
name : 'password',
allowBlank : false,
blankText : " 密码不能为空"
} ],
buttons : [ {
text : "提交",
type : "submit",
handler : function() {
if (simple.form.isValid()) {
Ext.MessageBox.show( {
title : " 请稍等",
msg : "正在加载.....",
progressText : "",
width : 300,
progress : true,
closable : false,
animEl : "loding"
});
var f = function(v) {
return function() {
var i = v / 11;
Ext.MessageBox.updateProgress(i, '');
}
}
for ( var i = 1; i < 13; i++) {
setTimeout(f(i), i * 150);
}
// 提交到服务器操作
simple.form.doAction("submit", {
url : "Login.action",
method : "post",
params : "",
success : function(form, action) {
document.location = 'user/index.jsp';
Ext.Msg.alert(" 登录成功!", action.result.message);
},
failure : function(form, action) {
Ext.Msg.alert('登陆失败', action.result.message);
}
});
}
}
}, {
text : " 重置",
handler : function() {
// 重置表单
simple.form.reset();
}
} ]
});
// 定义窗体
var _window = new Ext.Window( {
title : "登录窗口",
layout : "fit",
width : 280,
height : 150,
plain : true,
bodyStyle : "padding:10px;",
maximizable : false,
closeAction : "close",
closable : false,
collapsible : true,
plain : true,
buttonAlign : "center",
items : simple
});
simple.getForm().load( {
url:'Login!hello.action',
//url : 'hello.jsp',
waitTitle : '提示',
waitMsg : '正在处理您的请求,请稍候...',
success : function(form, action) {
Ext.Msg.alert('hello');
},
failure : function(form, action) {
Ext.Msg.alert('失败...');
}
}
);
_window.show();
});
ext form load
最新推荐文章于 2021-08-06 20:40:53 发布