myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bom...@apache.org
Subject svn commit: r950678 - in /myfaces/tobago/trunk/tobago-extension/tobago-facelets/src/main/java/org/apache/myfaces/tobago/facelets/extension: TobagoLabelExtensionHandler.java TobagoMenuExtensionHandler.java
Date Wed, 02 Jun 2010 17:27:23 GMT
Author: bommel
Date: Wed Jun  2 17:27:23 2010
New Revision: 950678

URL: http://svn.apache.org/viewvc?rev=950678&view=rev
Log:
(TOBAGO-888) tx:menuRadio may produce a ClassCastException on concurrent access

Modified:
    myfaces/tobago/trunk/tobago-extension/tobago-facelets/src/main/java/org/apache/myfaces/tobago/facelets/extension/TobagoLabelExtensionHandler.java
    myfaces/tobago/trunk/tobago-extension/tobago-facelets/src/main/java/org/apache/myfaces/tobago/facelets/extension/TobagoMenuExtensionHandler.java

Modified: myfaces/tobago/trunk/tobago-extension/tobago-facelets/src/main/java/org/apache/myfaces/tobago/facelets/extension/TobagoLabelExtensionHandler.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-extension/tobago-facelets/src/main/java/org/apache/myfaces/tobago/facelets/extension/TobagoLabelExtensionHandler.java?rev=950678&r1=950677&r2=950678&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-extension/tobago-facelets/src/main/java/org/apache/myfaces/tobago/facelets/extension/TobagoLabelExtensionHandler.java
(original)
+++ myfaces/tobago/trunk/tobago-extension/tobago-facelets/src/main/java/org/apache/myfaces/tobago/facelets/extension/TobagoLabelExtensionHandler.java
Wed Jun  2 17:27:23 2010
@@ -20,6 +20,7 @@ package org.apache.myfaces.tobago.facele
 import com.sun.facelets.FaceletContext;
 import com.sun.facelets.el.ELAdaptor;
 import com.sun.facelets.tag.MetaRuleset;
+import com.sun.facelets.tag.Metadata;
 import com.sun.facelets.tag.TagAttribute;
 import com.sun.facelets.tag.jsf.ComponentConfig;
 import com.sun.facelets.tag.jsf.ComponentHandler;
@@ -62,6 +63,8 @@ public abstract class TobagoLabelExtensi
   private TagAttribute labelAttribute;
   private TagAttribute markupAttribute;
   private TagAttribute fieldIdAttribute;
+  private Class subComponentLastType = Object.class;
+  private Metadata subComponentMapper;
 
   public TobagoLabelExtensionHandler(ComponentConfig config) {
     super(config);
@@ -127,7 +130,7 @@ public abstract class TobagoLabelExtensi
     input.setId(uid);
     enrichInput(faceletContext, input);
     
-    setAttributes(faceletContext, input);
+    setSubComponentAttributes(faceletContext, input);
 
     panel.getChildren().add(input);
   }
@@ -210,22 +213,22 @@ public abstract class TobagoLabelExtensi
     }
   }
 
-  protected MetaRuleset createMetaRuleset(Class aClass) {
-    MetaRuleset metaRuleset = super.createMetaRuleset(aClass);
-    if (UIPanel.class.isAssignableFrom(aClass)) {
-      TagAttribute [] attrs = tag.getAttributes().getAll();
-      for (int i = 0; i < attrs.length; i++) {
-        TagAttribute attr = attrs[i];
-        if (!attr.getLocalName().equals("rendered")) {
-          metaRuleset.ignore(attr.getLocalName());
-        }
-      }
-      return metaRuleset;
-    } else {
-      metaRuleset.ignore(Attributes.LABEL);
-      metaRuleset.ignore(Attributes.TIP);
-      metaRuleset.ignore("labelWidth");
+  private void setSubComponentAttributes(FaceletContext ctx, Object instance) {
+    if (instance != null) {
+      Class type = instance.getClass();
+      if (subComponentMapper == null || !subComponentLastType.equals(type)) {
+        subComponentLastType = type;
+        subComponentMapper = createSubComponentMetaRuleset(type).finish();
+      }
+      subComponentMapper.applyMetadata(ctx, instance);
     }
+  }
+
+  protected MetaRuleset createSubComponentMetaRuleset(Class aClass) {
+    MetaRuleset metaRuleset = createMetaRuleset(aClass);
+    metaRuleset.ignore(Attributes.LABEL);
+    metaRuleset.ignore(Attributes.TIP);
+    metaRuleset.ignore("labelWidth");
     if (SupportsMarkup.class.isAssignableFrom(aClass)) {
       metaRuleset.addRule(SupportsMarkupRule.INSTANCE);
     }
@@ -234,4 +237,16 @@ public abstract class TobagoLabelExtensi
     }
     return metaRuleset;
   }
+
+  protected MetaRuleset createMetaRuleset(Class aClass) {
+    MetaRuleset metaRuleset = super.createMetaRuleset(aClass);
+    TagAttribute [] attrs = tag.getAttributes().getAll();
+    for (int i = 0; i < attrs.length; i++) {
+      TagAttribute attr = attrs[i];
+      if (!attr.getLocalName().equals("rendered")) {
+        metaRuleset.ignore(attr.getLocalName());
+      }
+    }
+    return metaRuleset;
+  }
 }

Modified: myfaces/tobago/trunk/tobago-extension/tobago-facelets/src/main/java/org/apache/myfaces/tobago/facelets/extension/TobagoMenuExtensionHandler.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-extension/tobago-facelets/src/main/java/org/apache/myfaces/tobago/facelets/extension/TobagoMenuExtensionHandler.java?rev=950678&r1=950677&r2=950678&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-extension/tobago-facelets/src/main/java/org/apache/myfaces/tobago/facelets/extension/TobagoMenuExtensionHandler.java
(original)
+++ myfaces/tobago/trunk/tobago-extension/tobago-facelets/src/main/java/org/apache/myfaces/tobago/facelets/extension/TobagoMenuExtensionHandler.java
Wed Jun  2 17:27:23 2010
@@ -19,12 +19,12 @@ package org.apache.myfaces.tobago.facele
 
 import com.sun.facelets.FaceletContext;
 import com.sun.facelets.tag.MetaRuleset;
+import com.sun.facelets.tag.Metadata;
 import com.sun.facelets.tag.TagAttribute;
 import com.sun.facelets.tag.jsf.ComponentConfig;
 import com.sun.facelets.tag.jsf.ComponentHandler;
 import com.sun.facelets.tag.jsf.ComponentSupport;
 import org.apache.myfaces.tobago.component.Attributes;
-import org.apache.myfaces.tobago.component.UIMenuCommand;
 
 import javax.el.ELException;
 import javax.faces.FacesException;
@@ -39,6 +39,9 @@ import java.io.IOException;
  */
 public abstract class TobagoMenuExtensionHandler extends ComponentHandler {
 
+  private Class subComponentLastType = Object.class;
+  private Metadata subComponentMapper;
+
   public TobagoMenuExtensionHandler(ComponentConfig config) {
     super(config);
   }
@@ -67,26 +70,38 @@ public abstract class TobagoMenuExtensio
     UIComponent component = application.createComponent(getSubComponentType());
     component.setId(root.createUniqueId());
     component.setRendererType(getSubRendererType());
-    setAttributes(faceletContext, component);
+    setSubComponentAttributes(faceletContext, component);
     menuCommand.getFacets().put(getFacetName(), component);
   }
 
-  protected MetaRuleset createMetaRuleset(Class aClass) {
-    MetaRuleset metaRuleset = super.createMetaRuleset(aClass);
-    if (UIMenuCommand.class.isAssignableFrom(aClass)) {
-      metaRuleset.ignore(Attributes.CONVERTER);
-      metaRuleset.ignore(Attributes.VALUE);
-      return metaRuleset;
-    } else {
-      TagAttribute [] attrs = tag.getAttributes().getAll();
-      for (int i = 0; i < attrs.length; i++) {
-        TagAttribute attr = attrs[i];
-        if (!(attr.getLocalName().equals(Attributes.CONVERTER)
-            || attr.getLocalName().equals(Attributes.VALUE))) {
-          metaRuleset.ignore(attr.getLocalName());
-        }
+  private void setSubComponentAttributes(FaceletContext ctx, Object instance) {
+    if (instance != null) {
+      Class type = instance.getClass();
+      if (subComponentMapper == null || !subComponentLastType.equals(type)) {
+        subComponentLastType = type;
+        subComponentMapper = createSubComponentMetaRuleset(type).finish();
+      }
+      this.subComponentMapper.applyMetadata(ctx, instance);
+    }
+  }
+
+  protected MetaRuleset createSubComponentMetaRuleset(Class aClass) {
+    MetaRuleset metaRuleset = createMetaRuleset(aClass);
+    TagAttribute [] attrs = tag.getAttributes().getAll();
+    for (int i = 0; i < attrs.length; i++) {
+      TagAttribute attr = attrs[i];
+      if (!(attr.getLocalName().equals(Attributes.CONVERTER)
+          || attr.getLocalName().equals(Attributes.VALUE))) {
+        metaRuleset.ignore(attr.getLocalName());
       }
-      return metaRuleset;
     }
+    return metaRuleset;
+  }
+
+  protected MetaRuleset createMetaRuleset(Class aClass) {
+    MetaRuleset metaRuleset = super.createMetaRuleset(aClass);
+    metaRuleset.ignore(Attributes.CONVERTER);
+    metaRuleset.ignore(Attributes.VALUE);
+    return metaRuleset;
   }
 }



Mime
View raw message