You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by sk...@apache.org on 2009/08/03 16:15:50 UTC

svn commit: r800395 - in /myfaces/orchestra/trunk/sandbox/src/main/java/org/apache/myfaces/orchestra/dynaForm: annot/ui/MetaAttribute.java metadata/impl/ejb/EjbExtractor.java

Author: skitching
Date: Mon Aug  3 14:15:50 2009
New Revision: 800395

URL: http://svn.apache.org/viewvc?rev=800395&view=rev
Log:
Add support for new "MetaAttribute" annotation that causes bean introspection to add arbitrary (name, value) pairs to be stored in the dynaform attributes for that bean property.

Added:
    myfaces/orchestra/trunk/sandbox/src/main/java/org/apache/myfaces/orchestra/dynaForm/annot/ui/MetaAttribute.java   (with props)
Modified:
    myfaces/orchestra/trunk/sandbox/src/main/java/org/apache/myfaces/orchestra/dynaForm/metadata/impl/ejb/EjbExtractor.java

Added: myfaces/orchestra/trunk/sandbox/src/main/java/org/apache/myfaces/orchestra/dynaForm/annot/ui/MetaAttribute.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/sandbox/src/main/java/org/apache/myfaces/orchestra/dynaForm/annot/ui/MetaAttribute.java?rev=800395&view=auto
==============================================================================
--- myfaces/orchestra/trunk/sandbox/src/main/java/org/apache/myfaces/orchestra/dynaForm/annot/ui/MetaAttribute.java (added)
+++ myfaces/orchestra/trunk/sandbox/src/main/java/org/apache/myfaces/orchestra/dynaForm/annot/ui/MetaAttribute.java Mon Aug  3 14:15:50 2009
@@ -0,0 +1,38 @@
+/*
+ * 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.
+ */
+package org.apache.myfaces.orchestra.dynaForm.annot.ui;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Store the (name,value) pair into the Attributes map of this field's metadata.
+ * <p>
+ * User code can later check for arbitrary attributes on a field. In particular,
+ * a custom DynaFormComponentHandler implementation may want to do this.
+ */
+@Target(value = {ElementType.METHOD, ElementType.FIELD})
+@Retention(value = RetentionPolicy.RUNTIME)
+public @interface MetaAttribute
+{
+    String name();
+    String value();
+}

Propchange: myfaces/orchestra/trunk/sandbox/src/main/java/org/apache/myfaces/orchestra/dynaForm/annot/ui/MetaAttribute.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: myfaces/orchestra/trunk/sandbox/src/main/java/org/apache/myfaces/orchestra/dynaForm/metadata/impl/ejb/EjbExtractor.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/sandbox/src/main/java/org/apache/myfaces/orchestra/dynaForm/metadata/impl/ejb/EjbExtractor.java?rev=800395&r1=800394&r2=800395&view=diff
==============================================================================
--- myfaces/orchestra/trunk/sandbox/src/main/java/org/apache/myfaces/orchestra/dynaForm/metadata/impl/ejb/EjbExtractor.java (original)
+++ myfaces/orchestra/trunk/sandbox/src/main/java/org/apache/myfaces/orchestra/dynaForm/metadata/impl/ejb/EjbExtractor.java Mon Aug  3 14:15:50 2009
@@ -55,6 +55,7 @@
 import org.apache.myfaces.orchestra.dynaForm.annot.ui.IgnoreProperty;
 import org.apache.myfaces.orchestra.dynaForm.annot.ui.Length;
 import org.apache.myfaces.orchestra.dynaForm.annot.ui.Max;
+import org.apache.myfaces.orchestra.dynaForm.annot.ui.MetaAttribute;
 import org.apache.myfaces.orchestra.dynaForm.annot.ui.Min;
 import org.apache.myfaces.orchestra.dynaForm.annot.ui.NotNull;
 import org.apache.myfaces.orchestra.dynaForm.annot.ui.Range;
@@ -649,6 +650,15 @@
             DisplaySize displaySize = accessibleObject.getAnnotation(DisplaySize.class);
             mdField.setDisplaySize(displaySize.value());
         }
+
+        // Handle arbitrary metadata attributes
+        if (accessibleObject.isAnnotationPresent(MetaAttribute.class))
+        {
+            MetaAttribute attr = accessibleObject.getAnnotation(MetaAttribute.class);
+            String name = attr.name();
+            String value = attr.value();
+            mdField.setAttribute(name, value);
+        }
     }
 
     /**