ExtJs Model Proxy vs. Store Proxy -
OK, I'm stuck on what should be a basic task in ExtJs. I'm writing a simple login script which Undoubtedly sends a username and password combination for the web service and receives a GUID if the credentials are correct.
My question is, am I a model proxy or store proxy?
In my understanding, models represent a record, whereas the store is to deal with the data set with more than one record. If it is correct, then it seems that the model is a proxy way.
After the documentation of Senca on the code, something like this will appear:
Ext.define ('AuthenticationModel', {extension: 'Ext.data.Model', field: ['Username', 'password'], proxy: {type: 'comfort', url: '/ authentication'}}); // Get a reference for the Certification Model class var validation model = Ext.ModelManager.getModel ('AuthenticationModel');
So far everything is fine, to the next step:
// Modify a GET request authentication to use the RestProxy configured.load ('???', {Success: Function (session) {console.log ('Login successful');}});
The Load () method for model class is a single call that expects a single unique identifier. Logs usually depend on two factors, user names and passwords.
It seems that the store proxy is the only way to validate the credential combination of someone's username and password in EXJs. Can anyone verify and explain? Any help to understand this will be greatly appreciated.
All you need to know is the following:
You configure one for this example and if it does not take proxy from the model, then the store will use its proxy.
Then you can easily enable two proxy configurations to enable multi-crude operations on the store and single-crude operation on the model. Note that the static load method of the model expects the model id
because it is considered to load a model by just an ID (yes, overall keys are not supported). You'll also need to get a model example in the callback (as you did).
Back to your user name / password problem
You can apply your application with a custom 'LoadSession' method with session model < / P>
loadSession: function (user name, password, config) {config = Ext.apply ({}, config); Config = Ext.applyIf (config, {action: 'read', username: username, password: password}); Var Operation = New Extension. Data Operation (config), scope = config this, callback; Callback = function (operation) {var record = zero, success = operation Vast successful (); If (success) {record = operation.getRecords () [0]; // If the server has not set the ID, then do it here (! Record.hasId ()) {record.setId (user name); // Keep in mind to apply the ID here. } Ext.cellback (config.success, scope, [records, operations]); } Other {Ext.callback (config.failure, scope, [record, operation]); } Ext.cellback (config.callback, scope, [records, operations, success]); }; This.getProxy () Read (Operation, Callback, It); }
Now call it instead of load.
Comments
Post a Comment