Ext.define('Login.view.ForgotPasswordForm', { extend: 'Ext.form.Panel', alias: 'widget.forgotPasswordForm', bodyStyle: 'font-family: Arial; background-color: #dfe8f6;', frame: true, padding: 10, width: 325, method: 'POST', monitorValid: true, defaultType: 'textfield', defaults: { anchor: '100%', allowBlank: false, enableKeyEvents: true }, items: [ { xtype: 'label', itemId: 'infoLabel', style: { color: 'green' }, text: '' }, { xtype: 'label', itemId: 'errorLabel', style: { color: 'red' }, text: 'If you forgot your password please insert your username and submit' }, { fieldLabel: 'Username', name: 'username', itemId: 'username', allowBlank: false, maxLength: 25 } ], buttons: [ { xtype: 'button', text: 'Submit', itemId: 'forgotButton', action: 'submit' } ] }); Ext.define('Login.view.ForgotPasswordWindow', { extend: 'Ext.window.Window', alias: 'widget.forgotPasswordWindow', title: 'Forgot Password', layout: 'fit', resizable: true, minHeight: 150, closable: false, border: false, plain: true, items: [ { xtype: 'forgotPasswordForm' } ], tbar: [ '->', { text: 'Log in', action: 'login' } ] }); Ext.define('Login.controller.ForgotPasswordController', { extend: 'Ext.app.Controller', init: function () { this.control({ 'forgotPasswordWindow button[action=login]': { click: this.login }, 'forgotPasswordWindow button[action=submit]': { click: this.submit }, 'forgotPasswordWindow textfield': { keydown: this.onKeyPress } }); }, login: function (button) { button.up('window').close(); this.getController('LoginController').loginWindow.show(); }, submit: function (button) { var forgotPasswordForm = button.up('window').down('form'); if (forgotPasswordForm.getForm().isValid()) { forgotPasswordForm.submit({ scope: this, url: '/cen/register/adminReset.do', params: { action: 'forgotPassword', '_csrf': 'dabd004d-162d-4669-8cf0-dc7606476df4' }, success: function (form, action) { if (action.result.smtpConnectionErrorWCO || action.result.errorOnReset) { action.failure(); } else { forgotPasswordForm.down('#username').setValue(null); forgotPasswordForm.down('#errorLabel').hide(); forgotPasswordForm.down('#infoLabel').show(); forgotPasswordForm.down('#infoLabel').setText('Your request has been submitted! You\'ll receive an email with details.'); } }, failure: function (form, action) { forgotPasswordForm.down('#infoLabel').hide(); forgotPasswordForm.down('#errorLabel').show(); forgotPasswordForm.down('#errorLabel').setText('Password reset was not successful.'); } }); } }, onKeyPress: function (field, eventObject) { if (eventObject.getCharCode() == Ext.EventObject.ENTER) { var forgotButton = field.up('window').down('#forgotButton'); forgotButton.fireEvent('click', forgotButton); } else { return false; } } });