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/18 02:51:54 UTC

svn commit: r432471 - in /incubator/xap/trunk: WebContent/examples/dojo/datePicker.xal WebContent/examples/dojo/datePickerHandler.js src/xap/bridges/dojo/DojoDatePickerBridge.js

Author: mturyn
Date: Thu Aug 17 19:51:52 2006
New Revision: 432471

URL: http://svn.apache.org/viewvc?rev=432471&view=rev
Log:
Fixed DatePicker.attributeSet, added "formatString" property to peers, added format-string usage in examples. 

Modified:
    incubator/xap/trunk/WebContent/examples/dojo/datePicker.xal
    incubator/xap/trunk/WebContent/examples/dojo/datePickerHandler.js
    incubator/xap/trunk/src/xap/bridges/dojo/DojoDatePickerBridge.js

Modified: incubator/xap/trunk/WebContent/examples/dojo/datePicker.xal
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/WebContent/examples/dojo/datePicker.xal?rev=432471&r1=432470&r2=432471&view=diff
==============================================================================
--- incubator/xap/trunk/WebContent/examples/dojo/datePicker.xal (original)
+++ incubator/xap/trunk/WebContent/examples/dojo/datePicker.xal Thu Aug 17 19:51:52 2006
@@ -14,8 +14,7 @@
 		<datePicker xmlns="http://www.dojotoolkit.org/" 	
 				id="theDatePicker"	
 				displayerId="datePickerDisplayer"
-				height="60px"
-				width="90px"
+				width="300px"
 				x="10px"
 				y="10px"
 				onIncrementDate="javascript:alert('Changed, event \'onIncrementDate\' triggered the DEFAULT code that created this box.')"
@@ -24,6 +23,7 @@
 				onIncrementYear="javascript:alert('Changed, event \'onIncrementYear\' triggered the NON-DEFAULT code that created this box.')"
 				onClick="javascript:alert('Changed, event \'onClick\' triggered the DEFAULT code that created this box.')"
 				onSetDate="mco:handler.onSetDate(event)"
+				formatString="Formatted date:  #yyyy-#MM-#dd."
 		/>	
    	</xm:append> 	  	
 

Modified: incubator/xap/trunk/WebContent/examples/dojo/datePickerHandler.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/WebContent/examples/dojo/datePickerHandler.js?rev=432471&r1=432470&r2=432471&view=diff
==============================================================================
--- incubator/xap/trunk/WebContent/examples/dojo/datePickerHandler.js (original)
+++ incubator/xap/trunk/WebContent/examples/dojo/datePickerHandler.js Thu Aug 17 19:51:52 2006
@@ -16,8 +16,12 @@
 		
 		var dp_0 = clientEvent.session.getUiDocumentHandler().getHandlerForElement(dpEl );	
 	
+		var peer = dp_0.getPeer() ;
+		var date = peer.date ;
+		// Unfortunately, we can't do much with this format string yet
+		var format = peer.getFormatString() ;
 		document.getElementById("displ").innerHTML=
-						"<b>"+dp_0.getPeer().date+"</b>" ;
+						"<b>"+ dojo.date.toString(date,format) +"</b>" ;
 }
 
 

Modified: incubator/xap/trunk/src/xap/bridges/dojo/DojoDatePickerBridge.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/bridges/dojo/DojoDatePickerBridge.js?rev=432471&r1=432470&r2=432471&view=diff
==============================================================================
--- incubator/xap/trunk/src/xap/bridges/dojo/DojoDatePickerBridge.js (original)
+++ incubator/xap/trunk/src/xap/bridges/dojo/DojoDatePickerBridge.js Thu Aug 17 19:51:52 2006
@@ -56,15 +56,57 @@
 }
 
 
-xap.bridges.dojo.DojoDatePickerBridge.prototype.attributeSet = function(){
-	//TO_DO anything useful here?  format-string?
-};
-
 
 xap.bridges.dojo.DojoDatePickerBridge.prototype.getPeerOnCommandEvent = function(){
 	return "onSetDate" ;
 }
 
+
+/**
+ * This method is called whenever an attribute
+ * on the XML element that maps to this bridge class
+ * is changed. 
+ * <ul>
+ * <li>formatString - a string used to format the date into a string
+ * or to parse a string into a Date
+ * </ul>
+ * 
+ * Attributes not handled here are are passed to the 
+ * superclass attributeSet method.
+ *
+
+This method isn't needed, since the two-levels-up ancestor
+class AbstractBlackBoxWidget has a default attributeSet() that
+will automatically go from "formatString" to peer.setFormatString().
+
+xap.bridges.dojo.DojoDatePickerBridge.prototype.attributeSet = function( event ) {
+    var name = event.getName();
+    var value = event.getNewValue();
+    var peer = this.getPeer();
+    var shouldResize = false ;
+      
+    if(name=="formatString"){
+        peer.setFormatString(value);
+    } else{
+        this.superclass.attributeSet.call( this, event );
+    }
+}
+
+*/
+
+/**
+ *  Sets the widget as our peer, upgrades it with new methods to adapt it to our use:
+**/
+xap.bridges.dojo.DojoDatePickerBridge.prototype.setPeer = function(aDatePicker){
+	this.superclass.setPeer.call(this,aDatePicker) ;	
+	aDatePicker._formatString="yyyy-MM-dd" ;
+	aDatePicker.setFormatString = function(aString){
+		aDatePicker._formatString = aString ; 
+	}
+	aDatePicker.getFormatString = function(){
+		return aDatePicker._formatString ; 
+	}	
+}