Ext formpanel 二次显示出错

最近在做一个用户管理的小模块 用的ext的formpanel在前台展示,
很简单 一个注册一个登陆按钮,然后弹出各自的Ext.Window,其中自然包含formpanel,现在的问题是
用户登录之后我把登陆按钮给隐藏了,然后用户点注销再显示登录按钮,可是再次点登陆按钮的时候弹出windows,然后我再次输入用户名密码,可是程序中总也去不到用户名和密码了,我都是用的id取的,不知道这里有什么问题,希望大家给看一下!
下面是我的代码

[code="JavaScript"]

Ext.onReady(function(){
var i=0;
var loninUser = Ext.get('userLoginBtn');
var win,baseInfoPanel;

loninUser.on('click', function(){

    baseInfoPanel = new Ext.FormPanel({
        labelWidth: 40, // label settings here cascade unless overridden
        frame:true,
        autoWidth: true,
        height: 300,
        title: '用户登录',
        labelAlign : 'right',
        defaults: {width: 200},
        defaultType: 'textfield',
        bodyStyle:'padding:15px 15px 0',
        items: [
                new Ext.form.TextField({
                fieldLabel: '用户名',
                id:   'userlogin_username',
                allowBlank:false,
                blankText:'用户名不能为空',
                vtype:'alphanum',
                vtypeText:'用户名中只能包含英文字母,数字和_',
                msgTarget:'under'


            }),{
                fieldLabel: '密码',
                id:  'userlogin_password',
                inputType: 'password',
                blankText:'请填写密码',
                msgTarget:'under',
                allowBlank: false
            }]

    });

    var tabs = new Ext.TabPanel({
        deferredRender: false,
        anchor:'0,0',
        region: 'center',
        margins:'3 3 3 0', 

        activeTab: 0,
        items: [baseInfoPanel],
        layoutOnTabChange : true,
        listeners:{
            tabchange : function(){
                tabs.doLayout(false);
            }
        }
    });

//

    if(!win){
        win = new Ext.Window({
            el:'userLoginDiv',
            layout:'fit',
            width:400,
            height:300,
            modal:true,
            closeAction:'hide',
            closable:false,
            plain: true,

            items:baseInfoPanel,

            buttons: [{
                text:'确定',
                disabled:false,
                handler: function(){


                    if(baseInfoPanel.form.isValid()){

                    var privBits = '';
                    var end = 0;
                                            var userparams ={                       
                        userName:baseInfoPanel.findById( 'userlogin_username').getValue(),
                        password:baseInfoPanel.findById( 'userlogin_password').getValue()

                    };


                    Ext.Ajax.request({
                        url:'servlet/userajax?class=cn.com.infcn.usp.ajax.user.UserAction&verb=login',
                        method: 'POST',

                        params:userparams,
                        callback:function(options,success,response){

                            var results = Ext.decode(response.responseText);
                            if(results.success == false){
                                alert(results.message);
                            }else {
                                alert('恭喜'+results.result+',登录成功');
                                win.hide();
                                //设置登录和注册按钮不可用
                                document.getElementById('userLoginBtn').style.display='none';
                                document.getElementById('registerNewUserBtn').style.display='none';
                                document.getElementById('showUserNamePla').style.display='';
                                var loginUserName = document.getElementById('loginUserName').innerText=results.result;


                            }

                        },
                        failure: function(errMsg){
                            alert(errMsg);
                        }
                        });          


                }else{
                    Ext.Msg.alert('验证未通过','输入数据不合法,请检查输入的数据');
                }


            }
            },{

                text: '取消',
                handler: function(){
                    baseInfoPanel.form.reset();
                    win.hide();
                    //button.dom.title('注册');
                }

                }]
        });
   }
    win.show(this);
});

});

[/code]

[b]问题补充:[/b]
刚才我 items: baseInfoPanel, 换成items:tabs,运行还是有同样的错误就是第二次提交的时候,在
userName:baseInfoPanel.findById( 'userlogin_username').getValue(),

password:baseInfoPanel.findById( 'userlogin_password').getValue()

这里baseInfoPanel.findById( 'userlogin_username')会报undefined错误 不理解
[b]问题补充:[/b]
var win, baseInfoPanel这个我放到formpanel中的时候貌似可以再次提交了 不过出了新问题,就是第二次点登陆的时候会弹出两个window重叠,这样逐次增加 又是为什么呢
[b]问题补充:[/b]
我把那个closeAction:'close'改了以后如果后面按钮事件中的hide不改则问题还存在如果也都改为close();就会报一个错 : this.el.dom为空或者不是对象

[b]问题补充:[/b]
问题基本上应该是在这里,第二次取得时候通过id去不到那两个对象,是这样吧。我不理解的是既然运行到这里了那么baseInfoPanel应该是新创建的 同时那两个元素也就是新的啊,怎么可能去不到呢?麻烦了 userName:baseInfoPanel.findById( 'userlogin_username').getValue(),
password:baseInfoPanel.findById( 'userlogin_password').getValue()
[b]问题补充:[/b]
对了 我是照着ext的例子做的。在我的jsp中还加了这个

登陆
                </div>

是不是在windows。destroy的时候这两个div也没了 ,然后再次点登陆的时候找不到这两个div啊,有没有这个可能

yes

代码我就没有帮你运行测试了.初步帮你找了原因

[code="js"]
Ext.onReady(function () {
var i = 0;
var loninUser = Ext.get('userLoginBtn');

loninUser.on('click', function () {
    var win, baseInfoPanel; //放进来看看
    baseInfoPanel = new Ext.FormPanel({
        labelWidth: 40,
        // label settings here cascade unless overridden
        frame: true,
        autoWidth: true,
        height: 300,
        title: '用户登录',
        labelAlign: 'right',
        defaults: {
            width: 200
        },
        defaultType: 'textfield',
        bodyStyle: 'padding:15px 15px 0',
        items: [
        new Ext.form.TextField({
            fieldLabel: '用户名',
            id: 'userlogin_username',
            //尽量别用id,用父子关系来获得对象
            allowBlank: false,
            blankText: '用户名不能为空',
            vtype: 'alphanum',
            vtypeText: '用户名中只能包含英文字母,数字和_',
            msgTarget: 'under'

        }), {
            fieldLabel: '密码',
            id: 'userlogin_password',
            inputType: 'password',
            blankText: '请填写密码',
            msgTarget: 'under',
            allowBlank: false
        }]

    });

    var tabs = new Ext.TabPanel({
        deferredRender: false,
        anchor: '0,0',
        region: 'center',
        margins: '3 3 3 0',

        activeTab: 0,
        items: [baseInfoPanel],
        layoutOnTabChange: true,
        listeners: {
            tabchange: function () {
                tabs.doLayout(false);
            }
        }
    });
    //      
    if (!win) {
        win = new Ext.Window({
            el: 'userLoginDiv',
            layout: 'fit',
            width: 400,
            height: 300,
            modal: true,
            closeAction: 'hide',
            closable: false,
            plain: true,

            items: baseInfoPanel,
            //你这里应用不正确,baseInfoPanel已经放到了var tabs = new Ext.TabPanel()tabs里面了.
            //就不应该再放到这里.我想主要问题应该就在这里了一个对象在一个地方渲染过了.
            //就不要再放到其他组件里面去.这样会出错的.要单独创建对象,分开来应用
            buttons: [{
                text: '确定',
                disabled: false,
                handler: function () {

                    if (baseInfoPanel.form.isValid()) {

                        var privBits = '';
                        var end = 0;
                        var userparams = {
                            userName: baseInfoPanel.findById('userlogin_username').getValue(),
                            password: baseInfoPanel.findById('userlogin_password').getValue()

                        };

                        Ext.Ajax.request({
                            url: 'servlet/userajax?class=cn.com.infcn.usp.ajax.user.UserAction&verb=login',
                            method: 'POST',

                            params: userparams,
                            callback: function (options, success, response) {

                                var results = Ext.decode(response.responseText);
                                if (results.success == false) {
                                    alert(results.message);
                                } else {
                                    alert('恭喜' + results.result + ',登录成功');
                                    win.hide();
                                    //设置登录和注册按钮不可用
                                    document.getElementById('userLoginBtn').style.display = 'none';
                                    document.getElementById('registerNewUserBtn').style.display = 'none';
                                    document.getElementById('showUserNamePla').style.display = '';
                                    var loginUserName = document.getElementById('loginUserName').innerText = results.result;

                                }

                            },
                            failure: function (errMsg) {
                                alert(errMsg);
                            }
                        });

                    } else {
                        Ext.Msg.alert('验证未通过', '输入数据不合法,请检查输入的数据');
                    }

                }
            },
            {

                text: '取消',
                handler: function () {
                    baseInfoPanel.form.reset();
                    win.hide();
                    //button.dom.title('注册');
                }

            }]
        });
    }
    win.show(this);
});

});
[/code]

closeAction:'close',

那就是其他原因导致的了.你不可能因为避免那个错误才这样做.你应该解决那个问题.想你这种写法,对象应该用销毁方式比较好.不要隐藏.你说的this.el.dom是因为这个对象销毁了然后你再去引用它,就会异常

findById 原因就是这个了.别用id.用层级关系