1. #1
    Ext User
    Join Date
    Sep 2008
    Posts
    45
    Vote Rating
    0
    frank_ash is on a distinguished road

      0  

    Default remember username and password when type the name is textbox

    remember username and password when type the name is textbox


    hi,
    how to remember username and password in loginpage when enter the username in textbox..

    thanks is advance...

  2. #2
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246
    Vote Rating
    89
    Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of

      0  

    Default


    Do you want to remember it in code using a Cookie? Have a look at the Ext.state.CookieProvider class...

    Or do you want to use the browser autocomplete feature? In that case you input fields must already exist in the HTML, e.g.
    Code:
    <script type="text/javascript">
    new Ext.Window({
    	el: 'login',
    	title: 'Welcome',
    	width: 260,
    	resizable: false,
    	closable: false,
    	layout: 'form',
    	defaultType: 'textfield',
    	bodyStyle: 'padding: 5px;',
    	defaults: {
    		anchor: '-20',
    		allowBlank: false
    	},
    	items: [{
    		id: 'username',
    		el: 'username',
    		fieldLabel: 'Username'
    	},{
    		id: 'password',
    		el: 'password',
    		fieldLabel: 'Password'
    	}],
    	defaultButton: 'username',
    	buttonAlign: 'center',
    	buttons: [{
    		text: 'Login',
    		handler: function(){
    			Ext.getDom('submit').click();
    		}
    	}]
    }).show();
    </script>
    <body>
    <form id="login" method="post" action="j_security_check" class="x-hidden">
    <input type="text" id="username" name="j_username" />
    <input type="password" id="password" name="j_password" />
    <input type="submit" id="submit" value="Login" class="x-hidden" />
    </form>
    </body>

  3. #3
    Sencha User
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    6
    Vote Rating
    0
    ggranum is on a distinguished road

      0  

    Default


    "Or do you want to use the browser autocomplete feature? In that case you input fields must already exist in the HTML, e.g."

    This nifty example or at least the information in general would be right at home in the BasicForm or FormPanel docs :~)

  4. #4
    Sencha Premium Member
    Join Date
    Jul 2007
    Posts
    117
    Vote Rating
    1
    borg is on a distinguished road

      0  

    Default


    what if in my button handler I want to do this ajax type of submit rather than a normal post, how would i do it? Ext.getCmp('login').getForm() doesn't work

    Code:
    Ext.getCmp('login').getForm().submit({
    	url: scriptlocation,
    	waitMsg: 'Submitting...',
    	success: function(form, action) {
    		Ext.Msg.wait('Redirecting...');
    		window.location = 'test.htm';
    	},
    	failure: function(form, action) {
    		var msg = '';
    		if (action.failureType == Ext.form.Action.CLIENT_INVALID) {
    			msg = 'Invalid password.';
    		}
    		else if (action.failureType == Ext.form.Action.CONNECT_FAILURE) {
    			msg = 'Connection failure.';
    		}
    		else if (action.failureType == Ext.form.Action.LOAD_FAILURE) {
    			msg = 'Load failure.';
    		}
    		else if (action.failureType == Ext.form.Action.SERVER_INVALID) {
    			var jsonData = Ext.util.JSON.decode(action.response.responseText);
    			if (jsonData['error']) {
    				msg = jsonData['error'];
    			}
    		}
    
    		Ext.Msg.show({
    			title: 'Error',
    			msg: msg,
    			modal: true,
    			closable: false,
    			icon: Ext.Msg.ERROR,
    			buttons: Ext.Msg.OK,
    			fn: function (btn){
    				Ext.get('password').focus();
    			}
    		});
    	}
    });
    Ext-4.2.1 / Windows 7 SP1 / Firefox 24 / Firebug 1.12.2

  5. #5
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246
    Vote Rating
    89
    Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of

      0  

    Default


    For the autocomplete to work you must do a standard submit, otherwise the entered username and password aren't stored.

    The only thing you could try is:
    Code:
    Ext.get('login').on('submit', function(){
      Ext.getCmp('login').getForm().submit({
        ...
      });
    }, null, {stopEvent: true});
    I'm not sure if this also stores the username and password...

  6. #6
    Sencha Premium Member
    Join Date
    Jul 2007
    Posts
    117
    Vote Rating
    1
    borg is on a distinguished road

      0  

    Default


    tried that code, just did a standard submit. OK well if I can't do an ajax submit I don't want to use the save form field data anyway. thanks for the info
    Ext-4.2.1 / Windows 7 SP1 / Firefox 24 / Firebug 1.12.2

  7. #7
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,811
    Vote Rating
    834
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    this works on my applications:

    Code:
    	var formOnSuccessorFail = function(form, action) {
    		if (action.result.success) {
    			//do whatever you want
    		} else {
    			Ext.MessageBox.alert("Error", action.result.msg);
    		}
    	}
    	
    	var formSubmitHandler = function() {
    		var form = Ext.getCmp("myForm"); 
    		form.getForm().submit({
    			url: "functions.php",
    			params: {
    				one: "something"
    			},
    			success: formOnSuccessorFail,
    			failure: formOnSuccessorFail
    		});
    	}
    On my button I have it call formSubmitHandler()
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  8. #8
    Sencha User
    Join Date
    Jan 2008
    Posts
    29
    Vote Rating
    0
    sirioz10 is on a distinguished road

      0  

    Default


    Quote Originally Posted by mitchellsimoens View Post
    this works on my applications:

    Code:
        var formOnSuccessorFail = function(form, action) {
            if (action.result.success) {
                //do whatever you want
            } else {
                Ext.MessageBox.alert("Error", action.result.msg);
            }
        }
        
        var formSubmitHandler = function() {
            var form = Ext.getCmp("myForm"); 
            form.getForm().submit({
                url: "functions.php",
                params: {
                    one: "something"
                },
                success: formOnSuccessorFail,
                failure: formOnSuccessorFail
            });
        }
    On my button I have it call formSubmitHandler()
    Can you explain me your code?

    var form = Ext.getCmp("myForm");

    What is myForm?

  9. #9
    Sencha User fay's Avatar
    Join Date
    Apr 2007
    Location
    Ireland
    Posts
    1,750
    Vote Rating
    9
    fay will become famous soon enough fay will become famous soon enough

      0  

    Default


    From the Ext.getCmp docs:

    This is shorthand reference to Ext.ComponentMgr.get. Looks up an existing Component by id.
    So "myForm" is the value of the 'id' config param specified for that form.

  10. #10
    Sencha User
    Join Date
    Jan 2008
    Posts
    35
    Vote Rating
    0
    akrherz is on a distinguished road

      0  

    Question


    Hi,

    Would anybody kindly post a working example of this? I can't seem to figure out a combination that works among all browsers and OS. Currently, I have an extra button on the login window whose handler is
    PHP Code:
    Ext.getDom('submit').click(); 
    where there is a submit button with id of submit. This then goes to a simple php page that redirects back to the application. This catches most users, but not all.

    thanks,
    daryl