jsm

net/sf/jsm/widgets/++jsmWidget.js

Summary

No overview generated for 'net/sf/jsm/widgets/++jsmWidget.js'


Class Summary
JsmWidget Base object for widgets

/**
 * JsmWidget should be considered abstract. 
 * @extends JsmObject
 * @class Base object for widgets
 * @constructor
 */   
  function JsmWidget() {
	logger.error("JsmWidget is abstract and can not be instantiated");  
	throw new Error("JsmWidget is an abstract class and can not be instatiated");    	
  }
  
  JsmWidget.extendClass(JsmObject);
  
  /** @ignore */  
  JsmWidget.prototype.className="JsmWidget"; 
  
  /** Attached validators
  * @type Array
  */  
  JsmWidget.prototype._validators;   
  
  /** Each widget to be attached to a {@link JsmTable} has to implement this method!
  * Will be called from the _jsmOnSaveRow event; the widget has to modify the model according to its own design
  * @param {JsmTable} table The table this widget is attached to
  * @param {int} rowIdx The index of the row
  * @param {int} columnIdx The index of the column
  * @param theViewComponent 
  */
  JsmWidget.prototype.updateModel = function(table, rowIdx, columnIdx, theViewComponent) {
  	alert("A JsmWidget has to implement the updateModel method");	
  }    
  
  /** Each widget to be attached to a {@link JsmTable} has to implement this method!
  * Will be called in the {@link JsmTd#getNode} method ( before the {@link #getNode} method of the widget is called) 
  * @param {JsmTd} theTd The cell in which this widget will be displayed
  */
  JsmWidget.prototype.init = function(theTd) {
  	alert("A JsmWidget has to implement the init method");
  } 
  
  /** Each widget to be attached to a {@link JsmTable} has to implement this method!
  * Will be called to retrieve the view component; it will be appended as a child to the table cell  
  */  
  JsmWidget.prototype.getNode = function() {
  	alert("A JsmWidget has to implement the getNode method");
  } 
  
  /** Clone this widget*/  
  JsmWidget.prototype.clone = function() {
  	alert("A JsmWidget has to implement the clone method");
  }      
  
  /** A widget should call this method before updating the model and if it returns false
  * the model should not be updated. This method will call each attached validators validate()-method
  * passing on its arguments.
  * @param {JsmTable} table The table the widget is attached to 
  * @param {int} rowIdx The index of the row this widget is displayed in
  * @param {int} columnIdx The index of the column this widget is displayed in
  * @param theViewComponent The view object
  * @return {boolean}
  */
  JsmWidget.prototype.validate = function(table, rowIdx, columnIdx, theViewComponent) {
  	retVal = true;
	for (var validator=0;validator<this.getValidators().length;validator++) {  
		if (!this.getValidators()[validator].validate(table, rowIdx, columnIdx, theViewComponent)) {
			return false;
		}
	} 
	return retVal;
  }      
  
  /**
  * Add a validator
  * @return this
  */
  JsmWidget.prototype.addValidator = function(validator) {
  	if (!this._validators) {this._validators = new Array();}  
  	this._validators.push(validator);
  	return this;
  }
  
  /**
  * Get all attached validators
  * @return {Array}
  */  
  JsmWidget.prototype.getValidators = function() {
  	if (!this._validators) {this._validators = new Array();}  
  	return this._validators;
  }  

  /**
  * Remove all attached validators
  * @return this
  */ 
  JsmWidget.prototype.removeValidators = function() {
  	this._validators = new Array();
  	return this;
  }   
   

jsm

Documentation generated by JSDoc on Tue Sep 26 08:42:57 2006