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 mt...@apache.org on 2006/08/31 21:04:11 UTC

svn commit: r439047 - /incubator/xap/trunk/src/xap/taghandling/AbstractTagImpl.js

Author: mturyn
Date: Thu Aug 31 14:04:11 2006
New Revision: 439047

URL: http://svn.apache.org/viewvc?rev=439047&view=rev
Log:
First, (very) rough draft of namespaced attribute value resolution for xal documents---still only mco's working, and code shared with EventHandler that will need to be broken-out.

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?rev=439047&r1=439046&r2=439047&view=diff
==============================================================================
--- incubator/xap/trunk/src/xap/taghandling/AbstractTagImpl.js (original)
+++ incubator/xap/trunk/src/xap/taghandling/AbstractTagImpl.js Thu Aug 31 14:04:11 2006
@@ -24,6 +24,7 @@
 Xap.require("xap.session.ClientEvent");
 Xap.require("google.*");
 Xap.require("xap.xml.InvalidXmlException");
+Xap.require("xap.session.EventHandler") ;
 
 
 //TODO we need to handle qualifying URLs properly based on the request page again
@@ -637,42 +638,75 @@
 /**
  * @param e The AttributeChangeEvent
  */
-xap.taghandling.AbstractTagImpl.prototype.beforeAttributeRemoved = function( e ) {}
+xap.taghandling.AbstractTagImpl.prototype.beforeAttributeSet = function(/*AttributeChangeEvent*/ e){	
 
-/**
- * @param e The AttributeChangeEvent
- */	
-xap.taghandling.AbstractTagImpl.prototype.beforeAttributeSet = function( e ) {
-//		ResolutionHandler resolverRegistry = getUiContentHandler().getResolverRegistry();
-//		String attributeName = e.getName();
-//		String attributeValue = e.getNewValue();
-//
-//		try{
-//		    if (resolverRegistry.needsResolving(attributeValue)){
-//		        String newValue = resolverRegistry.resolveAttribute(getElement(),attributeName,attributeValue);
-//				e.setNewValue(newValue);
-//		    }
-//		    else{
-//				e.setNewValue(resolverRegistry.unescapeString(attributeValue));
-//			}   
-//		    
-//		    //now that we handled escaping also handle the fact that the thing
-//		    //can be a url that needs to be qualified
-//		    attributeValue = e.getNewValue();
-//            
-//	        String newAttributeValue = qualifyToFullUrl(attributeName, attributeValue,this);
-//			if ( newAttributeValue != null && !newAttributeValue.equals(attributeValue)){
-//				e.setNewValue(newAttributeValue);
-//			}
-//		}
-//		catch(ResolverException ex){
-//			getSession().handleException(ExceptionContext.RESOLVER_ERROR,ex);
-//		}
-//		catch(EscapeSyntaxException ex){
-//			getSession().handleException(ExceptionContext.RESOLVER_ERROR,ex);
-//		}
+	var attributeValue = e.getNewValue() ;
+
+	if ( attributeValue == null 
+			|| attributeValue.length == 0
+				|| attributeValue.charAt(0) != "{"
+					|| attributeValue.charAt(attributeValue.length - 1) != "}"
+			){
+	// There's nothing interesting here....
+		return ;
+	} else {
+		// Work with what's between the {}'s from here on in:
+		attributeValue = attributeValue.substring(1,attributeValue.length - 1) ;
+	}		
+
+
+	// Stealing code from this.fireEvent() and EventHandler.fireEvent():
+	var session = this.getSession() ;
+	var handler = session.getEventHandler() ;
+
+	var eventElement = this.getElement();
+	var clientEvent = new xap.session.ClientEvent( eventElement, this.getSession());	
+	try{
+	// If this works, move this to resolver:
+		if (handler._isObjectEvent(attributeValue)){
+		
+			// This will go to a more complete unescaping method later:
+			attributeValue = attributeValue.replace(/\\{/g,"{") ;
+			attributeValue = attributeValue.replace(/\\}/g,"}") ;
+		
+			//we use parseArgument here because technically an object event is just an argument
+			//as they can be imbedded in other arugments etc
+			var parseResult =
+			session.getDeclarativeArgumentParser().parseArgument(attributeValue,0,eventElement, clientEvent);		
+
+			if( parseResult._resultObject){
+				e.setNewValue(parseResult._resultObject);		
+			}
+					       //= resolverRegistry.resolveAttribute(getElement(),attributeName,attributeValue);
+		}
+// Deal with unescaping later:
+//		else{
+//			e.setNewValue(resolverRegistry.unescapeString(attributeValue));
+//		}   
+		
+		//now that we handled escaping also handle the fact that the thing
+		//can be a url that needs to be qualified
+		//attributeValue = e.getNewValue();
+		
+// Skip implementing URL resolution for now:		
+// var newAttributeValue = this.qualifyToFullUrl(attributeName, attributeValue,this);
+//if ( newAttributeValue != null && !newAttributeValue.equals(attributeValue)){
+//			e.setNewValue(newAttributeValue);
+//}
+	}
+	catch(anException){
+		xap.util.Utils.interrogate(anException,true) ;
+		if(true /*resolverException test?*/){
+			session.handleException(ExceptionContext.RESOLVER_ERROR,anException);
+		} else if (false /*escapeSyntaxException test?*/){
+			session.handleException(ExceptionContext.RESOLVER_ERROR,anException);
+		} else {
+			// TODO: handle unknown exception.
+		}
+	}
 }
 
+
 //	/**
 //	 * Generate a new full url string value if the attribute value
 //	 * can be properly qualified into an http, https, or classpath
@@ -791,4 +825,27 @@
 xap.taghandling.AbstractTagImpl.prototype.setSession = function( session ) {
 	this._clientSession = session;
 }
+
+///**
+// * Returns the PluginDocumentHandler that handles the document
+// * that the element this class bridges belongs to.
+// * 
+// * @return The PluginDocumentHandler.
+// * 
+// * @since 4.5/jRex1.1
+// */
+//xap.taghandling.AbstractTagImpl.prototype.getPluginDocumentHandler = function(){
+//
+//	ownerDocument = this.getElement().getOwnerDocument() ;
+//	/*PluginDocumentHandler */documentHandler 
+//		= (/*(ClientSessionImpl)*/this.getSession()).getPluginHandler(ownerDocument);
+//	if (documentHandler==null){
+//		documentHandler = this.getUiContentHandler();
+//	}
+//	
+//	//IMPORTANT revisit this!
+//	return documentHandler;
+//	
+//}
+