PDA

View Full Version : XML with CDATA in 4.0.1



eascanzano
17 Jun 2011, 4:12 PM
Hi All,

I am trying parse the XML below with this code. I am not getting anything for child elements. I have no idea what to write to parse the CDATA. I also noted the defect with more than one hasMany which I presume is not fixed in 4.0.1.



Ext.define('Coriolis', {
extend: 'Ext.util.Observable',

constructor: function(config) {
this.name = config.name;

this.addEvents({
});

this.listeners = config.listeners;

// Call our superclass constructor to complete construction process.
Coriolis.superclass.constructor.call(this, config)
},
});
var Coriolis = new Coriolis({});

Coriolis.behaviors = new Object();

// ***************************************************************************************
Ext.define('Config', {
extend: 'Ext.data.Model',
fields: [
{name: 'name', mapping: '@name'},
],
belongsTo: 'BehaviorXML'
});
Ext.define('Listener', {
extend: 'Ext.data.Model',
fields: [
{name: 'name', mapping: '@name'}
],
belongsTo: 'BehaviorXML'
});
Ext.define('ClientMethod', {
extend: 'Ext.data.Model',
fields: [
{name: 'name', mapping: '@name'}
],
belongsTo: 'BehaviorXML'
});

Ext.define('BehaviorXML', {
extend: 'Ext.data.Model',
fields: [
{name: 'name', mapping: '@name'},
{name: 'javaclass', mapping: '@javaclass'}
],
hasMany: {model: 'Config', name: 'configs', associationKey: 'configs'}
});
var store = new Ext.data.Store({
model: 'BehaviorXML',
autoLoad: false,
autoDestroy: true,
storeId: 'myStore',
proxy: {
type: 'ajax',
url : '/Coriolis/Main/md/realm1/Developer/Behavior',
reader: {
type: 'xml',
root: 'dataset',
record: 'row'
}
}
});
store.load({
callback: function() {
var i = 0;
// for (i = 0;i<this.getCount();i++) {
var behavior = this.getAt(i);
var o = new CBehavior({});
o['name'] = behavior.get('name');
o['javaclass'] = behavior.get('javaclass');

Coriolis.behaviors[behavior.get('name')] = o;

behavior.configs().each(function(con) {
console.log(con.get('name'));
});
// }
console.log(Coriolis.behaviors);
}
});

<dataset>
<row name="Ext.toolbar.Fill" javaclass="Behavior Standard Component" project="Coriolis" inactive="false" comments="" module="" repository="com.coriolis">
<configs>
<config name="id" inactive="false" comments="" module="" repository="com.coriolis">
<configScript>
<![CDATA[<% return "'" + coriolis.getActiveObject().getUniqueID() + "'";%>]]>
</configScript>
</config>
<config name="UIComponentName" inactive="false" comments="" module="" repository="com.coriolis">
<configScript>
<![CDATA[<% return "'" + coriolis.getCurrentComponent().getName() + "'";%>]]>
</configScript>
</config>
</configs>
</row>
</dataset>