ExtJs4 User Logon window

Source: Internet
Author: User

// User Logon window

Function getLoginWindow (){
Var loginWindow = Ext. WindowMgr. get ('loginwindow ');
If (! LoginWindow ){
LoginWindow = Ext. create ('ext. window. Window ',{
Id: 'loginwindow ',
Title: 'login Windows ',
Height: 160,
Width: 350,
Plain: true,
Resizable: false,
Closable: false,
Draggable: false,
ButtonAlign: 'center ',
Modal: true,
Plain: true,
Layout: 'fit ',
Items :[{
Xtype: 'form ',
Id: 'userloginform ',
Frame: true,
MonitorValid: true,
BodyPadding: 10,
BodyPadding: '10 5 0 ',
FieldDefaults :{
LabelAlign: 'right ',
LabelWidth: 70,
MsgTarget: 'day'
},
Items :[{
Xtype: 'textfield ',
Name: 'userloginform. username ',
FieldLabel: 'username ',
Margins: '20 20 20 20 ',
Width: 250,
EmptyText: 'Enter the user name ',
AllowBlank: false,
BlankText: 'user name cannot be blank'
},{
Xtype: 'textfield ',
FieldLabel: 'password & nbsp; Code ',
Name: 'userloginform. userpwd ',
Margins: '20 20 20 20 ',
Width: 250,
InputType: 'Password ',
EmptyText: 'Enter the password ',
AllowBlank: false,
BlankText: 'password cannot be blank'
}],
Listeners :{
Actioncomplete: function (formPanel, action ){
Location. href = basePath + '/success/loginSuccess. action ';
},
Actionfailed: function (formPanel, action ){
If (action. result ){
Ext. Msg. show ({
Title: 'login ',
Msg: action. result. msg,
Buttons: Ext. Msg. OK,
Closable: false,
Fn: function (btn ){},
Icon: Ext. MessageBox. QUESTION
});
} Else {
Alert (action. response. responseText );
}
}
}
}],
Buttons :[{
Text: 'login ',
Id: 'loginbtn ',
Width: 80,
Height: 30,
Listeners :{
Click: function (){
Login ();
}
}
},{
Text: 'reset ',
Width: 80,
Height: 30,
FormBind: true,
Listeners :{
Click: function (btn, even, opt ){
Ext. getCmp ('userloginform'). form. reset ();
}
}
}],
Listeners :{
Render: function (input ){
New Ext. KeyMap (input. getEl (),[{
Key: Ext. EventObject. ENTER,
Fn: function (){
Login ();
}
}]);
}
}
});
}
Return loginWindow;
}

// Save Method

Function login (){
Var userLoginForm = Ext. getCmp ('userloginform'). getForm ();
If (userLoginForm. isValid ()){
UserLoginForm. submit ({
Url: basePath + '/public/userLogin. action ',
WaitTitle: 'login ',
WaitMsg: 'login in progress. Please wait ...'
});
}
}

The ext4 keyboard event is equivalent to a change in the previous version:

Add a render event in the window.

Render: function (input ){
New Ext. KeyMap (input. getEl (),[{
Key: Ext. EventObject. ENTER,
Fn: function (){
Login ();
}
}]);
},

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.