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/01/20 18:40:59 UTC

svn commit: r498146 - in /myfaces/tobago/trunk/contrib/facelets/src/main/java/org/apache/myfaces/tobago/facelets: SupportsMarkupRule.java TobagoComponentHandler.java

Author: bommel
Date: Sat Jan 20 09:40:57 2007
New Revision: 498146

URL: http://svn.apache.org/viewvc?view=rev&rev=498146
Log:
(TOBAGO-205) Allow multiple values in markup attribute

Added:
    myfaces/tobago/trunk/contrib/facelets/src/main/java/org/apache/myfaces/tobago/facelets/SupportsMarkupRule.java
Modified:
    myfaces/tobago/trunk/contrib/facelets/src/main/java/org/apache/myfaces/tobago/facelets/TobagoComponentHandler.java

Added: myfaces/tobago/trunk/contrib/facelets/src/main/java/org/apache/myfaces/tobago/facelets/SupportsMarkupRule.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/contrib/facelets/src/main/java/org/apache/myfaces/tobago/facelets/SupportsMarkupRule.java?view=auto&rev=498146
==============================================================================
--- myfaces/tobago/trunk/contrib/facelets/src/main/java/org/apache/myfaces/tobago/facelets/SupportsMarkupRule.java (added)
+++ myfaces/tobago/trunk/contrib/facelets/src/main/java/org/apache/myfaces/tobago/facelets/SupportsMarkupRule.java Sat Jan 20 09:40:57 2007
@@ -0,0 +1,60 @@
+package org.apache.myfaces.tobago.facelets;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import com.sun.facelets.tag.Metadata;
+import com.sun.facelets.tag.TagAttribute;
+import com.sun.facelets.tag.MetadataTarget;
+import com.sun.facelets.tag.MetaRule;
+import com.sun.facelets.FaceletContext;
+import org.apache.myfaces.tobago.component.ComponentUtil;
+import org.apache.myfaces.tobago.component.SupportsMarkup;
+
+import javax.faces.component.UIComponent;
+
+/*
+ * User: bommel
+ * Date: Jan 20, 2007
+ * Time: 5:54:23 PM
+ */
+public class SupportsMarkupRule extends MetaRule {
+  public static final SupportsMarkupRule INSTANCE = new SupportsMarkupRule();
+
+  public Metadata applyRule(String name, TagAttribute attribute,
+      MetadataTarget metadataTarget) {
+    if (metadataTarget.isTargetInstanceOf(SupportsMarkup.class)) {
+      if ("markup".equals(name)) {
+        return new SupportsMarkupMapper(attribute);
+      }
+    }
+    return null;
+  }
+
+  static final class SupportsMarkupMapper extends Metadata {
+
+    private final TagAttribute attribute;
+
+    public SupportsMarkupMapper(TagAttribute attribute) {
+      this.attribute = attribute;
+    }
+
+    public void applyMetadata(FaceletContext ctx, Object instance) {
+      ComponentUtil.setMarkup((UIComponent)instance, attribute.getValue());
+    }
+  }
+}

Modified: myfaces/tobago/trunk/contrib/facelets/src/main/java/org/apache/myfaces/tobago/facelets/TobagoComponentHandler.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/contrib/facelets/src/main/java/org/apache/myfaces/tobago/facelets/TobagoComponentHandler.java?view=diff&rev=498146&r1=498145&r2=498146
==============================================================================
--- myfaces/tobago/trunk/contrib/facelets/src/main/java/org/apache/myfaces/tobago/facelets/TobagoComponentHandler.java (original)
+++ myfaces/tobago/trunk/contrib/facelets/src/main/java/org/apache/myfaces/tobago/facelets/TobagoComponentHandler.java Sat Jan 20 09:40:57 2007
@@ -26,6 +26,7 @@
 import org.apache.myfaces.tobago.event.SheetStateChangeSource;
 import org.apache.myfaces.tobago.component.OnComponentCreated;
 import org.apache.myfaces.tobago.component.UIPage;
+import org.apache.myfaces.tobago.component.SupportsMarkup;
 import static org.apache.myfaces.tobago.TobagoConstants.TOBAGO_COMPONENT_CREATED;
 
 import javax.faces.component.UIComponent;
@@ -55,6 +56,9 @@
     }
     if (SheetStateChangeSource.class.isAssignableFrom(aClass)) {
       metaRuleset.addRule(SheetStateChangeSourceRule.INSTANCE);
+    }
+    if (SupportsMarkup.class.isAssignableFrom(aClass)) {
+      metaRuleset.addRule(SupportsMarkupRule.INSTANCE);
     }
     return metaRuleset;
   }