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/08/27 18:21:55 UTC

svn commit: r808493 - in /myfaces/tobago/branches/tobago-1.0.x/theme: scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/ standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/msie/script/

Author: bommel
Date: Thu Aug 27 16:21:52 2009
New Revision: 808493

URL: http://svn.apache.org/viewvc?rev=808493&view=rev
Log:
(TOBAGO-789) IE resets the selection in the select element when the select element gets focus via label

Modified:
    myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SelectOneChoiceRenderer.java
    myfaces/tobago/branches/tobago-1.0.x/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/msie/script/tobago.js

Modified: myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SelectOneChoiceRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SelectOneChoiceRenderer.java?rev=808493&r1=808492&r2=808493&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SelectOneChoiceRenderer.java (original)
+++ myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SelectOneChoiceRenderer.java Thu Aug 27 16:21:52 2009
@@ -34,6 +34,7 @@
 import org.apache.myfaces.tobago.renderkit.html.HtmlConstants;
 import org.apache.myfaces.tobago.renderkit.html.HtmlRendererUtil;
 import org.apache.myfaces.tobago.webapp.TobagoResponseWriter;
+import org.apache.myfaces.tobago.context.ClientProperties;
 
 import javax.faces.component.UIComponent;
 import javax.faces.context.FacesContext;
@@ -86,6 +87,11 @@
     if (onchange != null) {
       writer.writeAttribute(HtmlAttributes.ONCHANGE, onchange, true);
     }
+
+    if (ClientProperties.getInstance(facesContext.getViewRoot()).getUserAgent().isMsie()) {
+      writer.writeAttribute("onfocusin", "Tobago.fixSelectionOnFocusIn()", false);
+      writer.writeAttribute("onfocus", "Tobago.fixSelectionOnFocus()", false);
+    }
     Object[] values = {selectOne.getValue()};
 
     HtmlRendererUtil.renderSelectItems(selectOne, items, values, writer, facesContext);

Modified: myfaces/tobago/branches/tobago-1.0.x/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/msie/script/tobago.js
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-1.0.x/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/msie/script/tobago.js?rev=808493&r1=808492&r2=808493&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-1.0.x/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/msie/script/tobago.js (original)
+++ myfaces/tobago/branches/tobago-1.0.x/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/msie/script/tobago.js Thu Aug 27 16:21:52 2009
@@ -84,4 +84,26 @@
     // remove filter
     element.runtimeStyle.filter = "";
   }
+};
+
+Tobago.fixSelectionOnFocusIn = function() {
+  try {
+    var src = window.event.srcElement;
+    if (src) {
+      src.tmpIndex = src.selectedIndex;
+    }
+  } catch (e) {
+     // ignore
+  }
+};
+
+Tobago.fixSelectionOnFocus = function() {
+  try {
+    var src = window.event.srcElement;
+    if (src) {
+      src.selectedIndex = src.tmpIndex;
+     }
+  } catch (e) {
+    // ignore
+  }
 };
\ No newline at end of file