jsm

net/sf/jsm/+jsmObject.js

Summary

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


Class Summary
JsmObject Root of all other jsm classes.

/**
 * Can not be instatiated.
 * @class Root of all other jsm classes. 
 * It can be considered an abstract class.
 */
  function JsmObject() {
	logger.error("JsmObject is abstract and can not be instantiated");
  	throw new Error("JsmObject is an abstract class and can not be instatiated");	
  } 
   
  /**
   * Holds the name of the class, in this case 'JsmObject'
   * @type String
   */  
  JsmObject.prototype.className="JsmObject";
  
  /**
   * The id of the object; Has to be defined in the constructor of each object to: 
   * <code>this.id=new Date().getTime() + "" + Math.random();</code>
   * @type String
   */   
  JsmObject.prototype.id=null;
  
   /** Constant: Meta data name: propertyPath: 
   * The property path to a member of variable of a JavaBean according to Jakarta BeanUtils 
   * Used to store back dirty values into the server side bean
   * @type String
   */ 
  JsmObject.prototype.META_DATA_NAME_PROPERTY_PATH = "propertyPath";
   /** Constant: Meta data name: value: 
   * For example a table cell uses this to store the value in its meta data. 
   * Used where the displayed value and the value to store back into the bean differs (eg. for selectboxes).
   * @type String
   */   
  JsmObject.prototype.META_DATA_NAME_VALUE = "value";  
  
  
  /**
   * Holds all specified attributes
   * @private
   * @type Hash
   */   
  JsmObject.prototype._attributes=null;
  
  /**
   * Holds all specified meta data
   * @private
   * @type Hash
   */   
  JsmObject.prototype._metaData=null;           
  
  /**
   * @return {String} String representation of this object
   */   
  JsmObject.prototype.toString = function() {
  	return "[" + this.className + " object]"
  }
  
  /** Returns the identity of each object
   * @return {String} The class name and the id
   */    
  JsmObject.prototype.identify = function() {
  	return "[" + this.className + ":" + this.getId() + "]"
  }  

  /**
   * Set the objects id
   * @param {String} theId
   * @return this
   */ 
  JsmObject.prototype.setId = function(theId) {
  	logger.debug(this.identify() + " Set id to: " + theId);
  	this.id = theId;
  	return this;
  }  
  
  /**
   * Get the objects id
   * @return {String}
   */   
  JsmObject.prototype.getId = function() {
  	return this.id;
  } 
 
  /**
   * Add an attribute to the object
   * @param {String} name Name of the attribute
   * @param {String} value Value of the attribute   
   * @return this
   */    
  JsmObject.prototype.setAttribute = function(name, value) {
  	logger.debug(this.identify() + " Set attribute: " + name + " - " + value);  
  	if (!this._attributes) {this._attributes = new Array();}
  	if (name == 'colspan') {name = 'colSpan'};
  	if (name == 'class') {name = 'className'};	  	
  	this._attributes[name]=value;  	
  	return this;
  } 

  /**
   * Gets the specified attribute value or the array of attributes
   * @param {String} name Optional: Name of the attribute  
   * @return {String/Array} Returns null if attribute is not set
   */  
  JsmObject.prototype.getAttribute = function(name) {
  	if (!this._attributes) {this._attributes = new Array();}  
  	if (jsm.noud(name)) {return this._attributes;}
  	if (name == 'colspan') {name = 'colSpan'};
  	if (name == 'class') {name = 'className'};  	
  	return this._attributes[name];
  }  
  
  /**
   * Add a meta data to the object
   * @param {String} name Name of the meta data
   * @param {String} value Value of the meta data   
   * @return this
   */    
  JsmObject.prototype.setMetaData = function(name, value) {
	if (!this._metaData) {this._metaData = new Array();} 
  	this._metaData[name]=value;
  	return this;
  }  
    
  /**
   * Get the specified meta data value or the array of meta data
   * @param {String} name Optional: Name of the meta data
   * @return {String/Array} Returns null if the meta data is not set
   */      
  JsmObject.prototype.getMetaData = function(name) {
  	if (!this._metaData) {this._metaData = new Array();}  
  	if (jsm.noud(name)) {return this._metaData;}	       	  
	return this._metaData[name];
  }   
  
  /**
  * Adds all the attributes of the object to the view component
  * @param theViewComponent The view component, eg. document.createElement("table");
  */
  JsmObject.prototype.addAttributesToViewComponent = function (theViewComponent) {
  	for (var attributeName in this._attributes) {
  		if (typeof this._attributes[attributeName] == 'function') {continue;}
  		if (attributeName == 'onkeyup') {theViewComponent.onkeyup=_jsmOnKeyUpEventDelegate;continue;}
  		if (attributeName == 'onchange') {theViewComponent.onchange=_jsmOnChangeEventDelegate;continue;}  		
  		if (attributeName == 'onclick') {theViewComponent.onclick=_jsmOnClickEventDelegate;continue;}  		  		
  		if (attributeName == 'onmousedown') {theViewComponent.onmousedown=_jsmOnMouseDownEventDelegate;continue;}  		  		
  		if (attributeName == 'onmouseup') {theViewComponent.onmouseup=_jsmOnMouseUpEventDelegate;continue;}  		  		  		
  		if (attributeName == 'onmousemove') {theViewComponent.onmousemove=_jsmOnMouseMoveEventDelegate;continue;}  	  		
  		theViewComponent.setAttribute(attributeName, this._attributes[attributeName]) 		
  	}     
  }

jsm

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