dev@javaserverfaces.java.net

Seeking Retroactive Review: AttributeHandler

From: Ed Burns <Ed.Burns_at_Sun.COM>
Date: Fri, 26 Sep 2008 05:58:37 -0700

Issue: 280-EZComp

Automated tests still run, so I'm going to check this in, but review is
appreciated.


SECTION: Modified Files
----------------------------
M jsf-ri/src/com/sun/faces/facelets/tag/composite/AttributeHandler.java

- Implement a portion of EZComp not hitherto implemented, and not
  currently specified: make sure the attributes are included in the
  component metadata.


SECTION: Diffs
----------------------------
Index: jsf-ri/src/com/sun/faces/facelets/tag/composite/AttributeHandler.java
===================================================================
--- jsf-ri/src/com/sun/faces/facelets/tag/composite/AttributeHandler.java (revision 5479)
+++ jsf-ri/src/com/sun/faces/facelets/tag/composite/AttributeHandler.java (working copy)
 -61,6 +61,8 @@
 import java.beans.IntrospectionException;
 import java.beans.PropertyDescriptor;
 import java.io.IOException;
+import java.util.List;
+import java.util.Map;
 import javax.el.ELException;
 import javax.el.ValueExpression;
 import javax.faces.FacesException;
 -89,12 +91,30 @@
         
         PropertyDescriptor propertyDescriptor;
         TagAttribute attr;
+ CompositeComponentBeanInfo componentBeanInfo = null;
+ Map<String, Object> attrs = parent.getAttributes();
+
+ componentBeanInfo = (CompositeComponentBeanInfo) attrs.get(UIComponent.BEANINFO_KEY);
+ assert(null != componentBeanInfo);
+ List<PropertyDescriptor> declaredAttributes =
+ componentBeanInfo.getPropertyDescriptorsList();
 
         // Get the value of required the name propertyDescriptor
         ValueExpression ve = name.getValueExpression(ctx, String.class);
         String strValue = (String) ve.getValue(ctx);
+
+ // Search the propertyDescriptors for one for this attribute
+ for (PropertyDescriptor cur: declaredAttributes) {
+ if (strValue.endsWith(cur.getName())) {
+ // If we have a match, no need to waste time
+ // duplicating and replacing it.
+ return;
+ }
+ }
+
         try {
             propertyDescriptor = new PropertyDescriptor(strValue, null, null);
+ declaredAttributes.add(propertyDescriptor);
         } catch (IntrospectionException ex) {
             throw new TagException(tag, "Unable to create property descriptor for property " + strValue, ex);
         }

-- 
| ed.burns_at_sun.com  | office: 408 884 9519 OR x31640
| homepage:         | http://ridingthecrest.com/