You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2012/07/24 11:49:02 UTC

svn commit: r1364955 - in /myfaces/tobago/trunk: tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/ tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/

Author: lofwyr
Date: Tue Jul 24 09:49:02 2012
New Revision: 1364955

URL: http://svn.apache.org/viewvc?rev=1364955&view=rev
Log:
TOBAGO-1182: Accesskey support without rendering javascript fragments 
 - checking for null values
 - using better writeAttribute method (not escaping)
 - checking for allowed chars

Modified:
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/LabelWithAccessKey.java
    myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/ButtonRenderer.java
    myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/LabelRenderer.java
    myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/LinkRenderer.java
    myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MenuCommandRenderer.java
    myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MenuRenderer.java
    myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SelectBooleanCheckboxRenderer.java
    myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TabGroupRenderer.java
    myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeCommandRenderer.java

Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/LabelWithAccessKey.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/LabelWithAccessKey.java?rev=1364955&r1=1364954&r2=1364955&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/LabelWithAccessKey.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/LabelWithAccessKey.java Tue Jul 24 09:49:02 2012
@@ -67,7 +67,7 @@ public final class LabelWithAccessKey {
     } else {
       text = label.substring(0, index)
           + label.substring(index + 1);
-      accessKey = text.charAt(index);
+      setAccessKey(text.charAt(index));
       pos = index - escapedIndicatorCount;
     }
   }
@@ -107,7 +107,17 @@ public final class LabelWithAccessKey {
   }
 
   public void setAccessKey(Character accessKey) {
+    if (! isPermitted(accessKey)) {
+      LOG.warn("Ignoring illegal access key: " + accessKey);
+    }
     this.accessKey = accessKey;
   }
 
+  /**
+   * Ensures, that no illegal character will be write out.
+   * (If this is changed from only allowing letters, the renderers may change the escaping)
+   */
+  private boolean isPermitted(Character accessKey) {
+    return accessKey >= 'a' && accessKey <= 'z' || accessKey >= 'A' && accessKey <= 'Z';
+  }
 }

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/ButtonRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/ButtonRenderer.java?rev=1364955&r1=1364954&r2=1364955&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/ButtonRenderer.java (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/ButtonRenderer.java Tue Jul 24 09:49:02 2012
@@ -70,7 +70,7 @@ public class ButtonRenderer extends Comm
       writer.writeAttribute(HtmlAttributes.TABINDEX, tabIndex);
     }
     if (label.getAccessKey() != null && helper.isDisabled()) {
-      writer.writeAttribute(HtmlAttributes.ACCESSKEY, label.getAccessKey(), null);
+      writer.writeAttribute(HtmlAttributes.ACCESSKEY, Character.toString(label.getAccessKey()), false);
     }
     if (helper.getOnclick() != null) {
       writer.writeAttribute(HtmlAttributes.ONCLICK, helper.getOnclick(), true);

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/LabelRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/LabelRenderer.java?rev=1364955&r1=1364954&r2=1364955&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/LabelRenderer.java (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/LabelRenderer.java Tue Jul 24 09:49:02 2012
@@ -89,7 +89,7 @@ public class LabelRenderer extends Layou
     String clientId = label.getClientId(facesContext);
     LabelWithAccessKey key = new LabelWithAccessKey(label);
     if (key.getAccessKey() != null) {
-      writer.writeAttribute(HtmlAttributes.ACCESSKEY, key.getAccessKey(), null);
+      writer.writeAttribute(HtmlAttributes.ACCESSKEY, Character.toString(key.getAccessKey()), false);
     }
     if (key.getText() != null) {
       HtmlRendererUtils.writeLabelWithAccessKey(writer, key);

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/LinkRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/LinkRenderer.java?rev=1364955&r1=1364954&r2=1364955&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/LinkRenderer.java (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/LinkRenderer.java Tue Jul 24 09:49:02 2012
@@ -70,7 +70,7 @@ public class LinkRenderer extends Comman
         writer.writeAttribute(HtmlAttributes.TABINDEX, tabIndex);
       }
       if (label.getAccessKey() != null) {
-        writer.writeAttribute(HtmlAttributes.ACCESSKEY, label.getAccessKey(), null);
+        writer.writeAttribute(HtmlAttributes.ACCESSKEY, Character.toString(label.getAccessKey()), false);
       }
     }
     Style style = new Style(facesContext, link);

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MenuCommandRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MenuCommandRenderer.java?rev=1364955&r1=1364954&r2=1364955&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MenuCommandRenderer.java (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MenuCommandRenderer.java Tue Jul 24 09:49:02 2012
@@ -187,8 +187,8 @@ public class MenuCommandRenderer extends
             && !AccessKeyMap.addAccessKey(facesContext, label.getAccessKey())) {
           LOG.info("duplicated accessKey : " + label.getAccessKey());
         }
-        if (!disabled && component != null) {
-          writer.writeAttribute(HtmlAttributes.ACCESSKEY, label.getAccessKey(), null);
+        if (!disabled && component != null && label.getAccessKey() != null) {
+          writer.writeAttribute(HtmlAttributes.ACCESSKEY, Character.toString(label.getAccessKey()), false);
         }
       }
       HtmlRendererUtils.writeLabelWithAccessKey(writer, label);

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MenuRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MenuRenderer.java?rev=1364955&r1=1364954&r2=1364955&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MenuRenderer.java (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/MenuRenderer.java Tue Jul 24 09:49:02 2012
@@ -81,8 +81,8 @@ public class MenuRenderer extends Layout
             && !AccessKeyMap.addAccessKey(facesContext, label.getAccessKey())) {
           LOG.info("duplicated accessKey : " + label.getAccessKey());
         }
-        if (!disabled) {
-          writer.writeAttribute(HtmlAttributes.ACCESSKEY, label.getAccessKey(), null);
+        if (!disabled && label.getAccessKey() != null) {
+          writer.writeAttribute(HtmlAttributes.ACCESSKEY, Character.toString(label.getAccessKey()), false);
         }
       }
       HtmlRendererUtils.writeLabelWithAccessKey(writer, label);

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SelectBooleanCheckboxRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SelectBooleanCheckboxRenderer.java?rev=1364955&r1=1364954&r2=1364955&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SelectBooleanCheckboxRenderer.java (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/SelectBooleanCheckboxRenderer.java Tue Jul 24 09:49:02 2012
@@ -120,7 +120,7 @@ public class SelectBooleanCheckboxRender
       writer.startElement(HtmlElements.LABEL, select);
       writer.writeAttribute(HtmlAttributes.FOR, id, false);
       if (labelWithAccessKey.getAccessKey() != null) {
-        writer.writeAttribute(HtmlAttributes.ACCESSKEY, labelWithAccessKey.getAccessKey(), null);
+        writer.writeAttribute(HtmlAttributes.ACCESSKEY, Character.toString(labelWithAccessKey.getAccessKey()), false);
       }
       HtmlRendererUtils.writeLabelWithAccessKey(writer, labelWithAccessKey);
       if (labelWithAccessKey.getAccessKey() != null) {

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TabGroupRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TabGroupRenderer.java?rev=1364955&r1=1364954&r2=1364955&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TabGroupRenderer.java (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TabGroupRenderer.java Tue Jul 24 09:49:02 2012
@@ -202,7 +202,9 @@ public class TabGroupRenderer extends La
           }
           final String tabId = tab.getClientId(facesContext);
           writer.writeIdAttribute(tabId);
-          writer.writeAttribute(HtmlAttributes.ACCESSKEY, label.getAccessKey(), null);
+          if (label.getAccessKey() != null) {
+            writer.writeAttribute(HtmlAttributes.ACCESSKEY, Character.toString(label.getAccessKey()), false);
+          }
           if (label.getText() != null) {
             HtmlRendererUtils.writeLabelWithAccessKey(writer, label);
           } else {

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeCommandRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeCommandRenderer.java?rev=1364955&r1=1364954&r2=1364955&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeCommandRenderer.java (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TreeCommandRenderer.java Tue Jul 24 09:49:02 2012
@@ -80,7 +80,9 @@ public class TreeCommandRenderer extends
     writer.writeStyleAttribute(createStyle(facesContext, command));
     writer.writeClassAttribute(Classes.create(command));
     writer.writeIdAttribute(clientId);
-    writer.writeAttribute(HtmlAttributes.ACCESSKEY, label.getAccessKey(), null);
+    if (label.getAccessKey() != null) {
+      writer.writeAttribute(HtmlAttributes.ACCESSKEY, Character.toString(label.getAccessKey()), false);
+    }
     HtmlRendererUtils.renderTip(command, writer);
     writer.flush();