Ext如何做登陆页面

Ext如何做登陆页面

网上帮你弄来的.多谷歌谷歌
[code="js"]
Ext.onReady(function(){
Ext.QuickTips.init();//开启表单提示
Ext.form.Field.prototype.msgTarget = 'side';//设置提示信息位置为边上
var simple = new Ext.FormPanel({//初始化表单面板
labelWidth: 75, // 默认标签宽度
frame:true,//设置表单面板,false为无面板
title: '我的表单',
bodyStyle:'padding:5px 5px 0',
width: 350,
defaults: {width: 230},
defaultType: 'textfield',//默认字段类型

    items: [{
            fieldLabel: '帐户',
            name: 'name',
            allowBlank:false,
            blankText: '帐户不能为空'
        },{
            fieldLabel: '密码',
            name: 'pws',
            allowBlank:false,//禁止为空
            blankText: '密码不能为空'//可限制多种类型,具体参照api文档
        }
    ],

    buttons: [{
        text: '登录',
        handler:function(){alert("你提交了表单!");}//提交表单与服务器交互的实例请参照实例分析部分《一个完整的登录实例》
    },{
        text: '取消',
        handler:function(){simple.form.reset();}//重置表单
    }]
});

simple.render('show');//填充到指定区域

});

[/code]

这是login.js
var txtUserName = new Ext.form.TextField({
name: 'txtName',
width: 250,
fieldLabel: '用户名',
maxLength: 50,
allowBlank: false,
blankText: '帐户不能为空'
});
var txtPassword = new Ext.form.TextField({
name: 'txtPassword',
width: 250,
fieldLabel: '密码',
maxLength: 50,
allowBlank: false,
blankText: '密码不能为空'
});

Ext.onReady(function(){
//使用表单提示
Ext.QuickTips.init();
Ext.form.Field.prototype.msgTarget = 'side';

      //定义表单
      var simple = new Ext.FormPanel({
            labelWidth: 75,             
            baseCls: 'x-plain',
            defaults: {width: 150},
            defaultType: 'textfield',//默认字段类型

            //定义表单元素
            items: [txtUserName, txtPassword
            /*
            {
                    fieldLabel: '用户名',
                    name: 'name',//元素名称
                    //anchor:'95%',//也可用此定义自适应宽度
                    allowBlank:false,//不允许为空
                    blankText:'帐户不能为空'//错误提示内容
                },{
                    inputType:'password',
                    fieldLabel: '密码',
                    //anchor:'95%',
                    name: 'pws',
                    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);
                               }*/
                               //提交请求
                                var requester = new Ext.data.Connection({
                                    method: 'post',
                                    url: './user/login.form?view=login',
                                    waitTitle: 'xxxxx',
                                    waitMsg: 'yyyyyyyyyyyyyyyy'
                                });
                                requester.request({
                                    params: {name: txtUserName.getValue(), pws: txtPassword.getValue()},
                                    scope: this,
                                    success: function(response, action) {
                                        var users = Ext.util.JSON.decode(response.responseText);
                                        if(!users.success){
                                            Ext.Msg.alert('登录错误', users.errors);
                                        }else{
                                            document.location='index.html';
                                        }

                                    },
                                    failure: function(response, action) {
                                        console.info('Error');
                                    }
                                });
                           }                                                       
                }
            },{
                text: '取消',
                handler:function(){simple.form.reset();}//重置表单
            }]
        }); 


               //定义窗体
               win = new Ext.Window({
                    id:'win',
                    title:'用户登陆',
                    layout:'fit',   //之前提到的布局方式fit,自适应布局                  
                    width:300,
                    height:150,
                    plain:true,
                    bodyStyle:'padding:5px;',
                    maximizable:false,//禁止最大化
                    closeAction:'close',
                    closable:false,//禁止关闭
                    collapsible:true,//可折叠
                    plain: true,
                    buttonAlign:'center',
                    items:simple//将表单作为窗体元素嵌套布局
                });
                win.show();//显示窗体

simple.render("show");
});

这是html页面
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">


abc
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">

<link href="./resources/styles/ext-all.css" rel="stylesheet" type="text/css"/>
<link href="./resources/styles/screen.css" rel="stylesheet" type="text/css" />

<script type="text/javascript" src="./resources/scripts/ext-base.js"></script>
<script type="text/javascript" src="./resources/scripts/ext-all.js"></script>
<script type="text/javascript" src="./resources/scripts/ext-lang-zh_CN.js"></script>
<script type="text/javascript" src="./resources/scripts/login.js"></script>






/**
* 登录请求
*/
public ModelAndView login(HttpServletRequest request,
HttpServletResponse response) throws Exception{
response.setContentType("application/json;charset=UTF-8");
String name = request.getParameter("name");
String pwd = request.getParameter("pws");
Map model = new HashMap();
if("admin".equals(name)){
model.put("success", Boolean.TRUE);
model.put("errors", "登陆成功!");
}
else{
model.put("success", Boolean.FALSE);
model.put("errors", "用户名或密码错误!");
}
return new ModelAndView("jsonView", model);
}

把以上代码copy回去就可以了;这是自己写的,希望对你有用

http://download.csdn.net/source/254802
http://download.csdn.net/source/603127
http://download.csdn.net/source/726620