Base class for all components.
All RichFaces components should use this class as base or another RichFaces class which based on it.
//Inheritance example:
(function ($, richfaces, params) {
// Constructor definition
richfaces.MyComponent = function(componentId, [options]) {
// call constructor of parent class
$super.constructor.call(this, componentId, [options]);
// call this.attachToDom method to attach component to dom element
// its required for the client side API calls and to clean up after ajax request or page unload:
// destroy method will be called if component attached to dom
this.attachToDom(componentId);
};
// define private method
var myPrivateMethod = function () {
}
// Extend component class and add protected methods from parent class to our container
richfaces.BaseComponent.extend(richfaces.BaseComponent, richfaces.MyComponent);
// define super class link
var $super = richfaces.MyComponent.$super;
// Add new properties and methods
$.extend(richfaces.MyComponent.prototype, (function (params) {
return {
name:"MyComponent",
f:function (){alert("hello"),
// destroy method definition for clean up
destroy: function () {
// clean up code here
// call parent's destroy method
$super.destroy.call(this);
}
}
};
})(params));
})(jQuery, RichFaces);