You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xap-commits@incubator.apache.org by jm...@apache.org on 2007/01/22 19:41:21 UTC

svn commit: r498760 - /incubator/xap/trunk/codebase/src/xap/macro/MacroNamespaceHandler.js

Author: jmargaris
Date: Mon Jan 22 11:41:21 2007
New Revision: 498760

URL: http://svn.apache.org/viewvc?view=rev&rev=498760
Log:
Support name attribute in macro.

Modified:
    incubator/xap/trunk/codebase/src/xap/macro/MacroNamespaceHandler.js

Modified: incubator/xap/trunk/codebase/src/xap/macro/MacroNamespaceHandler.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/xap/macro/MacroNamespaceHandler.js?view=diff&rev=498760&r1=498759&r2=498760
==============================================================================
--- incubator/xap/trunk/codebase/src/xap/macro/MacroNamespaceHandler.js (original)
+++ incubator/xap/trunk/codebase/src/xap/macro/MacroNamespaceHandler.js Mon Jan 22 11:41:21 2007
@@ -49,7 +49,7 @@
 }
 
 /**
- * This method is called when an element with the XModify namespace is 
+ * This method is called when an element with the Macro namespace is 
  * encountered.
  * 
  * @param element the element that is namespaced, including all of its 
@@ -59,17 +59,22 @@
  */
 xap.macro.MacroNamespaceHandler.prototype.receiveDispatch = function( element ) {
 	var session = this._session;
-	 var id = element.getAttribute("id");
-	 if ( id == null || 
-		 id == "" ||
-		 xap.xml.dom.XapElement.isGeneratedId( id )) {
-		 session.handleException(
-		 	new xap.xml.InvalidXmlException( 
-		 		xap.xml.InvalidXmlException.MISSING_ATTRIBUTE_MSGID,
-				new Array( "id", element.toXml( true ))));
+	var name = element.getAttribute("name");
+	 if ( name == null || 
+		 name == "" ) {
+		 name = element.getAttribute("id");
+		 // If name wasn't specified try "id" as it worked previously
+		 // due to a bug
+		 if (name == null || name == "" || 
+			xap.xml.dom.XapElement.isGeneratedId( name )) {
+    		 session.handleException(
+    		 	new xap.xml.InvalidXmlException( 
+    		 		xap.xml.InvalidXmlException.MISSING_ATTRIBUTE_MSGID,
+    				new Array( "name", element.toXml( true ))));
+		 }
 	}
 	if (xap.util.LogFactory.s_loggingEnabled)
-		xap.macro.MacroNamespaceHandler.s_log.debug( "Create macro id: ["+ id + 
+		xap.macro.MacroNamespaceHandler.s_log.debug( "Create macro name: ["+ name + 
 									"] from element: [" + element.toXml() + "]");
 	 
 	//TODO we really need to clarify whether or not XAP is a generic wrapping
@@ -81,11 +86,11 @@
 	//output that to info at least.
 	
 	var macroContainer = session.getMacroContainer();
-	if ( macroContainer.get( id ) != null ){
+	if ( macroContainer.get( name ) != null ){
 		xap.macro.MacroNamespaceHandler.s_log.info( "Replacing an existing macro registered" +
-			" with id:" + id + ". Element:" + element.toXml() );
+			" with name:" + name + ". Element:" + element.toXml() );
 	}
-	macroContainer.put( id, macro );
+	macroContainer.put( name, macro );
 }