You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by bo...@apache.org on 2009/11/22 20:29:06 UTC

svn commit: r883128 - in /myfaces/tobago/trunk/theme: scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/ scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/script/ stan...

Author: bommel
Date: Sun Nov 22 19:29:05 2009
New Revision: 883128

URL: http://svn.apache.org/viewvc?rev=883128&view=rev
Log:
(TOBAGO-826) (TOBAGO-577) adding onChange support  and change facet support for datepicker 
thanks to Helmut Swaczinna for the patch

Modified:
    myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/DatePickerRenderer.java
    myfaces/tobago/trunk/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/script/calendar.js
    myfaces/tobago/trunk/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js

Modified: myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/DatePickerRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/DatePickerRenderer.java?rev=883128&r1=883127&r2=883128&view=diff
==============================================================================
--- myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/DatePickerRenderer.java (original)
+++ myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/DatePickerRenderer.java Sun Nov 22 19:29:05 2009
@@ -243,12 +243,12 @@
 
     UICommand okButton = (UICommand) popup.findComponent("ok" + CLOSE_POPUP);
     attributes = okButton.getAttributes();
-    attributes.put(Attributes.ONCLICK, "var textBox = writeIntoField2(this);Tobago.closePopup(this);textBox.focus();");
+    attributes.put(Attributes.ONCLICK, "writeIntoField2(this);");
     attributes.put(Attributes.POPUP_CLOSE, "afterSubmit");
 
     UICommand cancelButton = (UICommand) popup.findComponent(CLOSE_POPUP);
     attributes = cancelButton.getAttributes();
-    attributes.put(Attributes.ONCLICK, "var textBox = writeIntoField2(this);Tobago.closePopup(this);textBox.focus();");
+    attributes.put(Attributes.ONCLICK, "writeIntoField2(this);");
     attributes.put(Attributes.POPUP_CLOSE, "immediate");
 
     applyConverterPattern(facesContext, popup, converterPattern);

Modified: myfaces/tobago/trunk/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/script/calendar.js
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/script/calendar.js?rev=883128&r1=883127&r2=883128&view=diff
==============================================================================
--- myfaces/tobago/trunk/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/script/calendar.js (original)
+++ myfaces/tobago/trunk/theme/scarborough/src/main/resources/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/script/calendar.js Sun Nov 22 19:29:05 2009
@@ -221,11 +221,11 @@
 function writeIntoField2(obj) {
   var id = obj.id;
   var index = id.lastIndexOf(':');
-  return writeIntoField(id.substring(0, index));
+  return writeIntoField(obj, id.substring(0, index));
 }
 
 
-function writeIntoField(id) {
+function writeIntoField(obj, id) {
   var textBoxId = document.getElementById(id + ":calendar:fieldId");
   var textBox = document.getElementById(textBoxId.value);
 
@@ -253,11 +253,18 @@
     second = 0;
   }
   var date = new Date(year, month - 1, day, hour, minute, second);
-  textBox.value = formatDate(date, document.calendar.formatPattern);
-//  textBox.focus();
-//  alert(document.calendar.formatPattern);
-	return textBox;
+
+  Tobago.closePopup(obj)
+
+  textBox.focus();
+
+  var newValue =  formatDate(date, document.calendar.formatPattern);
+  if (textBox.value != newValue) {
+    textBox.value = newValue;
+    raiseEvent("change", textBox);
+  }
 }
+// ------------------------------------------------------------------
 
 // ------------------------------------------------------------------
 

Modified: myfaces/tobago/trunk/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js?rev=883128&r1=883127&r2=883128&view=diff
==============================================================================
--- myfaces/tobago/trunk/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js (original)
+++ myfaces/tobago/trunk/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js Sun Nov 22 19:29:05 2009
@@ -1787,6 +1787,18 @@
 
   setDefaultAction: function(defaultActionId) {
     Tobago.action.value = defaultActionId;
+  },
+
+  raiseEvent: function(eventType, element) {
+    if (document.createEvent) {
+      var evt = document.createEvent("Events");
+      evt.initEvent(eventType, true, true);
+      element.dispatchEvent(evt);
+    }
+    else if (document.createEventObject) {
+      var evt = document.createEventObject();   
+      element.fireEvent('on' + eventType, evt);
+    }
   }
 };