I have to admit, that I never really understood how the associations within Sencha ExtJS are working … especially when not working with a relational database.
So, some of the generated code by PUM for ExtJS was questionable – all in the area of associations.
Due to a new experimental project I had to code the UI again by myself and came across these problems. In this project I had to fill three different structures together and send them in an container object to the Gemstone/S server.
So I had 3 toOne-associations and the assignment of my three structures to the container object work, but the conversion to json failed totally.
So I had to read the documentation again and again and finally found, that a keyless definition of such an association would be the best definition for Gemstone/S. Actually the documentation of Sencha ExtJS mentioned a NonSQL-databases approach – the world is moving on !
So with the v10 codegenerator for ExtJS I changed the code for the :1 associations to:
hasOne: [
{
name: 'videoSetting',
model: 'gcr.model.GCRAPIVideoProductionSetting',
getterName: 'getVideoSettingField',
setterName: 'setVideoSettingField',
associationKey: 'videoSetting'
},
{
name: 'ddxmlSetting',
model: 'gcr.model.GCRAPIDDXMLSetting',
getterName: 'getDdxmlSettingField',
setterName: 'setDdxmlSettingField',
associationKey: 'ddxmlSetting'
},
{
name: 'pictureSetting',
model: 'gcr.model.GCRAPIPictureProductionSetting',
getterName: 'getPictureSettingField',
setterName: 'setPictureSettingField',
associationKey: 'pictureSetting'
}
]
with the following explanations:
- name – this is the name of the attribute
- model – this is the name of the class (“model”) of the instance in this ToOne association
- getterName – this is the name of the function Sencha generates for getting the object
- settingName – this is the name of the function Sencha generates for setting the association
- associationKey – normally the same as name, but can be different. Its the key used in the json structure to hold the ToOne association
So, with these changes you can program on the model-level within Sencha ExtJS and handle the toOne associations within an object comfortably:
var
aContainerObject = new ContainerObject(),
aGCRAPIVideoProductionSetting = new gcr.model.GCRAPIVideoProductionSetting();
aContainerObject.setVideoSettingField(aGCRAPIVideoProductionSetting);