// 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 ();
}
}]);
},