PDA

View Full Version : [CLOSED] 5.0.1 Error loading xml model, Uncaught Error: Invalid record id returned for [email protected]



harrypottar
16 Sep 2014, 7:52 AM
Moving from Extjs 4.0.7 to ExtJs 5.0.1, we load XML configuration files on all our ext apps.

The below snippet of code is a base xml model and a call from the controller onLaunch function, this works in ExtJs 4.x but I get the following error with 5.0.1

Uncaught Error: Invalid record id returned for [email protected]


Model:

Ext.define('lostpassword.model.XMLLostPasswordConfig', {
extend: 'Ext.data.Model',
fields: [
{name: 'formtitle', mapping: '/description/form-title', type: 'string',convert: function(v){return Ext.String.trim(v);}, defaultValue:''},

{name: 'formTopMessage', mapping: '/description/top-message', type: 'string',convert: function(v){return Ext.String.trim(v);}, defaultValue:''},
{name: 'formTopMessageInclude', mapping: '/description/top-message/@includeinform', type: 'int', defaultValue: false },

{name: 'mysqlDateFormat', mapping: '/form/elements/@mysqldateformat', type: 'string',convert: function(v){return Ext.String.trim(v);}, defaultValue:''},

{name: 'formLabelPosition', mapping: '/form/elements/@labelposition', type: 'string',convert: function(v){return Ext.String.trim(v);}, defaultValue:''},

{name: 'statusZero', mapping: '/description/sitestatus/zero', type: 'string',convert: function(v){return Ext.String.trim(v);}, defaultValue:''},
{name: 'statusFour', mapping: '/description/sitestatus/four', type: 'string',convert: function(v){return Ext.String.trim(v);}, defaultValue:''},
{name: 'statusEight', mapping: '/description/sitestatus/eight', type: 'string',convert: function(v){return Ext.String.trim(v);}, defaultValue:''},
{name: 'statusTen', mapping: '/description/sitestatus/ten', type: 'string',convert: function(v){return Ext.String.trim(v);}, defaultValue:''},
{name: 'statusFourTeen', mapping: '/description/sitestatus/fourteen', type: 'string',convert: function(v){return Ext.String.trim(v);}, defaultValue:''},
{name: 'statusTwenty', mapping: '/description/sitestatus/twenty', type: 'string',convert: function(v){return Ext.String.trim(v);}, defaultValue:''},
{name: 'statusTwentyFour', mapping: '/description/sitestatus/twentyfour', type: 'string',convert: function(v){return Ext.String.trim(v);}, defaultValue:''},
{name: 'statusNinety', mapping: '/description/sitestatus/ninety', type: 'string',convert: function(v){return Ext.String.trim(v);}, defaultValue:''},
{name: 'statusNinetyFour', mapping: '/description/sitestatus/ninetyfour', type: 'string',convert: function(v){return Ext.String.trim(v);}, defaultValue:''},
{name: 'statusNinetyNine', mapping: '/description/sitestatus/ninetynine', type: 'string',convert: function(v){return Ext.String.trim(v);}, defaultValue:''}

],
proxy: {
type: 'ajax',
reader: {
type: 'xml',
record: 'portal_auth_page_description'
}
}
});


Call:


onLaunch: function() {
//check if the languge xml is already loaded
if (lostpasswordXML == undefined) {
var objXml = this.getXMLLostPasswordConfigModel();

var xmlPath = lostpasswordConfigObj.siteUrl + '/authentication/templates/lostpassword/lang/' + this.xinetLanguge + '/lostpasswordform.xml';
//fetch the XML document
objXml.load(0,{
scope: this,
url: xmlPath,
callback: this.processXml//what to do when we get the xml

});
} else {
//xml is alreday loaded.
this.creatView();
}


},


thanks in advance

harrypottar
16 Sep 2014, 11:05 AM
Ok, we've never has to do this before, but if I add an id field to the model


{name: 'id', type: 'int', mapping: '/description/@recordid'},


and then add an attribute to me xml


<description recordid="0">

it now loads fine?

If I set a defaultValue that does not work either.


{name: 'id', type: 'int', defaultValue: 1},

Odd that it now needs id defining and existing in the XML.

thanks