ExtJS uses cookies to save login information

Source: Internet
Author: User

The project has the following requirement: select an organization name during logon, and enter an account to log on. The next time you log on, the last logon page is displayed in the "unit selection" box.
The specific implementation is as follows:

{
Xtype: 'combo ', // here is the combo of the unit selected
Id: 'orgname ',
Store: orgStore,
Name: 'orgname ',
EmptyText: 'select the unit ',
DisplayField: 'orgname ',
ValueField: 'dbname ',
Editable: false,
ForceSelection: true,
TriggerAction: 'all ',
Shadow: 'framework ',
HiddenName: 'dbname ',
Listeners :{
Select: function () {// Add one select function. When this function is selected, save the selection result to the cookie.
Savedbname = Ext. getCmp ('orgname'). getValue ();
Ext. util. Cookies. set ('savedbname', savedbname );
}
}
}

 

 
Var orgStore = new Ext. data. JsonStore ({// This is the Combo data Source selected by the Unit
Url: 'test/LoginOrgSelectServlet ',
Root: 'orgselect ',
Fields: ['orgname', 'dbname'],
AutoLoad: true,
Listeners: {load: function () {// Add a load listener to the store.
Var cookiedata = Ext. util. Cookies. get ("savedbname ");
If (cookiedata! = Null) {Ext. getCmp ('orgname'). setValue (cookiedata);} // set the combo value when the data in the cookie is not empty.
}}
});

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.