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 2006/08/31 18:23:37 UTC

svn commit: r439000 - in /incubator/xap/trunk/src/xap: bridges/basic/ bridges/dojo/ components/dojo/ session/ taghandling/ xml/dom/ xml/xmodify/

Author: jmargaris
Date: Thu Aug 31 11:23:36 2006
New Revision: 439000

URL: http://svn.apache.org/viewvc?rev=439000&view=rev
Log:
More layout stuff, bug fixes for ID lookups, tail recursion
now toggleable

Added:
    incubator/xap/trunk/src/xap/bridges/dojo/BorderPanelBridge.js   (with props)
    incubator/xap/trunk/src/xap/components/dojo/BorderPanel.js   (with props)
Modified:
    incubator/xap/trunk/src/xap/bridges/basic/AbstractBlackBoxWidgetBridge.js
    incubator/xap/trunk/src/xap/bridges/dojo/DojoWidgetBridge.js
    incubator/xap/trunk/src/xap/bridges/dojo/HorizontalPanelBridge.js
    incubator/xap/trunk/src/xap/bridges/dojo/VerticalPanelBridge.js
    incubator/xap/trunk/src/xap/components/dojo/HorizontalPanel.js
    incubator/xap/trunk/src/xap/components/dojo/VerticalPanel.js
    incubator/xap/trunk/src/xap/session/ClientSession.js
    incubator/xap/trunk/src/xap/session/DeclarativeArgumentParser.js
    incubator/xap/trunk/src/xap/taghandling/AbstractTagImpl.js
    incubator/xap/trunk/src/xap/taghandling/plugin.xml
    incubator/xap/trunk/src/xap/xml/dom/Document.js
    incubator/xap/trunk/src/xap/xml/dom/XapElement.js
    incubator/xap/trunk/src/xap/xml/xmodify/CommandDirective.js

Modified: incubator/xap/trunk/src/xap/bridges/basic/AbstractBlackBoxWidgetBridge.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/bridges/basic/AbstractBlackBoxWidgetBridge.js?rev=439000&r1=438999&r2=439000&view=diff
==============================================================================
--- incubator/xap/trunk/src/xap/bridges/basic/AbstractBlackBoxWidgetBridge.js (original)
+++ incubator/xap/trunk/src/xap/bridges/basic/AbstractBlackBoxWidgetBridge.js Thu Aug 31 11:23:36 2006
@@ -196,59 +196,7 @@
 	// constructor, via a database call, using a JSON-encoded object over the fibre,
 	// or stolen from a fruit-cart:
 	this.obtainPeer() ;
-
-	var parent = this.getElement().getParent();
-	var parentHandler = this.getUiContentHandler().getHandlerForElement( parent );
-	
-	var parentPeer = parentHandler.getPeer();
-
-	var parentPeerDomNode = null ;
-
-	if ( parentHandler.getNodeForChildren ){
-		if (!parentHandler.getNodeForChildren()){
-			throw new xap.util.Exception(
-						"Problem inserting component managed by "
-						+ this.toString()
-						+ " into a container managed by " 
-						+ parentHandler.toString()
-						+ "; parent doesn't have a suitable container."
-											) ;
-			return ;
-		}	
-		// The parent is another bridge
-		// Get the display node associated with the bridge's parent, since this represents the 
-		// place in the HTML DOM	
-		parentPeerDomNode = parentHandler.getNodeForChildren() ;
-	}  else if (parentPeer.innerHTML){
-		// This is already an HTML element or equivalent:
-		// (Is there a better way of telling an HTML element?)
-		// TO_DO:  make sure that we can remove this option---bridges
-		// should see only other bridges' components only through methods.
-		// As it stands, if the parent's handler is an AbstractBlackBoxWidgetBridge
-		// or subclass, it will have a getNodeForChildren method, and we 
-		// won't get here....
-		parentPeerDomNode = parentPeer ;
-	} else {
-		throw new xap.util.Exception("Parent must either be a XapElement or a bridge.") ;
-	}
-	 
-	// TODO: is there a better, generic, way
-	// of describing an element that contains
-	// a widget---maybe anything that can call appendChild?
-	if ( ! parentPeerDomNode.tagName.match(/(DIV|BODY|TD)/)){
-		xap.bridges.basic.AbstractBlackBoxWidgetBridge.s_log.error("Bogus parent peer:" + parentPeer );
-	} else  {			   
-		// A bit of contractual programming---make sure this is a bridge of the sort we can use:
-		if(!this._peer){
-			throw new xap.util.Exception("Haven't obtained a source object to manage.") ;
-		}
-
-		// Connects (and if necessary, creates) the bridge events mirroring the peer's.
-		this.autoAttachBridgeEventsToPeerEvents() ;
-
-		// Finds and sets the peer's location in the HTML DOM:
-		this.setHtmlDomLocation(parentPeerDomNode) ;
-	} 
+	this.autoAttachBridgeEventsToPeerEvents() ;
 }
 
 /**
@@ -298,6 +246,39 @@
 	return function(){
 				return this.fireEvent(str) ;
 		 	} ;
+}
+
+xap.bridges.basic.AbstractBlackBoxWidgetBridge.prototype.onChildAdded = function( e ) {
+	var childElement = e.getChange();
+	var childHandler = this.getUiContentHandler().getHandlerForElement( childElement );
+	this.addChild(childHandler, e.getIndex());
+}
+
+xap.bridges.basic.AbstractBlackBoxWidgetBridge.prototype.onChildRemoved = function (e) {
+   var childElement = e.getChange();
+	var childHandler = this.getUiContentHandler().getHandlerForElement( childElement );
+	this.removeChild(childHandler);
+	xap.taghandling.AbstractTagImpl.prototype.onChildRemoved.call( this, e );
+}
+
+xap.bridges.basic.AbstractBlackBoxWidgetBridge.prototype.addChild = function(childHandler, index){
+	if (this.getNodeForChildren && this.getNodeForChildren()){
+		this.getNodeForChildren().appendChild(childHandler.getRootDomNode());
+	}
+	else{
+		throw new xap.util.Exception(
+			"Problem inserting component managed by "
+			+ childHandler.toString()
+			+ " into a container managed by " 
+			+ this.toString()
+			+ "; parent doesn't have a suitable container.") ;
+	}
+}
+
+xap.bridges.basic.AbstractBlackBoxWidgetBridge.prototype.removeChild = function(childHandler, index){
+	if (this.getNodeForChildren && this.getNodeForChildren()){
+		this.getNodeForChildren().removeChild(childHandler.getRootDomNode());
+	}
 }
 
 

Added: incubator/xap/trunk/src/xap/bridges/dojo/BorderPanelBridge.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/bridges/dojo/BorderPanelBridge.js?rev=439000&view=auto
==============================================================================
--- incubator/xap/trunk/src/xap/bridges/dojo/BorderPanelBridge.js (added)
+++ incubator/xap/trunk/src/xap/bridges/dojo/BorderPanelBridge.js Thu Aug 31 11:23:36 2006
@@ -0,0 +1,90 @@
+/*
+ * Copyright  2006 The Apache Software Foundation.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+ 
+ /**
+ * @fileoverview
+ * 
+ * A bridge class that controls a dojo BorderPanel peer.
+ */
+
+Xap.provide("xap.bridges.dojo.BorderPanelBridge"); 
+
+Xap.require("xap.bridges.dojo.DojoWidgetBridge");
+Xap.require("xap.components.dojo.BorderPanel"); 
+
+
+ 
+ /**
+ * @fileoverview
+ * 
+ * A bridge class with dojo toolkit box panel peer.
+ */
+ 
+xap.bridges.dojo.BorderPanelBridge= function() {
+	xap.bridges.dojo.DojoWidgetBridge.call(this);
+}
+
+
+Xap.setupClassAsSubclassOf(
+				"xap.bridges.dojo.BorderPanelBridge",
+				"xap.bridges.dojo.DojoWidgetBridge"						
+);
+
+
+
+xap.bridges.dojo.BorderPanelBridge.prototype.getPeerString = function(){
+    return "BorderPanel" ;
+}
+
+
+/** XML attribute set method for "width" */
+xap.bridges.dojo.BorderPanelBridge.prototype.setWidthAttribute = function(value){
+	this.getRootDomNode().style.width = value ;
+	this.getPeer().onResized();
+}
+
+/** XML attribute set method for "height" */
+xap.bridges.dojo.BorderPanelBridge.prototype.setHeightAttribute = function(value){
+	this.getRootDomNode().style.height = value ;
+	this.getPeer().onResized();
+}
+
+xap.bridges.dojo.BorderPanelBridge.prototype.addChild = function( childHandler ){
+	var element = childHandler.getElement();
+	var borderPosition = element.getAttribute("borderPosition");
+	this.getPeer().addChild(childHandler.getPeer(),borderPosition);
+}
+
+
+
+ 
+/**
+ * 
+ * 
+ * Attribute definitions
+ * 
+ */ 
+ 
+ 
+/**
+ * No new dynamic attributes
+ */
+xap.bridges.dojo.BorderPanelBridge.prototype.getNewAllowedAttributes = function(){
+	return [];
+}	
+
+

Propchange: incubator/xap/trunk/src/xap/bridges/dojo/BorderPanelBridge.js
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/xap/trunk/src/xap/bridges/dojo/DojoWidgetBridge.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/bridges/dojo/DojoWidgetBridge.js?rev=439000&r1=438999&r2=439000&view=diff
==============================================================================
--- incubator/xap/trunk/src/xap/bridges/dojo/DojoWidgetBridge.js (original)
+++ incubator/xap/trunk/src/xap/bridges/dojo/DojoWidgetBridge.js Thu Aug 31 11:23:36 2006
@@ -78,7 +78,7 @@
  * We get the string Dojo will use to locate the widget to create from 
  * the subclass' <code>this.getPeerString()</code>. 
  */
-xap.bridges.dojo.DojoWidgetBridge.prototype.createPeer = function() {
+xap.bridges.dojo.DojoWidgetBridge.prototype.obtainPeer = function() {
         
    		// These properties of the map might be overwritten by a passed-in map:
    		// (by default, widget i.d. === xap i.d.)
@@ -108,70 +108,60 @@
 		if (dojoType == null ){
 			throw new xap.util.Exception("No dojo type specified by class or passed-in map.") ;		
 		}	
+		
+		//we need to do this because DOJO sort of expects to be replacing
+		//the div and if you don't pass in anything to replace it can
+		//get messed up for examle splitContainer is created with
+		//a span for the root instead of a div
+		var tmp = document.createElement('div');
+		var tmp2 = document.createElement('div');
+		tmp2.appendChild(tmp);
+		var peer = dojo.widget.createWidget(dojoType,propertyMap,tmp); 
+		this.setPeer(peer ) ;
+}
 
 
-
-		var parent = this.getElement().getParent();
-		var parentHandler = this.getUiContentHandler().getHandlerForElement( parent );
-		var parentPeerNode = null ;
-		var parentPeer = parentHandler.getPeer();
-		
-		var htmlContainerNode = this.getSpecifiedDisplayNode();
-		
-		
-		//basic strategy:
-		//if the parent is a dojo widget, add to the parent using the addChild
-		//method. If the parent is not a dojo widget, just add to it's container
-		//HTML node
-		
-		//if there is no addChild, do something else
-		//TODO if they specifcy container node should that override something?
-		if (!parentPeer.addChild){
-			//if they didn't specify a target, use the parent's target
-			if (!htmlContainerNode){
-				if (parentHandler.getNodeForChildren){
-					htmlContainerNode = parentHandler.getNodeForChildren();
-				}
-			}
-			
-			//if there still is no target there is nothing we can do
-			if (!htmlContainerNode){
-				throw new xap.util.Exception(
-					"Problem inserting component managed by "
-					+ this.toString()
-					+ " into a container managed by " 
-					+ parentHandler.toString()
-					+ "; parent doesn't have a suitable container.") ;
-			}
-			var tmp = document.createElement('div');
-	    
-			// Will setting the dimensions of the original div help us size the 
-			// eventual Dojo widget?
-			//IMPORTANT put back in if needed?
-//			for( var fieldName in this._creationProperties ){
-//				if( !tmp.style[fieldName]){
-//					tmp.style[fieldName] = this._creationProperties[fieldName] ; 
-//				}
-//			}
-			tmp.parent = htmlContainerNode ;
-	    	htmlContainerNode.appendChild(tmp) ;
-	    	var peer = dojo.widget.createWidget(dojoType,propertyMap, tmp); 
-	    	this.setPeer(peer ) ;	
-	    	this.autoAttachBridgeEventsToPeerEvents() ;	  	 
-		}
-		
-		//TODO checking for addChild isn't really enough, that
-		//doesn't really mean it is a dojo widget
-		else{
-			var peer = dojo.widget.createWidget(dojoType,propertyMap); 
-			parentHandler.getPeer().addChild(peer);
-			this.setPeer(peer ) ;
-			this.autoAttachBridgeEventsToPeerEvents() ;
-			
+//TODO this is never used right now, do we really
+//want this functionality or what?
+xap.bridges.dojo.DojoWidgetBridge.prototype.addPeerToParent = function(){
+	var parent = this.getElement().getParent();
+	var parentHandler = this.getUiContentHandler().getHandlerForElement( parent );
+	var parentPeerNode = null ;
+	var parentPeer = parentHandler.getPeer();
+		
+	var htmlContainerNode = this.getSpecifiedDisplayNode();
+		
+	if (htmlContainerNode){
+	   htmlContainerNode.appendChild(this.getPeer().getRootDomNode()) ; 	 
+	}
+	else if (parentHandler.addChild){
+		parentHandler.addChild(this);
+	}
+	else{
+		throw new xap.util.Exception(
+				"Problem inserting component managed by "
+				+ this.toString()
+				+ " into a container managed by " 
+				+ parentHandler.toString()
+				+ "; parent doesn't have a suitable container.") ;		
 		}
 }
 
+//IMPORTANT we should really add to the parent AFTER we go through the 
+//intial attributes and children, for efficiency among other reasons
+
+xap.bridges.dojo.DojoWidgetBridge.prototype.addChild = function(childHandler, index){
+	
+	//index -1 just append!
+	var insertIndex = index<0?null:index;
+	//TODO check if it is a dojo widget bridge/peer!!
+	this.getPeer().addChild(childHandler.getPeer(),null,'insertAtIndex',null,insertIndex);
+}
+
 
+xap.bridges.dojo.DojoWidgetBridge.prototype.removeChild = function(childHandler){
+	this.getPeer().removeChild(childHandler.getPeer());
+}
 
 
 /**
@@ -180,13 +170,8 @@
  *  @param propertyMap A JS object holding name/value pairs
  *  @param holder An object holding an array of attribute nodes (in an "attributes" member) 
  *                produced by the parser/handler.
- *  @param trimP  If there and true, trim allowed initial attributes from the 
- *                attributes list so that they're not handled twice.
 **/ 
-
-//IMPORTANT old code that may or may not be useful, keep for now
-//tried to set properties initially to help dojo widgets size better
-xap.bridges.dojo.DojoWidgetBridge.prototype.mapAllowedInitialPropertiesFromXalToDojo = function(propertyMap,attrHolder,trimP){
+xap.bridges.dojo.DojoWidgetBridge.prototype.mapAllowedInitialPropertiesFromXalToDojo = function(propertyMap,attrHolder){
 	var arrAttributes = attrHolder.attributes
 	// if trimP, all attributes we handle here will be
 	// removed from the list--easisest to just start a new list from scratch
@@ -216,16 +201,8 @@
 				
 				propertyMap[name] = value ;			
 			} 
-			else if (trimP){
-				postInitAttributes.push( arrAttributes[ii] ) ;
-			}  		
    		} // end iteration over attributes
    	} // end gate over attributes' existing in the first place
-
-   	// If we want to trim the list of the attributes we've added to the property map:
-   	if( trimP ){
-   		attrHolder.attributes = postInitAttributes ;
-   	}
 }
 
 

Modified: incubator/xap/trunk/src/xap/bridges/dojo/HorizontalPanelBridge.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/bridges/dojo/HorizontalPanelBridge.js?rev=439000&r1=438999&r2=439000&view=diff
==============================================================================
--- incubator/xap/trunk/src/xap/bridges/dojo/HorizontalPanelBridge.js (original)
+++ incubator/xap/trunk/src/xap/bridges/dojo/HorizontalPanelBridge.js Thu Aug 31 11:23:36 2006
@@ -73,12 +73,17 @@
  * 
  */ 
  
- 
-/**
- * No new dynamic attributes
- */
 xap.bridges.dojo.HorizontalPanelBridge.prototype.getNewAllowedAttributes = function(){
-	return [];
+	return ["align","pack"];
 }	
 
+/** XML attribute set method for "align" */
+xap.bridges.dojo.HorizontalPanelBridge.prototype.setAlignAttribute = function(value){
+	this.getPeer().setAlign(value);
+}
+
+/** XML attribute set method for "align" */
+xap.bridges.dojo.HorizontalPanelBridge.prototype.setPackAttribute = function(value){
+	this.getPeer().setPack(value);
+}
 

Modified: incubator/xap/trunk/src/xap/bridges/dojo/VerticalPanelBridge.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/bridges/dojo/VerticalPanelBridge.js?rev=439000&r1=438999&r2=439000&view=diff
==============================================================================
--- incubator/xap/trunk/src/xap/bridges/dojo/VerticalPanelBridge.js (original)
+++ incubator/xap/trunk/src/xap/bridges/dojo/VerticalPanelBridge.js Thu Aug 31 11:23:36 2006
@@ -74,11 +74,20 @@
  */ 
  
  
-/**
- * No new dynamic attributes
- */
 xap.bridges.dojo.VerticalPanelBridge.prototype.getNewAllowedAttributes = function(){
-	return [];
+	return ["align","pack"];
 }	
+
+/** XML attribute set method for "align" */
+xap.bridges.dojo.VerticalPanelBridge.prototype.setAlignAttribute = function(value){
+	this.getPeer().setAlign(value);
+}
+
+/** XML attribute set method for "align" */
+xap.bridges.dojo.VerticalPanelBridge.prototype.setPackAttribute = function(value){
+	this.getPeer().setPack(value);
+}
+
+
 
 

Added: incubator/xap/trunk/src/xap/components/dojo/BorderPanel.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/components/dojo/BorderPanel.js?rev=439000&view=auto
==============================================================================
--- incubator/xap/trunk/src/xap/components/dojo/BorderPanel.js (added)
+++ incubator/xap/trunk/src/xap/components/dojo/BorderPanel.js Thu Aug 31 11:23:36 2006
@@ -0,0 +1,56 @@
+//IMPORTANT move this to some shared area
+dojo.widget.manager.registerWidgetPackage("xap.components.dojo");
+
+Xap.provide("xap.components.dojo.VerticalPanel");
+
+dojo.require("dojo.widget.*");
+dojo.require("dojo.widget.HtmlWidget");
+dojo.require("dojo.dom");
+dojo.require("dojo.html");
+dojo.require("dojo.style");
+dojo.require("dojo.event");
+
+dojo.widget.tags.addParseTreeHandler("dojo:BorderPanel");
+
+xap.components.dojo.BorderPanel = function(){
+	dojo.widget.HtmlWidget.call(this);
+}
+
+dojo.inherits(xap.components.dojo.BorderPanel,dojo.widget.HtmlWidget);
+
+dojo.lang.extend(xap.components.dojo.BorderPanel, {
+	templateString: '<table><tr align="center" valign="center">'+
+	'<td colspan="3" dojoAttachPoint="north"></td></tr>' +
+	'<tr align="center" valign="center" style="height:70%">'+
+	'<td dojoAttachPoint="west"></td><td style="width:70%" dojoAttachPoint="center"></td><td dojoAttachPoint="east"></td></tr>' +
+	'<tr align="center" valign="center"><td colspan="3" dojoAttachPoint="south"></tr></td></table>',
+	
+	templateCssPath: null ,
+	widgetType: "BorderPanel",
+	isContainer: true,
+	
+	addChild: function(child, position){
+		if (position=="north"){
+			this.containerNode = this.north;
+		}
+		else if (position=="south"){
+			this.containerNode = this.south;
+		}
+		else if (position=="east"){
+			this.containerNode = this.east;
+		}
+		else if (position=="west"){
+			this.containerNode = this.west;
+		}
+		else{
+			this.containerNode = this.center;
+		}
+		child.domNode.style.width="100%";
+		child.domNode.style.height="100%";
+		
+		xap.components.dojo.BorderPanel.superclass.addChild.call(this,child);
+	}
+}
+);
+
+

Propchange: incubator/xap/trunk/src/xap/components/dojo/BorderPanel.js
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/xap/trunk/src/xap/components/dojo/HorizontalPanel.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/components/dojo/HorizontalPanel.js?rev=439000&r1=438999&r2=439000&view=diff
==============================================================================
--- incubator/xap/trunk/src/xap/components/dojo/HorizontalPanel.js (original)
+++ incubator/xap/trunk/src/xap/components/dojo/HorizontalPanel.js Thu Aug 31 11:23:36 2006
@@ -18,15 +18,39 @@
 dojo.inherits(xap.components.dojo.HorizontalPanel, dojo.widget.HtmlWidget);
 
 dojo.lang.extend(xap.components.dojo.HorizontalPanel, {
-	templateString: '<table cellPadding="0" cellSpacing="0"><tbody><tr></tr></tbody></table>',
+	templateString: '<table cellPadding="0" cellSpacing="0"><tbody><tr><td dojoAttachPoint="startCell"></td>'
+	+'<td dojoAttachPoint="endCell" style="width:99%"></td></tr></tbody></table>',
 	templateCssPath: null ,
 	widgetType: "HorizontalPanel",
 	isContainer: true,
+	align : "start",
 	
 	addChild: function(child, overrideContainerNode, pos, ref, insertIndex){
-		var row = this.domNode.childNodes[0].childNodes[0];
+		var row = this.endCell.parentNode;
 		var cell = document.createElement("td");
-		row.appendChild(cell);
+		
+		
+		if (this.align=="center"){
+			cell.setAttribute("valign", "center");
+		}
+		else if (this.align=="start"){
+			cell.setAttribute("valign", "top");
+		}
+		else if (this.align=="end"){
+			cell.setAttribute("valign", "bottom");
+		}
+		else if (this.align=="stretch"){
+			child.domNode.style.height="100%";
+		}
+		
+		//if we are inserting in the middle, insert before some row
+		//bumped up one to account for the start spacer row
+		if (insertIndex && insertIndex>=0 && insertIndex<row.childNodes.length-2){
+			row.insertBefore(cell,row.childNodes[insertIndex+1]);
+		}
+		else{
+			row.insertBefore(cell, this.endCell);
+		}
 		this.containerNode = cell;
 		xap.components.dojo.HorizontalPanel.superclass.addChild.call(this,child, overrideContainerNode, pos, ref, insertIndex);
 	},
@@ -39,6 +63,25 @@
 		xap.components.dojo.HorizontalPanel.superclass.removeChild.call(this,child);
 		containerCell.parentNode.removeChild(containerCell);
     },
+    
+	setAlign: function(align){
+    	this.align = align;
+    },
+    
+    setPack: function(pack){
+    	if (pack=="start"){
+    		this.startCell.style.width="0%";
+    		this.endCell.style.width="99%";
+    	}
+    	else if (pack=="end"){
+    		this.startCell.style.width="99%";
+    		this.endCell.style.width="0%";
+    	}
+   	else if (pack=="center"){
+   		this.startCell.style.width="50%";
+    		this.endCell.style.width="50%";
+   	}
+    }
 }
 );
 

Modified: incubator/xap/trunk/src/xap/components/dojo/VerticalPanel.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/components/dojo/VerticalPanel.js?rev=439000&r1=438999&r2=439000&view=diff
==============================================================================
--- incubator/xap/trunk/src/xap/components/dojo/VerticalPanel.js (original)
+++ incubator/xap/trunk/src/xap/components/dojo/VerticalPanel.js Thu Aug 31 11:23:36 2006
@@ -18,18 +18,50 @@
 dojo.inherits(xap.components.dojo.VerticalPanel, dojo.widget.HtmlWidget);
 
 dojo.lang.extend(xap.components.dojo.VerticalPanel, {
-	templateString: '<table cellPadding="0" cellSpacing="0"><tbody></tbody></table>',
+	templateString: '<table cellPadding="0" cellSpacing="0"><tbody dojoAttachPoint="tbody">' +
+	'<tr dojoAttachPoint="startRow"><td></td></tr>'
+	+'<tr dojoAttachPoint="endRow" style="height:99%"><td></td></tr></tbody></table>',
 	templateCssPath: null ,
 	widgetType: "VerticalPanel",
 	isContainer: true,
+	align: "center", //start, center, end, stretch
 	
 	addChild: function(child, overrideContainerNode, pos, ref, insertIndex){
+		//TODO if they have something like height=50%
+		//we should set that on the table cell?
 		var row = document.createElement("tr");
 		var cell = document.createElement("td");
+		if (this.align=="center"){
+			cell.setAttribute("align", "center");
+		}
+		else if (this.align=="start"){
+			cell.setAttribute("align", "left");
+		}
+		else if (this.align=="end"){
+			cell.setAttribute("align", "right");
+		}
+		
+		//if they set the width again after this it won't really work
+		//TODO this can happen now when they have width=x because
+		//of the order of operations we add the child to the parent
+		//BEFORE we go through the initial attributes
+		else if (this.align=="stretch"){
+			child.domNode.style.width="100%";
+		}
 		row.appendChild(cell);
-		this.domNode.childNodes[0].appendChild(row);
+		
+		var tBody = this.tbody;
+		
+		//if we are inserting in the middle, insert before some row
+		//bumped up one to account for the start spacer row
+		if (insertIndex && insertIndex>=0 && insertIndex<tBody.childNodes.length-2){
+			tBody.insertBefore(row,tBody.childNodes[insertIndex+1]);
+		}
+		else{
+			tBody.insertBefore(row, this.endRow);
+		}
 		this.containerNode = cell;
-		xap.components.dojo.VerticalPanel.superclass.addChild.call(this,child, overrideContainerNode, pos, ref, insertIndex);
+		xap.components.dojo.VerticalPanel.superclass.addChild.call(this,child, overrideContainerNode, pos, ref, 0);
 	},
 	
 	 removeChild: function(child) {
@@ -40,6 +72,25 @@
 		xap.components.dojo.VerticalPanel.superclass.removeChild.call(this,child);
 		containerRow.parentNode.removeChild(containerRow);
     },
+    
+    setAlign: function(align){
+    	this.align = align;
+    },
+    
+    setPack: function(pack){
+    	if (pack=="start"){
+    		this.startRow.style.height="0%";
+    		this.endRow.style.height="99%";
+    	}
+    	else if (pack=="end"){
+    		this.startRow.style.height="99%";
+    		this.endRow.style.height="0%";
+    	}
+   	else if (pack=="center"){
+   		this.startRow.style.height="50%";
+    		this.endRow.style.height="50%";
+   	}
+    }
 }
 );
 

Modified: incubator/xap/trunk/src/xap/session/ClientSession.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/session/ClientSession.js?rev=439000&r1=438999&r2=439000&view=diff
==============================================================================
--- incubator/xap/trunk/src/xap/session/ClientSession.js (original)
+++ incubator/xap/trunk/src/xap/session/ClientSession.js Thu Aug 31 11:23:36 2006
@@ -286,9 +286,20 @@
 // if zimbroid, it will have to be found some other way Zimbra will handle:
 	if( toolkitType && toolkitType=="dojo"){
 		parentElementWrapper = parentElement!=null? parentElement : document.body ;
+		
 		handler.getNodeForChildren = function(){
 			return parentElement ;
 		}
+		
+		handler.onChildAdded = function( e ) {
+			var childElement = e.getChange();
+			var childHandler = this.getUiContentHandler().getHandlerForElement( childElement );
+			this.addChild(childHandler, e.getIndex());
+		}		
+
+		handler.addChild = function(child, index){
+			this.getNodeForChildren().appendChild(child.getRootDomNode());
+		}
 	} else {
 		parentElementWrapper = new DwtShell( "MainShell", false, null, null, true );
 		handler.getNodeForChildren = function(){
@@ -307,5 +318,6 @@
 	
 	//have the parentElementWrapper be the peer of the xap.taghandling.AbstractTagImpl
 	handler.setPeer( parentElementWrapper );
+	uiDocument.getRootElement().addStructureChangeListener( handler );
 }
 

Modified: incubator/xap/trunk/src/xap/session/DeclarativeArgumentParser.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/session/DeclarativeArgumentParser.js?rev=439000&r1=438999&r2=439000&view=diff
==============================================================================
--- incubator/xap/trunk/src/xap/session/DeclarativeArgumentParser.js (original)
+++ incubator/xap/trunk/src/xap/session/DeclarativeArgumentParser.js Thu Aug 31 11:23:36 2006
@@ -374,13 +374,13 @@
 		var containerName = arg.substring(0,index);
 		var mcoName = arg.substring(index+1);
 		var container = this._session.getContainer(containerName);
-		if (container==null){
+		if (!container){
 			//TODO
 			throw new xap.util.Exception("No container with name: " + containerName);
 		}
 		
 		var bean = container.get(mcoName);
-	  	if (bean==null){
+	  	if (!bean){
 	  		//TODO
 			throw new xap.util.Exception("No bean with name: " + mcoName);
 	  	}
@@ -421,20 +421,20 @@
 
 		
    		var element = this._session.getDocumentContainer().getUiDocument().getElementById(elementName);
-   		if (element==null && elementName=="this"){
+   		if (!element && elementName=="this"){
 	   		element = thisElement;
    		}
    		
-   		xap.session.DeclarativeArgumentParser.s_log.debug("FOund element: " + element);
+   		xap.session.DeclarativeArgumentParser.s_log.debug("Found element: " + element);
                              	
-   		if (element!=null){
-	   		if (elementAttribute==null) return element;
+   		if (element){
+	   		if (!elementAttribute) return element;
    		
 	   
-			var attributeValue = element.getAttribute(elementAttribute);
-			xap.session.DeclarativeArgumentParser.s_log.debug("FOund attribute: " + attributeValue);
-			if (attributeValue==null) attributeValue = ""; 
-			return attributeValue;
+				var attributeValue = element.getAttribute(elementAttribute);
+				xap.session.DeclarativeArgumentParser.s_log.debug("FOund attribute: " + attributeValue);
+				if (!attributeValue) attributeValue = ""; 
+				return attributeValue;
 			
    		}
 	}

Modified: incubator/xap/trunk/src/xap/taghandling/AbstractTagImpl.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/taghandling/AbstractTagImpl.js?rev=439000&r1=438999&r2=439000&view=diff
==============================================================================
--- incubator/xap/trunk/src/xap/taghandling/AbstractTagImpl.js (original)
+++ incubator/xap/trunk/src/xap/taghandling/AbstractTagImpl.js Thu Aug 31 11:23:36 2006
@@ -92,6 +92,14 @@
 	this._clientSession = null;
 }
 
+
+//what is this? TAIL_RECURSION true means we build the entire
+//thing from tail to head, and when we attach the head to the existing
+//document the entire trail is in place. That should be more efficient
+//in many cases but it has some issues: dojo widgets don't size well
+//and the user won't see anything on screen until the very end
+xap.taghandling.AbstractTagImpl.TAIL_RECURSION = false;
+
 //-----------------------------------------------------------------------
 // Public Methods.
 //-----------------------------------------------------------------------
@@ -214,6 +222,20 @@
  * @param e The element to parse the initial children of.
  */	
 xap.taghandling.AbstractTagImpl.prototype.parseInitialChildren = function( e ) {
+	
+	//if we aren't using tail recursion add ourselved to parent BEFORE
+	//we go through all our children
+	if (!xap.taghandling.AbstractTagImpl.TAIL_RECURSION){
+		var parentElement = this.getElement().parentNode;
+		var parentHandler = this.getUiContentHandler().getHandlerForElement( parentElement );
+	
+		var event = new xap.xml.dom.events.StructureChangeEvent( e, this.getElement(), -1 );
+		parentHandler.beforeChildAdded( event );
+		parentHandler.onChildAdded( event );
+	}
+		
+	
+	
 	var session = this.getSession();
 	var contentHandler = session.getUiDocumentHandler();
 	
@@ -227,36 +249,41 @@
 		var child = children[i];
 		if ( child.nodeType==google.DOM_ELEMENT_NODE ) {
 			contentHandler.parseChild( child );
+			
+			if (xap.taghandling.AbstractTagImpl.TAIL_RECURSION){
 		
-			//-1 index means an append, even though we already have
-			//all the child elements we want to pretend we are adding
-			//them right now, so just fire off each one as if it was appended
-			var event = new xap.xml.dom.events.StructureChangeEvent( e, child, -1 );
-			this.beforeChildAdded( event );
-			this.onChildAdded( event );
+				//-1 index means an append, even though we already have
+				//all the child elements we want to pretend we are adding
+				//them right now, so just fire off each one as if it was appended
+				var event = new xap.xml.dom.events.StructureChangeEvent( e, child, -1 );
+				this.beforeChildAdded( event );
+				this.onChildAdded( event );
+			}
 		}
 		if ( child.nodeType==google.DOM_TEXT_NODE ) {
-			//TODO this needs some work in that they are supposed to be able
-			//to CHANGE the text in the beforeChildAdded and that is supposed to
-			//be what we actually add. This can happen with databinding syntax
-			//where the text is replaced with filled-in values. What we really
-			//need to do here is fire the before, then if the new value is different
-			//from the old actually REPLACE the old text value with the new one.
-			//for reference the old code looked like:
-			// writeBackRemoveChild(i);
-			//	e.insertChildAt(i,(String)o);
-			//This worked but was somewhat inneficient in that it always removed
-			//and re-added the text node. Perhaps in this case what we should do
-			//is instead of actually change the text node just change the VALUE
-			//of the text node instead. So if we see a text node with data binding like:
-			// <button>{ someOtherButton.text }</button>
-			//we replace the someOtherButton.text with the resolved value by changing
-			//the value of the text node while keeping the same text node overall.
 			
-			var event = new xap.xml.dom.events.StructureChangeEvent( e, child, -1 );
-			this.beforeChildAdded( event );
-			this.onChildAdded( event );
-		
+			if (xap.taghandling.AbstractTagImpl.TAIL_RECURSION){
+				//TODO this needs some work in that they are supposed to be able
+				//to CHANGE the text in the beforeChildAdded and that is supposed to
+				//be what we actually add. This can happen with databinding syntax
+				//where the text is replaced with filled-in values. What we really
+				//need to do here is fire the before, then if the new value is different
+				//from the old actually REPLACE the old text value with the new one.
+				//for reference the old code looked like:
+				// writeBackRemoveChild(i);
+				//	e.insertChildAt(i,(String)o);
+				//This worked but was somewhat inneficient in that it always removed
+				//and re-added the text node. Perhaps in this case what we should do
+				//is instead of actually change the text node just change the VALUE
+				//of the text node instead. So if we see a text node with data binding like:
+				// <button>{ someOtherButton.text }</button>
+				//we replace the someOtherButton.text with the resolved value by changing
+				//the value of the text node while keeping the same text node overall.
+				
+				var event = new xap.xml.dom.events.StructureChangeEvent( e, child, -1 );
+				this.beforeChildAdded( event );
+				this.onChildAdded( event );
+			}
 		}
 	}
 }

Modified: incubator/xap/trunk/src/xap/taghandling/plugin.xml
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/taghandling/plugin.xml?rev=439000&r1=438999&r2=439000&view=diff
==============================================================================
--- incubator/xap/trunk/src/xap/taghandling/plugin.xml (original)
+++ incubator/xap/trunk/src/xap/taghandling/plugin.xml Thu Aug 31 11:23:36 2006
@@ -33,6 +33,7 @@
 		<mapping class="xap.bridges.dojo.FreePanelBridge" name="freePanel"/>	
 		<mapping class="xap.bridges.dojo.VerticalPanelBridge" name="verticalPanel"/>	
 		<mapping class="xap.bridges.dojo.HorizontalPanelBridge" name="horizontalPanel"/>	
+		<mapping class="xap.bridges.dojo.BorderPanelBridge" name="borderPanel"/>	
 				
 		<mapping class="xap.bridges.basic.DomNodeBridge" name="dom"/>
 		<mapping class="xap.bridges.dojo.DojoDatePickerBridge" name="datePicker"/>

Modified: incubator/xap/trunk/src/xap/xml/dom/Document.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/xml/dom/Document.js?rev=439000&r1=438999&r2=439000&view=diff
==============================================================================
--- incubator/xap/trunk/src/xap/xml/dom/Document.js (original)
+++ incubator/xap/trunk/src/xap/xml/dom/Document.js Thu Aug 31 11:23:36 2006
@@ -66,11 +66,11 @@
     this._rootElement = rootElement;
     this._documentEncoding = null;
     
-    this._structureChangeListeners = new Array(); 
-    this._attributeChangeListeners = new Array(); 
+    this._structureChangeListeners = [];
+    this._attributeChangeListeners = [];
     
-    this._idToElementMap = new Object();
-    this._prefixToNamespaceMap = new Object();
+    this._idToElementMap = {};
+    this._prefixToNamespaceMap = {};
     this._uidProvider = new xap.util.UidProvider();
 }
 
@@ -185,9 +185,6 @@
  * @param id The id attribute value of the xap.xml.dom.XapElement to look up.
  */
 xap.xml.dom.Document.prototype.getElementById = function( id ) {
-	if( this._idToElementMap == null ) {
-		return null;
-	}
 	return this._idToElementMap[id];
 }
 
@@ -343,7 +340,7 @@
  * @private
  */            
 xap.xml.dom.Document.prototype._removeDocumentFragmentFromIdMap = function( e ) {
-	this._idToElementMap[e.getAttribute( "id" )] = null;
+	delete (this._idToElementMap[e.getAttribute( "id" )]);
 	e._notifyListenersOnRemovedFromDocument( this );
 	for( var i=0; i < e.childNodes.length; i++ ) {
 		var o = e.childNodes[i];
@@ -442,10 +439,7 @@
  * @private
  */            
 xap.xml.dom.Document.prototype._addIdToElementMapping = function( id, e ) { 
-	if( this._idToElementMap == null ) {
-		this._idToElementMap = new Object();
-	}
-	if( this._idToElementMap[id] != null ) {
+	if( this._idToElementMap[id] ) {
 		throw new xap.xml.InvalidXmlException(
 				xap.xml.InvalidXmlException.ID_CONFLICT_MSGID, 
 				new Array( id ));

Modified: incubator/xap/trunk/src/xap/xml/dom/XapElement.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/xml/dom/XapElement.js?rev=439000&r1=438999&r2=439000&view=diff
==============================================================================
--- incubator/xap/trunk/src/xap/xml/dom/XapElement.js (original)
+++ incubator/xap/trunk/src/xap/xml/dom/XapElement.js Thu Aug 31 11:23:36 2006
@@ -199,9 +199,7 @@
 	var doc = this.getOwnerDocument();
   
 	//flag that indicates if we are setting the id att
-	var isIdAttribute = false;
 	if( "id" == name ) {
-		isIdAttribute = true;
  		if ( doc != null ) {
  			throw new xap.util.Exception
       		( xap.util.ResourceDictionary.getMessage

Modified: incubator/xap/trunk/src/xap/xml/xmodify/CommandDirective.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/xml/xmodify/CommandDirective.js?rev=439000&r1=438999&r2=439000&view=diff
==============================================================================
--- incubator/xap/trunk/src/xap/xml/xmodify/CommandDirective.js (original)
+++ incubator/xap/trunk/src/xap/xml/xmodify/CommandDirective.js Thu Aug 31 11:23:36 2006
@@ -235,7 +235,7 @@
 		for (var j = 0; j < elemsToAppend.length; j++){
 			try {
                  if (currentNode instanceof google.XNode){
-			        currentNode.appendChild(elemsToAppend[j].deepClone(false)); 
+			        currentNode.appendChild(elemsToAppend[j].deepClone(true)); 
                  } else if (this._bHtmlDocument){
 			        currentNode.appendChild(this.makeNodeHTML(elemsToAppend[j])); 
 			     }
@@ -703,13 +703,13 @@
             var nextOldChild = oldChild.nextSibling ;
             if (true||nextOldChild != null){
                 parent.insertBefore(
-                            newChild.deepClone(false), 
+                            newChild.deepClone(true), 
                             nextOldChild
                                 );
             } else {
                 // If there is no next sibling before which to insert,
                 // we can just append it to the end of the child list:
-                parent.appendChild(newChild.deepClone(false));                
+                parent.appendChild(newChild.deepClone(true));                
             }
         } else if (this._bHtmlDocument){
             var nextOldChild = oldChild.nextSibling ;
@@ -745,7 +745,7 @@
         // Just try it for XNode and descendants so far:
         if (oldChild instanceof google.XNode){
             parent.insertBefore(
-                            newChild.deepClone(false), 
+                            newChild.deepClone(true), 
                             oldChild
                                 );
         } else if (this._bHtmlDocument){
@@ -831,7 +831,7 @@
                                 ) ;
           try {
               parent.insertBefore(
-                         newChild.deepClone(false), 
+                         newChild.deepClone(true), 
                          oldChild
                          );
           } catch (insertionException){
@@ -907,7 +907,7 @@
     for (var ll=0; ll<this._commandTargets.length; ++ll) {
         var toClone = this._commandTargets[ll] ;
         if (toClone.nodeType == google.DOM_ELEMENT_NODE) {
-            var cloned = toClone.deepClone(false) ;
+            var cloned = toClone.deepClone(true) ;
             this._clones[ll] = clone ;
         } else {
             throw new xap.xml.xmodify.XmodifyException(