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