1. Project Clover database Fri Apr 29 2016 13:24:33 CEST
  2. Package info.magnolia.module.blossom.annotation

File Template.java

 

Code metrics

0
0
0
1
153
19
0
-
-
0
-

Classes

Class Line # Actions
Template 99 0 - 0 0
-1.0 -
 

Contributing tests

No tests hitting this source file were found.

Source view

1    /**
2    * This file Copyright (c) 2010-2016 Magnolia International
3    * Ltd. (http://www.magnolia-cms.com). All rights reserved.
4    *
5    *
6    * This file is dual-licensed under both the Magnolia
7    * Network Agreement and the GNU General Public License.
8    * You may elect to use one or the other of these licenses.
9    *
10    * This file is distributed in the hope that it will be
11    * useful, but AS-IS and WITHOUT ANY WARRANTY; without even the
12    * implied warranty of MERCHANTABILITY or FITNESS FOR A
13    * PARTICULAR PURPOSE, TITLE, or NONINFRINGEMENT.
14    * Redistribution, except as permitted by whichever of the GPL
15    * or MNA you select, is prohibited.
16    *
17    * 1. For the GPL license (GPL), you can redistribute and/or
18    * modify this file under the terms of the GNU General
19    * Public License, Version 3, as published by the Free Software
20    * Foundation. You should have received a copy of the GNU
21    * General Public License, Version 3 along with this program;
22    * if not, write to the Free Software Foundation, Inc., 51
23    * Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
24    *
25    * 2. For the Magnolia Network Agreement (MNA), this file
26    * and the accompanying materials are made available under the
27    * terms of the MNA which accompanies this distribution, and
28    * is available at http://www.magnolia-cms.com/mna.html
29    *
30    * Any modifications to this file must keep this entire header
31    * intact.
32    *
33    */
34    package info.magnolia.module.blossom.annotation;
35   
36    import info.magnolia.rendering.template.type.DefaultTemplateTypes;
37   
38    import java.lang.annotation.ElementType;
39    import java.lang.annotation.Retention;
40    import java.lang.annotation.RetentionPolicy;
41    import java.lang.annotation.Target;
42   
43    /**
44    * Used on a Spring Web MVC controller to expose it as a template. A template is either used to render a page or a
45    * component.
46    * <p/>
47    * The title of the template is set with this annotation while the description is set using
48    * {@link info.magnolia.module.blossom.annotation.TemplateDescription}.
49    * <p/>
50    * A component is added to a page using a dialog. A controller that uses this annotation automatically becomes a factory
51    * for its dialog. This dialog is automatically assigned an id and you do not need to add the
52    * {@link info.magnolia.module.blossom.annotation.DialogFactory} annotation. The functionality for creating the dialog
53    * is identical to the functionality of classes that use {@link info.magnolia.module.blossom.annotation.DialogFactory}.
54    * More specifically you can use {@link TabFactory} and {@link TabOrder}.
55    * <p/>
56    * If you prefer using a dialog created by a {@link DialogFactory} or one configured in Magnolia you can override this
57    * behaviour by setting the 'dialog' field.
58    * <p/>
59    * The class will also be scanned for methods annotated with {@link DialogFactory}. This makes it possible to declare
60    * dialogs in the same template that they're used for.
61    * <p/>
62    * It is possible to restrict on which pages a template can be used by using the
63    * {@link info.magnolia.module.blossom.annotation.Available} annotation.
64    * <p/>
65    * You can use {@link info.magnolia.module.blossom.annotation.I18nBasename} to specify which resource bundle should be
66    * used for localization of the template's title and description.
67    * <p/>
68    * For example this template will be exposed with the id "mainTemplate":
69    * <pre>
70    * &#64;Controller
71    * &#64;Template(title = "Main", id = "moduleName:pages/main")
72    * public class MainTemplate {
73    *
74    * &#64;RequestMapping("/mainTemplate")
75    * public String render() {
76    * return "mainTemplate.jsp";
77    * }
78    *
79    * &#64;TabFactory("Content")
80    * public void contentTab(UiConfig cfg, TabBuilder tab) {
81    * tab.fields(cfg.fields.richText("body").label("Text"));
82    * }
83    * }
84    * </pre>
85    *
86    * @see info.magnolia.module.blossom.annotation.TemplateDescription
87    * @see info.magnolia.module.blossom.annotation.Area
88    * @see info.magnolia.module.blossom.annotation.TabOrder
89    * @see info.magnolia.module.blossom.annotation.TabFactory
90    * @see info.magnolia.module.blossom.annotation.Available
91    * @see info.magnolia.module.blossom.annotation.I18nBasename
92    * @see info.magnolia.module.blossom.annotation.DialogFactory
93    * @see info.magnolia.module.blossom.annotation.TemplateParam
94    * @see info.magnolia.module.blossom.annotation.TemplateParams
95    * @since 1.0
96    */
97    @Retention(RetentionPolicy.RUNTIME)
98    @Target(ElementType.TYPE)
 
99    public @interface Template {
100   
101    /**
102    * Id of the template. Templates intended to be used for pages must have an id in the format
103    * <code>&lt;moduleName&gt;:pages/*</code> or if it's intended to be a component
104    * <code>&lt;moduleName&gt;:components/*</code>. For example: <code>myModule:pages/mainTemplate</code> and
105    * <code>myModule:components/textAndImage</code>.
106    */
107    String id();
108   
109    /**
110    * Title of the template.
111    */
112    String title() default "";
113   
114    /**
115    * Id of a dialog to be used for this template. By default the controller itself will be responsible for
116    * creating the dialog.
117    */
118    String dialog() default "";
119   
120    /**
121    * Defines the visibility of the template. When set to false the template is never presented in the user interface.
122    * This is useful for templates that are only used for pages that are created by scheduled jobs rather than by
123    * editors.
124    */
125    boolean visible() default true;
126   
127    /**
128    * Specifies the template type, e.g. "home", "section", etc.
129    *
130    * @see info.magnolia.rendering.template.type.DefaultTemplateTypes
131    */
132    String type() default DefaultTemplateTypes.CONTENT;
133   
134    /**
135    * Specifies the template subtype, such as specific features, e.g. "news", etc.
136    */
137    String subtype() default "";
138   
139    /**
140    * Specifies whether a component can be changed.
141    */
142    TernaryBoolean writable() default TernaryBoolean.UNSPECIFIED;
143   
144    /**
145    * Specifies whether a component can be moved.
146    */
147    TernaryBoolean moveable() default TernaryBoolean.UNSPECIFIED;
148   
149    /**
150    * Specifies whether a component can be deleted.
151    */
152    TernaryBoolean deletable() default TernaryBoolean.UNSPECIFIED;
153    }