mardi 10 juin 2014

Session and Associations

Hi all,

I've defined three models as follows:



Code:



Ext.define('MyApp.model.Base', { extend: 'Ext.data.Model',
fields: [{
name: 'id',
type: 'int'
}],
schema: {
namespace: 'MyApp.model',
proxy: {
type: 'rest',
url: '/server/{entityName:lowercase}',
reader: {
type: 'json',
rootProperty: '{entityName:lowercase}'
}
}
}
});


Code:



Ext.define('MyApp.model.User', {
extend: 'MyApp.model.Base',

fields: ['name', 'login', 'pwd']
});


Code:



Ext.define('MyApp.model.Credential', {
extend: 'MyApp.model.Base',

fields: [
{name:'modulo',type:'int'},
{name:'ler', type:'boolean'},
{name:'criar', type:'boolean'},
{name:'excluir', type:'boolean'},
{name:'alterar', type:'boolean'},
{name:'permitir', type:'boolean'},
{name:'userId', type:'int', reference: 'User'}
]
})

And I created a record as follows:

Code:



var user = Ext.create('MyApp.model.User',{
pwd: '123',
name: 'Alessandro',
login: 'tester'
});

1) I expected to get the function "credentials()" in the "user" variable (as well as I would've got in previous releases by setting the "hasMany" association), but such function wasn't created automatically. What's wrong?

2) I didn't figure out how to properly use the Ext.data.Session. How can I syc to the server all records attached to the Session? How can I sync all associated records automatically?





Aucun commentaire:

Enregistrer un commentaire