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 2007/05/24 12:51:07 UTC

svn commit: r541264 - in /myfaces/tobago/tags/tobago-1.0.11: contrib/facelets/src/main/java/org/apache/myfaces/tobago/facelets/ core/src/main/java/org/apache/myfaces/tobago/ core/src/main/java/org/apache/myfaces/tobago/component/ core/src/main/java/org...

Author: bommel
Date: Thu May 24 03:51:05 2007
New Revision: 541264

URL: http://svn.apache.org/viewvc?view=rev&rev=541264
Log:
(TOBAGO-410) attribute-tag causes ClassCastException

Modified:
    myfaces/tobago/tags/tobago-1.0.11/contrib/facelets/src/main/java/org/apache/myfaces/tobago/facelets/AttributeHandler.java
    myfaces/tobago/tags/tobago-1.0.11/core/src/main/java/org/apache/myfaces/tobago/TobagoConstants.java
    myfaces/tobago/tags/tobago-1.0.11/core/src/main/java/org/apache/myfaces/tobago/component/ComponentUtil.java
    myfaces/tobago/tags/tobago-1.0.11/core/src/main/java/org/apache/myfaces/tobago/taglib/component/AttributeTag.java

Modified: myfaces/tobago/tags/tobago-1.0.11/contrib/facelets/src/main/java/org/apache/myfaces/tobago/facelets/AttributeHandler.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/tags/tobago-1.0.11/contrib/facelets/src/main/java/org/apache/myfaces/tobago/facelets/AttributeHandler.java?view=diff&rev=541264&r1=541263&r2=541264
==============================================================================
--- myfaces/tobago/tags/tobago-1.0.11/contrib/facelets/src/main/java/org/apache/myfaces/tobago/facelets/AttributeHandler.java (original)
+++ myfaces/tobago/tags/tobago-1.0.11/contrib/facelets/src/main/java/org/apache/myfaces/tobago/facelets/AttributeHandler.java Thu May 24 03:51:05 2007
@@ -59,21 +59,25 @@
       String nameValue = name.getValue(ctx);
       if ("rendered".equals(nameValue)) {
         // TODO expression
-        parent.setRendered(value.getBoolean(ctx));
-      } else if (TobagoConstants.ATTR_RENDERED_PARTIALLY.equals(nameValue)
-          && parent instanceof UICommand) {
+        if (value.isLiteral()) {
+          parent.setRendered(value.getBoolean(ctx));
+        } else {
+          ELAdaptor.setExpression(parent, nameValue, value.getValueExpression(ctx, Object.class));
+        }
+      } else if (TobagoConstants.ATTR_RENDERED_PARTIALLY.equals(nameValue) && parent instanceof UICommand) {
         // TODO test expression
         ComponentUtil.setRenderedPartially((UICommand) parent, value.getValue());
-      } else if (parent instanceof EditableValueHolder
-          && "validator".equals(nameValue)) {
+      } else if (TobagoConstants.ATTR_STYLE_CLASS.equals(nameValue)) {
+        // TODO test expression
+        ComponentUtil.setStyleClasses(parent, value.getValue());
+      } else if (parent instanceof EditableValueHolder && TobagoConstants.ATTR_VALIDATOR.equals(nameValue)) {
         MethodExpression methodExpression = value.getMethodExpression(ctx, null, VALIDATOR);
         ((EditableValueHolder) parent).setValidator(new LegacyMethodBinding(methodExpression));
       } else if (!parent.getAttributes().containsKey(nameValue)) {
         if (value.isLiteral()) {
           parent.getAttributes().put(nameValue, value.getValue());
         } else {
-          ELAdaptor.setExpression(parent, nameValue, value
-              .getValueExpression(ctx, Object.class));
+          ELAdaptor.setExpression(parent, nameValue, value.getValueExpression(ctx, Object.class));
         }
       }
     }

Modified: myfaces/tobago/tags/tobago-1.0.11/core/src/main/java/org/apache/myfaces/tobago/TobagoConstants.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/tags/tobago-1.0.11/core/src/main/java/org/apache/myfaces/tobago/TobagoConstants.java?view=diff&rev=541264&r1=541263&r2=541264
==============================================================================
--- myfaces/tobago/tags/tobago-1.0.11/core/src/main/java/org/apache/myfaces/tobago/TobagoConstants.java (original)
+++ myfaces/tobago/tags/tobago-1.0.11/core/src/main/java/org/apache/myfaces/tobago/TobagoConstants.java Thu May 24 03:51:05 2007
@@ -169,6 +169,7 @@
   public static final String ATTR_WIDTH_LIST = "widthList";
   public static final String ATTR_WIDTH_LIST_STRING = "widthListString";
   public static final String ATTR_APPLICATION_ICON = "applicationIcon";
+  public static final String ATTR_VALIDATOR = "validator";
 
   public static final String FACET_ACTION = "action";
   public static final String FACET_CONFIRMATION = "confirmation";

Modified: myfaces/tobago/tags/tobago-1.0.11/core/src/main/java/org/apache/myfaces/tobago/component/ComponentUtil.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/tags/tobago-1.0.11/core/src/main/java/org/apache/myfaces/tobago/component/ComponentUtil.java?view=diff&rev=541264&r1=541263&r2=541264
==============================================================================
--- myfaces/tobago/tags/tobago-1.0.11/core/src/main/java/org/apache/myfaces/tobago/component/ComponentUtil.java (original)
+++ myfaces/tobago/tags/tobago-1.0.11/core/src/main/java/org/apache/myfaces/tobago/component/ComponentUtil.java Thu May 24 03:51:05 2007
@@ -50,10 +50,12 @@
 import static org.apache.myfaces.tobago.TobagoConstants.RENDERER_TYPE_OUT;
 import static org.apache.myfaces.tobago.TobagoConstants.RENDERER_TYPE_SELECT_BOOLEAN_CHECKBOX;
 import static org.apache.myfaces.tobago.TobagoConstants.RENDERER_TYPE_SELECT_ONE_RADIO;
+import static org.apache.myfaces.tobago.TobagoConstants.ATTR_STYLE_CLASS;
 import org.apache.myfaces.tobago.el.ConstantMethodBinding;
 import org.apache.myfaces.tobago.event.SheetStateChangeEvent;
 import org.apache.myfaces.tobago.event.PopupActionListener;
 import org.apache.myfaces.tobago.renderkit.LayoutableRendererBase;
+import org.apache.myfaces.tobago.renderkit.html.StyleClasses;
 import org.apache.myfaces.tobago.util.RangeParser;
 import org.apache.myfaces.tobago.context.TransientStateHolder;
 
@@ -347,14 +349,31 @@
     }
   }
 
- public static void setRenderedPartially(org.apache.myfaces.tobago.component.UICommand command,
+  public static void setRenderedPartially(org.apache.myfaces.tobago.component.UICommand command,
      String renderers) {
-   if (renderers != null) {
-     if (UIComponentTag.isValueReference(renderers)) {
-       command.setValueBinding(ATTR_RENDERED_PARTIALLY, createValueBinding(renderers));
-     } else {
-       String [] components  = renderers.split(",");
-       command.setRenderedPartially(components);
+    if (renderers != null) {
+      if (UIComponentTag.isValueReference(renderers)) {
+        command.setValueBinding(ATTR_RENDERED_PARTIALLY, createValueBinding(renderers));
+      } else {
+        String [] components  = renderers.split(",");
+        command.setRenderedPartially(components);
+      }
+    }
+  }
+
+  public static void setStyleClasses(UIComponent component,
+     String styleClasses) {
+    if (styleClasses != null) {
+      if (UIComponentTag.isValueReference(styleClasses)) {
+        component.setValueBinding(ATTR_STYLE_CLASS, createValueBinding(styleClasses));
+      } else {
+        String [] classes  = styleClasses.split("[,  ]");
+        if (classes.length > 0) {
+          StyleClasses styles = StyleClasses.ensureStyleClasses(component);
+          for (String clazz: classes) {
+            styles.addFullQualifiedClass(clazz);
+          }
+        }
       }
     }
   }

Modified: myfaces/tobago/tags/tobago-1.0.11/core/src/main/java/org/apache/myfaces/tobago/taglib/component/AttributeTag.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/tags/tobago-1.0.11/core/src/main/java/org/apache/myfaces/tobago/taglib/component/AttributeTag.java?view=diff&rev=541264&r1=541263&r2=541264
==============================================================================
--- myfaces/tobago/tags/tobago-1.0.11/core/src/main/java/org/apache/myfaces/tobago/taglib/component/AttributeTag.java (original)
+++ myfaces/tobago/tags/tobago-1.0.11/core/src/main/java/org/apache/myfaces/tobago/taglib/component/AttributeTag.java Thu May 24 03:51:05 2007
@@ -34,8 +34,6 @@
 import javax.faces.context.FacesContext;
 
 /*
- * Created by IntelliJ IDEA.
- * User: bommel
  * Date: Oct 14, 2006
  * Time: 1:47:13 PM
  */
@@ -106,11 +104,15 @@
         throw new JspException("Can not get ValueBinding for attribute name " + name);
       }
     }
-    if (component instanceof EditableValueHolder && attributeName.equals("validator")) {
+    if (component instanceof EditableValueHolder
+        && TobagoConstants.ATTR_VALIDATOR.equals(attributeName)) {
       ComponentUtil.setValidator((EditableValueHolder) component, value);
-    } else if (component instanceof ValueHolder && attributeName.equals("converter")) {
+    } else if (component instanceof ValueHolder
+        && TobagoConstants.ATTR_CONVERTER.equals(attributeName)) {
       ComponentUtil.setConverter((ValueHolder) component, value);
-    } else if (attributeName.equals(TobagoConstants.ATTR_RENDERED_PARTIALLY)
+    } else if (TobagoConstants.ATTR_STYLE_CLASS.equals(attributeName)) {
+      ComponentUtil.setStyleClasses(component, value);
+    } else if (TobagoConstants.ATTR_RENDERED_PARTIALLY.equals(attributeName)
         && component instanceof UICommand) {
       ComponentUtil.setRenderedPartially((UICommand) component, value);
     } else if (UIComponentTag.isValueReference(value)) {