View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  
20  package org.apache.myfaces.tobago.renderkit.html;
21  
22  /**
23   * Custom data attributes.
24   * These attributes may transport data to DOM which are not standardized.
25   * The format is "data-tobago-*" which is conform to HTML 5, but also works in older browsers.
26   */
27  public enum DataAttributes implements MarkupLanguageAttributes {
28  
29    /**
30     * Ajax behaviors execute and render attributes for TabGroup and Sheet reload
31     * @deprecated please use COMMANDS
32     */
33    BEHAVIOR_COMMANDS("data-tobago-behavior-commands"),
34  
35    /**
36     * Contains the closed tree icon or style.
37     */
38    CLOSED("data-tobago-closed"),
39  
40    /**
41     * The index of the column of a sheet. This index means the position of the rendered column. It can differ, if there
42     * are tc:column with rendered=false.
43     */
44    COLUMN_INDEX("data-tobago-column-index"),
45  
46    /**
47     * Custom command attribute. Is used to mark different client side JavaScript buttons.
48     * Should only contain the command name as a keyword, for security reasons.
49     */
50    COMMAND("data-tobago-command"),
51  
52    /**
53     * The list of commands attached to an element.
54     */
55    COMMANDS("data-tobago-commands"),
56  
57    CONTENT("data-content"),
58  
59    /**
60     * The context path of the application, may be needed in the Client.
61     */
62    CONTEXT_PATH("data-tobago-context-path"),
63  
64    DATE_TIME_I18N("data-tobago-date-time-i18n"),
65  
66    /**
67     * Holds the day of a calendar control.
68     */
69    DAY("data-tobago-day"),
70  
71    /**
72     * Custom disabled attribute. Use for element, that don't have the disabled attribute.
73     */
74    DISABLED("data-tobago-disabled"),
75  
76    DISMISS("data-dismiss"),
77  
78    /**
79     * Custom form attribute. Used to show the virtual form of the component.
80     */
81    DEFAULT("data-tobago-default"),
82  
83    DELAY("data-tobago-delay"),
84  
85    FOR("data-tobago-for"),
86  
87    /**
88     * Holds the id of the first row in a sheet.
89     */
90    FIRST("data-tobago-first"),
91  
92    /**
93     * Holds the first day of a week of a calendar control.
94     */
95    FIRST_DAY_OF_WEEK("data-tobago-first-day-of-week"),
96  
97    /**
98     * Defines a maximum value.
99     */
100   LAYOUT("data-tobago-layout"),
101 
102   /**
103    * Defines the depth level of a tree node.
104    */
105   LEVEL("data-tobago-level"),
106 
107   /**
108    * Defines a maximum value.
109    */
110   MAX("data-tobago-max"),
111 
112   /**
113    * Holds the month of a calendar control.
114    */
115   MONTH("data-tobago-month"),
116 
117   /**
118    * Holds the names of the months of a calendar control.
119    */
120   MONTH_NAMES("data-tobago-month-names"),
121 
122   /**
123    * Contains the open tree icon or style.
124    */
125   OPEN("data-tobago-open"),
126 
127   PARTIAL_IDS("data-tobago-partial-ids"),
128 
129   PARTIAL_ACTION("data-tobago-partial-action"),
130 
131   /**
132    * Custom attribute to describe a pattern, e. g. for an date input field.
133    */
134   PATTERN("data-tobago-pattern"),
135 
136   /**
137    * Custom reload attribute. Used to reload a panel.
138    */
139   RELOAD("data-tobago-reload"),
140 
141   ROW_ACTION("data-tobago-row-action"),
142 
143   /*
144    * Holds the index of the row in a sheet, if the sheed has a rowRendered attribute.
145    */
146   ROW_INDEX("data-tobago-row-index"),
147 
148   SELECTION_MODE("data-tobago-selection-mode"),
149 
150   /**
151    * The selectable attribute e. g. for trees.
152    */
153   SELECTABLE("data-tobago-selectable"),
154 
155   /**
156    * Reference to a sheet.
157    */
158   SHEET_ID("data-tobago-sheet-id"),
159 
160   /**
161    * A way to transport style data in JSON format to the browser. With CSP the normal style attribute isn't allowed.
162    * @deprecated since 4.0.0. UIStyle now renders itself.
163    */
164   @Deprecated
165   STYLE("data-tobago-style"),
166 
167   SCROLL_PANEL("data-tobago-scroll-panel"),
168 
169   SCROLL_POSITION("data-tobago-scroll-position"),
170 
171   SUGGEST_DATA("data-tobago-suggest-data"),
172 
173   SUGGEST_DELAY("data-tobago-suggest-delay"),
174 
175   SUGGEST_FOR("data-tobago-suggest-for"),
176 
177   SUGGEST_MAX_ITEMS("data-tobago-suggest-max-items"),
178 
179   SUGGEST_MIN_CHARS("data-tobago-suggest-min-chars"),
180 
181   SUGGEST_TOTAL_COUNT("data-tobago-suggest-total-count"),
182 
183   SUGGEST_UPDATE("data-tobago-suggest-update"),
184 
185   TARGET("data-target"),
186 
187   TITLE("data-title"),
188 
189   TO_PAGE("data-tobago-to-page"),
190 
191   TODAY("data-tobago-today"),
192 
193   TOGGLE("data-toggle"),
194 
195   TRANSITION("data-tobago-transition"),
196 
197   /**
198    * Id of the parent node in a tree node.
199    */
200   TREE_PARENT("data-tobago-tree-parent"),
201 
202   /**
203    * Defines the unit, e. g. to differ between hours, minutes and seconds in a time control.
204    */
205   UNIT("data-tobago-unit"),
206 
207   /**
208    * Holds the value (for tags, that don't have a value in HTML).
209    */
210   VALUE("data-tobago-value"),
211 
212   /**
213    * Holds the year of a calendar control.
214    */
215   YEAR("data-tobago-year");
216 
217   private final String value;
218 
219   DataAttributes(String value) {
220     this.value = value;
221   }
222 
223   @Override
224   public String getValue() {
225     return value;
226   }
227 
228   public static MarkupLanguageAttributes dynamic(final String withoutPrefix) {
229     return new MarkupLanguageAttributes() {
230       @Override
231       public String getValue() {
232         return "data-" + withoutPrefix;
233       }
234     };
235   }
236 
237 }