Jx.JxJsonWriterRest

This class is used by applications to interact with the platform's REST Web services. It overrides the toHash method of Ext.data.JsonWriter to convert JsonData sent from EXT JS to the data that is sent over the wire to a REST service. The overriding toHash method sends only those fields that have changed.


/**
 * @class Jx.JxJsonReader
 * This is a class which should be used by apps to interract 
 * with the Rest web services provided by the platform.
 */
Jx.JxJsonWriterRest = Ext.extend(Ext.data.JsonWriter, {
    toHash: function (rec) {
        var map = rec.fields.map,
            data = {},
            raw = (this.writeAllFields === false && rec.phantom === false) ? rec.getChanges() : rec.data,
            m;
        Ext.iterate(raw, function (prop, value) {
            if ((m = map[prop])) {
                data[m.mapping ? m.mapping : m.name] = value;
            }
        });
        if (rec.phantom === false) {
            data[this.meta.idProperty] = rec.id;
        }
        return data;
    }
});