PDA

View Full Version : Advise: Plugin to override component function



DaviBaldin
15 Jun 2010, 6:54 AM
HI all,

I'm developing a plugin to override some component functions. I would like to hear if my approch is correct.


App.form.EntityFormPlugin = Ext.extend(Ext.util.Observable, {

/**
* Entity represented by JSON data.
*/
entity: null,

/**
* Form container.
*/
form: null,

/**
* API to load and save data.
*/
api: null,

constructor: function(config){
Ext.apply(this, config);
App.form.EntityFormPlugin.superclass.constructor.call(this);

//Override Form's load action.
var f = Ext.form.BasicForm.prototype;
f.load = function(){};
f.load = f.load.createInterceptor(this.load, this);

//Add a new Form save action.
f.save = function(){};
f.save = f.save.createInterceptor(this.save, this);
},

init: function(formPanel){
this.form = formPanel.getForm();
this.form.load = function() {};
},

load: function() {}
});


Thanks,

Davi