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/06/21 13:32:34 UTC

svn commit: r786994 - in /myfaces/tobago/branches/tobago-1.0.x: core/src/main/java/org/apache/myfaces/tobago/renderkit/html/ theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/ theme/standard/src/main/reso...

Author: bommel
Date: Sun Jun 21 11:32:34 2009
New Revision: 786994

URL: http://svn.apache.org/viewvc?rev=786994&view=rev
Log:
(TOBAGO-764) Documentation and clarification of tabIndex attribute usage

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

Modified: myfaces/tobago/branches/tobago-1.0.x/core/src/main/java/org/apache/myfaces/tobago/renderkit/html/HtmlRendererUtil.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-1.0.x/core/src/main/java/org/apache/myfaces/tobago/renderkit/html/HtmlRendererUtil.java?rev=786994&r1=786993&r2=786994&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-1.0.x/core/src/main/java/org/apache/myfaces/tobago/renderkit/html/HtmlRendererUtil.java (original)
+++ myfaces/tobago/branches/tobago-1.0.x/core/src/main/java/org/apache/myfaces/tobago/renderkit/html/HtmlRendererUtil.java Sun Jun 21 11:32:34 2009
@@ -62,21 +62,45 @@
 import java.util.StringTokenizer;
 
 /*
- * User: weber
  * Date: Jan 11, 2005
  * Time: 4:59:36 PM
  */
 public final class HtmlRendererUtil {
 
   private static final Log LOG = LogFactory.getLog(HtmlRendererUtil.class);
+  private static final String ERROR_FOCUS_KEY = HtmlRendererUtil.class.getName() + ".ErrorFocusId";
 
   private HtmlRendererUtil() {
     // to prevent instantiation
   }
 
-  public static void renderFocusId(FacesContext facesContext, UIComponent component)
+  private static boolean renderErrorFocusId(final FacesContext facesContext, final UIInput input) throws IOException {
+    if (ComponentUtil.isError(input)) {
+      if (!FacesContext.getCurrentInstance().getExternalContext().getRequestMap().containsKey(ERROR_FOCUS_KEY)) {
+        FacesContext.getCurrentInstance().getExternalContext().getRequestMap().put(ERROR_FOCUS_KEY, Boolean.TRUE);
+        TobagoResponseWriter writer = HtmlRendererUtil.getTobagoResponseWriter(facesContext);
+        String id = input.getClientId(facesContext);
+        writer.writeJavascript("Tobago.errorFocusId = '" + id + "';");
+        return true;
+      } else {
+        return true;
+      }
+    }
+    return FacesContext.getCurrentInstance().getExternalContext().getRequestMap().containsKey(ERROR_FOCUS_KEY);
+  }
+
+  public static void renderFocusId(final FacesContext facesContext, final UIComponent component)
       throws IOException {
+    if (component instanceof UIInput) {
+      renderFocusId(facesContext, (UIInput) component);
+    }
+  }
 
+  public static void renderFocusId(final FacesContext facesContext, final UIInput component)
+      throws IOException {
+    if (renderErrorFocusId(facesContext, component)) {
+      return;
+    }
     if (ComponentUtil.getBooleanAttribute(component, ATTR_FOCUS)) {
       UIPage page = ComponentUtil.findPage(facesContext, component);
       String id = component.getClientId(facesContext);

Modified: myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/DateRenderer.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/DateRenderer.java?rev=786994&r1=786993&r2=786994&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/DateRenderer.java (original)
+++ myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/DateRenderer.java Sun Jun 21 11:32:34 2009
@@ -80,10 +80,6 @@
             + "DatePicker may not work correctly.");
       }
     }
-
-    // focus
-    // TODO is this not already done in InRenderer?
-    HtmlRendererUtil.renderFocusId(facesContext, component);
   }
 }
 

Modified: myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TextAreaRenderer.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/TextAreaRenderer.java?rev=786994&r1=786993&r2=786994&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TextAreaRenderer.java (original)
+++ myfaces/tobago/branches/tobago-1.0.x/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TextAreaRenderer.java Sun Jun 21 11:32:34 2009
@@ -115,7 +115,7 @@
     }
 
     // focus
-    HtmlRendererUtil.renderFocusId(facesContext, component);
+    HtmlRendererUtil.renderFocusId(facesContext, input);
   }
 }
 

Modified: myfaces/tobago/branches/tobago-1.0.x/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/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/standard/script/tobago.js?rev=786994&r1=786993&r2=786994&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-1.0.x/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js (original)
+++ myfaces/tobago/branches/tobago-1.0.x/theme/standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js Sun Jun 21 11:32:34 2009
@@ -109,6 +109,8 @@
     */
   focusId: undefined,
 
+  errorFocusId: undefined,
+
   htmlIdIndex: 0,
 
   createHtmlId: function() {
@@ -1185,7 +1187,7 @@
     * no element is explicitly requested.
     */
   setFocus: function() {
-    var focusElement = this.element(this.focusId);
+    var focusElement = this.element(this.errorFocusId == "undefined" ? this.focusId: this.errorFocusId);
     if (focusElement) {
       try { // focus() on not visible elements breaks IE
         focusElement.focus();