`

ExtJS form表单提交

阅读更多
简单的Form 表单提交:
一:普通方式提交:
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>My First ExtJS - Login Page</title>
<!-- ExtJS -->
<link rel="stylesheet" type="text/css"
href="<%=basePath%>/ExtJS4/resources/css/ext-all.css" />
<link rel="stylesheet" type="text/css"
href="<%=basePath%>/ExtJS4/examples/shared/example.css" />
<script type="text/javascript" src="<%=basePath%>/ExtJS4/ext-all.js"></script>
<script type="text/javascript">
Ext.require([ '*' ]);
Ext.onReady(function() {
var frmPanel = Ext.create('Ext.form.Panel', {
renderTo : Ext.getBody(),
title : 'User Form',
height : 150,
width : 280,
bodyPadding : 10,
standardSubmit:true, //标准方式
defaultType : 'textfield',
items : [ {
fieldLabel : 'User Name',
name : 'userName',
allowBlank:false//判断是否为空
}, {
fieldLabel : 'User Password',
name : 'userPassword',
inputType:'password', //密码框
allowBlank:false
} ],
buttons : [ {
text : 'Submit',
handler : login
}, {
text : "Reset",
handler : reset
} ]
});
//登录方法
function login() {
if(frmPanel.form.isValid()){
   frmPanel.form.submit({
   clientValidation:true,
   url:'<%=basePath%>homePage/login',
   method:'POST',
   waitMsg:'正在登录系统,请稍后...'

   });
}

}
function reset() {
frmPanel.form.reset();
}
});
</script>
</head>
<body>
</body>
</html>
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics