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     * The index of the column of a sheet. This index means the position of the rendered column. It can differ, if there
37     * are tc:column with rendered=false.
38     */
39    COLUMN_INDEX("data-tobago-column-index"),
40  
41    /**
42     * Custom command attribute. Is used to mark different client side JavaScript buttons.
43     * Should only contain the command name as a keyword, for security reasons.
44     */
45    COMMAND("data-tobago-command"),
46  
47    /**
48     * The list of commands attached to an element.
49     */
50    COMMANDS("data-tobago-commands"),
51  
52    /**
53     * The context path of the application, may be needed in the Client.
54     */
55    CONTEXT_PATH("data-tobago-context-path"),
56  
57    DATE_TIME_I18N("data-tobago-date-time-i18n"),
58  
59    /**
60     * Holds the day of a calendar control.
61     */
62    DAY("data-tobago-day"),
63  
64    /**
65     * Custom disabled attribute. Use for element, that don't have the disabled attribute.
66     */
67    DISABLED("data-tobago-disabled"),
68  
69    DISMISS("data-dismiss"),
70  
71    /**
72     * Custom form attribute. Used to show the virtual form of the component.
73     */
74    DEFAULT("data-tobago-default"),
75  
76    DELAY("data-tobago-delay"),
77  
78    FOR("data-tobago-for"),
79  
80    /**
81     * Holds the id of the first row in a sheet.
82     */
83    FIRST("data-tobago-first"),
84  
85    /*
86     * Holds the index of the row in a sheet, if the sheed has a rowRendered attribute.
87     */
88    ROW_INDEX("data-tobago-row-index"),
89  
90    /**
91     * Holds the first day of a week of a calendar control.
92     */
93    FIRST_DAY_OF_WEEK("data-tobago-first-day-of-week"),
94  
95    /**
96     * Defines a maximum value.
97     */
98    LAYOUT("data-tobago-layout"),
99  
100   /**
101    * Defines a maximum value.
102    */
103   MAX("data-tobago-max"),
104 
105   /**
106    * Holds the month of a calendar control.
107    */
108   MONTH("data-tobago-month"),
109 
110   /**
111    * Holds the names of the months of a calendar control.
112    */
113   MONTH_NAMES("data-tobago-month-names"),
114 
115   PARTIAL_IDS("data-tobago-partial-ids"),
116 
117   PARTIAL_ACTION("data-tobago-partial-action"),
118 
119   /**
120    * Custom attribute to describe a pattern, e. g. for an date input field.
121    */
122   PATTERN("data-tobago-pattern"),
123 
124   /**
125    * Custom reload attribute. Used to reload a panel.
126    */
127   RELOAD("data-tobago-reload"),
128 
129   ROW_ACTION("data-tobago-row-action"),
130 
131   SELECTION_MODE("data-tobago-selection-mode"),
132 
133   /**
134    * The selectable attribute e. g. for trees.
135    */
136   SELECTABLE("data-tobago-selectable"),
137 
138   /**
139    * Reference to a sheet.
140    */
141   SHEET_ID("data-tobago-sheet-id"),
142 
143   /**
144    * Alternate to the src attribute, icon open and close.
145    */
146   SRC_CLOSED("data-tobago-src-closed"),
147 
148   /**
149    * Alternate to the src attribute, icon open and close.
150    */
151   SRC_OPEN("data-tobago-src-open"),
152 
153   /**
154    * A way to transport style data in JSON format to the browser. With CSP the normal style attribute isn't allowed.
155    */
156   STYLE("data-tobago-style"),
157 
158   SCROLL_PANEL("data-tobago-scroll-panel"),
159 
160   SCROLL_POSITION("data-tobago-scroll-position"),
161 
162   SUGGEST_DATA("data-tobago-suggest-data"),
163 
164   SUGGEST_DELAY("data-tobago-suggest-delay"),
165 
166   SUGGEST_FOR("data-tobago-suggest-for"),
167 
168   SUGGEST_MAX_ITEMS("data-tobago-suggest-max-items"),
169 
170   SUGGEST_MIN_CHARS("data-tobago-suggest-min-chars"),
171 
172   SUGGEST_TOTAL_COUNT("data-tobago-suggest-total-count"),
173 
174   SUGGEST_UPDATE("data-tobago-suggest-update"),
175 
176   TARGET("data-target"),
177 
178   TO_PAGE("data-tobago-to-page"),
179 
180   TOGGLE("data-toggle"),
181 
182   TRANSITION("data-tobago-transition"),
183 
184   /**
185    * Id of the parent node in a tree node.
186    */
187   TREE_PARENT("data-tobago-tree-parent"),
188 
189   /**
190    * Defines the unit, e. g. to differ between hours, minutes and seconds in a time control.
191    */
192   UNIT("data-tobago-unit"),
193 
194   /**
195    * Holds the value (for tags, that don't have a value in HTML).
196    */
197   VALUE("data-tobago-value"),
198 
199   /**
200    * Holds the year of a calendar control.
201    */
202   YEAR("data-tobago-year");
203 
204   private final String value;
205 
206   DataAttributes(String value) {
207     this.value = value;
208   }
209 
210   @Override
211   public String getValue() {
212     return value;
213   }
214 
215   public static MarkupLanguageAttributes dynamic(final String withoutPrefix) {
216     return new MarkupLanguageAttributes() {
217       @Override
218       public String getValue() {
219         return "data-" + withoutPrefix;
220       }
221     };
222   }
223 
224 }