incubator-xap-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmarga...@apache.org
Subject svn commit: r485952 - /incubator/xap/trunk/src/xap/taghandling/AbstractTagImpl.js
Date Mon, 11 Dec 2006 23:55:18 GMT
Author: jmargaris
Date: Mon Dec 11 15:55:17 2006
New Revision: 485952

URL: http://svn.apache.org/viewvc?view=rev&rev=485952
Log:
added writeTextNode() for textArea support

Modified:
    incubator/xap/trunk/src/xap/taghandling/AbstractTagImpl.js

Modified: incubator/xap/trunk/src/xap/taghandling/AbstractTagImpl.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/taghandling/AbstractTagImpl.js?view=diff&rev=485952&r1=485951&r2=485952
==============================================================================
--- incubator/xap/trunk/src/xap/taghandling/AbstractTagImpl.js (original)
+++ incubator/xap/trunk/src/xap/taghandling/AbstractTagImpl.js Mon Dec 11 15:55:17 2006
@@ -25,6 +25,7 @@
 Xap.require("google.*");
 Xap.require("xap.xml.InvalidXmlException");
 Xap.require("xap.session.EventHandler") ;
+Xap.require("xap.xml.dom.Document") ;
 
 
 //TODO we need to handle qualifying URLs properly based on the request page again
@@ -507,19 +508,26 @@
 xap.taghandling.AbstractTagImpl.prototype.getUiContentHandler = function() {
 	return this.getSession().getUiDocumentHandler();
 }
-//	
-//
-//	public void writeBackTextNode(int index, String value){
-//		synchronized(getUiDocument().getDomSynchronizationObject()){
-//			getElement().removeStructureChangeListener(this);
-//			getElement().removeChildAt(index);
-//			getElement().insertChildAt(index,value);
-//			getElement().addStructureChangeListener(this);
-//		}
-//	}
-//	
-//
-//	
+
+/**
+ * Sets the text of the first child node if it is a text node.
+ * If there is no node at all it adds one.
+ * If there already is a child and it isn't a text node
+ * we just abort.
+ */
+xap.taghandling.AbstractTagImpl.prototype.writeBackTextNode = function( value ) {
+	var element = this.getElement();
+	element.removeStructureChangeListener(this);
+	var firstChild = element.firstChild;
+	if (!firstChild){
+		element.appendChild(xap.xml.dom.Document.createTextNode(value));	
+	}
+	else if (firstChild.nodeType==google.DOM_TEXT_NODE){
+		firstChild.nodeValue = value;
+	}
+	element.addStructureChangeListener(this);
+}
+
 /**
  * This method can be used to write values back into the document.
  * For example, if a user enters text into a textField and we want the 



Mime
View raw message