You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltaspike.apache.org by gp...@apache.org on 2013/05/26 18:12:53 UTC

svn commit: r1486424 - /incubator/deltaspike/site/trunk/content/deltaspike/jsf.mdtext

Author: gpetracek
Date: Sun May 26 16:12:53 2013
New Revision: 1486424

URL: http://svn.apache.org/r1486424
Log:
updated content

Modified:
    incubator/deltaspike/site/trunk/content/deltaspike/jsf.mdtext

Modified: incubator/deltaspike/site/trunk/content/deltaspike/jsf.mdtext
URL: http://svn.apache.org/viewvc/incubator/deltaspike/site/trunk/content/deltaspike/jsf.mdtext?rev=1486424&r1=1486423&r2=1486424&view=diff
==============================================================================
--- incubator/deltaspike/site/trunk/content/deltaspike/jsf.mdtext (original)
+++ incubator/deltaspike/site/trunk/content/deltaspike/jsf.mdtext Sun May 26 16:12:53 2013
@@ -608,14 +608,78 @@ For folders it's optional to implement t
 ## Advanced API usages
 [TODO]
 
-### Creating Custom Meta-Data via @ViewMetaData
-[TODO]
-
-### Creating Custom Callbacks via @ViewMetaData
-[TODO]
+Creating Custom Meta-Data via @ViewMetaData
+This meta-annotation allows to create custom view-meta-data which can be used for view-configs. Per default meta-data of a lower level overrides meta-data on a higher level which has the same type. That can be customized via annotating the final annotation as a whole via `@Aggregated(true)`.
 
-### Creating Custom inline Meta-Data via @InlineViewMetaData
-[TODO]
+    :::java
+    @ViewMetaData
+    @interface InfoPage
+    {
+    }
+
+By just using `@InfoPage` in view-configs, it can be queried via:
+
+    :::java
+    @Inject
+    private ViewConfigResolver viewConfigResolver;
+    //...
+
+    ViewConfigDescriptor viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(Pages.Index.class);
+    List<InfoPage> metaDataList = viewConfigDescriptor.getMetaData(InfoPage.class)
+
+Creating Custom Callbacks via @ViewMetaData
+
+Via a custom ConfigPreProcessor it's possible to register custom callbacks dynamically.
+The following listing shows a view-config which adds a simple callback including the corresponding `ConfigPreProcessor` and `ExecutableCallbackDescriptor`.
+
+    :::java
+    @ViewMetaData(preProcessor = MySecured.AnnotationPreProcessor.class)
+    public @interface MySecured
+    {
+        Class<? extends TestAccessDecisionVoter>[] value();
+
+        class AnnotationPreProcessor implements ConfigPreProcessor<MySecured>
+        {
+            @Override
+            public MySecured beforeAddToConfig(MySecured metaData, ViewConfigNode viewConfigNode)
+            {
+                List<CallbackDescriptor> descriptors = viewConfigNode.getCallbackDescriptors(MySecured.class);
+                descriptors.add(new Descriptor(metaData.value(), DefaultCallback.class));
+                return metaData;
+            }
+        }
+
+        static class Descriptor extends ExecutableCallbackDescriptor<Set<String>>
+        {
+            public Descriptor(Class[] beanClasses, Class<? extends Annotation> callbackMarker)
+            {
+                super(beanClasses, callbackMarker);
+            }
+
+            public List<Set<String>> execute(String param1, String param2)
+            {
+                return super.execute(param1, param2);
+            }
+        }
+    }
+
+By just using `@MySecured` in view-configs, it can be queried and executed via:
+
+    :::java
+    @Inject
+    private ViewConfigResolver viewConfigResolver;
+    //...
+    ViewConfigDescriptor viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(Pages.Secured.Index.class);
+
+    List<Set<String> /*return type of one callback*/> callbackResult =
+        viewConfigDescriptor.getExecutableCallbackDescriptor(MySecured.class, MySecured.Descriptor.class)
+            .execute("param1", "param2");
+
+It's also possible do register different callback-types per view-meta-data. An example can be found at `ViewControllerRef` which registers different callback-types for `InitView`, `PreViewAction`, `PreRenderView` and `PostRenderView`. In this case it's needed to use the type of the callback (= class of the annotation) as additional parameter for `#getExecutableCallbackDescriptor`.
+
+Creating Custom inline Meta-Data via @InlineViewMetaData
+This annotation can be used for view-meta-data which can be placed on other classes than view-config-classes. It's used e.g. for `@ViewRef`.
+Via a `TargetViewConfigProvider` it's possible to point to the view-config the meta-data should get applied to and via `InlineMetaDataTransformer` it's possible to convert it to a different meta-data-representation (which allows that at runtime you only have to support one side since the inline-meta-data was converted to the same meta-data representation which is used for the normal view-meta-data).
 
 ## View-Config SPI
 [TODO]