jsm

net/sf/jsm/widgets/jsmTextField.js

Summary

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


Class Summary
JsmTextField Represents a text field

/**
 * Creates a new JsmTextField
 * @extends JsmWidget
 * @class Represents a text field
 * @param {String} value The value of this text field
 * @constructor
 */   
  function JsmTextField(value) {
  	/** @ignore */
  	this.id=new Date().getTime() + "" + Math.random(); 
  	logger.info("Created JsmTextField with id: " + this.id);   	
  	/** The value of the text field 
  	* @type String
  	*/	  	
  	this.value = value;
  	if (jsm.noud(this.value)) this.value="";
  }

  JsmTextField.extendClass(JsmWidget);

  /** @ignore */
  JsmTextField.prototype.className="JsmTextField";
  
  /** @ignore */
  JsmTextField.prototype.toString = function() {
  	return "[JsmTextField object: value=" + this.value + "]\n"; 	
  }
  
  /** Get the value of this text field
   * @return {String}
   */
  JsmTextField.prototype.getValue = function() {
  	return this.value; 	
  }  
  
  /** Set the value of this text field
   * @return this
   */  
  JsmTextField.prototype.setValue = function(value) {
  	this.value = value; 	
  	return this;
  }    
  
  /** Update the tabel model if all validators are passed
   * @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   
   */  
  JsmTextField.prototype.updateModel = function(table, rowIdx, columnIdx, theViewComponent) {
  	if (jsm.noud(theViewComponent)) {return;}  
	if (!this.validate(table, rowIdx, columnIdx, theViewComponent)) {
		return;
	}
  	td = table.getTd(rowIdx, columnIdx);
  	if (td.getValue() != theViewComponent.value) {td.setDirty(true);}
	td.setValue(theViewComponent.value); 	
  }    
  
  /** Init this text field's value from with the tabel cells value
  * @param {JsmTd} theTd The cell in which this widget is displayed
  */  
  JsmTextField.prototype.init = function(theTd) {
  	this.value = theTd.getValue();
  	return this;
  } 
  
  /** Returns the node of the view component; the model (this) will be attached to the node as property 'model'
  * @return theViewComponent The node of the view component (for example to append to a table cell)
  */
  JsmTextField.prototype.getNode = function() {
  	var textfield = document.createElement("input"); 
  	textfield.model = this;
  	textfield.setAttribute("id", this.id);
  	textfield.setAttribute("name", this.id);  
  	textfield.setAttribute("type", "text");
  	textfield.setAttribute("value", this.value);  	
  	this.addAttributesToViewComponent(textfield);   	
  	return textfield;
  } 
  
  /** Clones this JsmTextField
  * @return {JsmTextField}
  */
  JsmTextField.prototype.clone = function() {
	var clonedWidget = new JsmTextField();
   	//TODO is it sufficient to copy the Array or do we have to iterate and copy each entry
   	clonedWidget._attributes = this._attributes;
   	clonedWidget._metaData = this._metaData;   
   	clonedWidget.value = this.value;   		
   	return clonedWidget;	
  }    
  
  
  
  

jsm

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