001: /*
002: * Copyright 2004 The Apache Software Foundation.
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016:
017: package com.icesoft.faces.renderkit.dom_html_basic;
018:
019: import com.icesoft.faces.util.ArrayUtils;
020:
021: /**
022: * Constant declarations for HTML rendering.
023: *
024: * @author Manfred Geiler (latest modification by $Author: svieujot $)
025: * @author Anton Koinov
026: * @version * $Revision: 1.22 $ $Date: 2005/02/28 20:40:15 $ $Log: HTML.java,v
027: * $
028: */
029: /* Revision 1.22 2005/02/28 20:40:15 svieujot
030: * closed MYFACES-112
031: *
032: * Revision 1.21 2005/02/16 00:50:37 oros
033: * SF issue #1043331: replaced all by the corresponding numeric entity   so safari users will be happy, too, with MyFaces output
034: *
035: * Revision 1.20 2004/12/27 04:11:11 mmarinschek
036: * Data Table stores the state of facets of children; script tag is rendered with type attribute instead of language attribute, popup works better as a column in a data table
037: *
038: * Revision 1.19 2004/12/04 03:22:45 svieujot
039: * Bugfix for BR_ELEM
040: *
041: * Revision 1.18 2004/12/02 15:34:43 svieujot
042: * Add iframe attributes
043: *
044: * Revision 1.17 2004/12/02 15:22:06 svieujot
045: * Add IFRAME_ELEM
046: *
047: * Revision 1.16 2004/12/02 05:03:14 svieujot
048: * Add H1-6 elements
049: *
050: * Revision 1.15 2004/12/02 02:34:41 svieujot
051: * Add a BUTTON_ELEM
052: *
053: * Revision 1.14 2004/11/08 03:43:20 bdudney
054: * Added a div element. x:div to use, inserts a div with class or style attributes
055: *
056: * Revision 1.13 2004/10/13 11:51:01 matze
057: * renamed packages to org.apache
058: *
059: * Revision 1.12 2004/08/09 08:43:29 manolito
060: * bug #1004867 - h:message has duplicate attributes
061: *
062: * Revision 1.11 2004/07/27 06:32:19 tinytoony
063: * new calendar component as a popup
064: *
065: * Revision 1.10 2004/07/26 09:19:08 manolito
066: * removed onclick from passthrough attributes for ButtonRenderer
067: *
068: * Revision 1.9 2004/07/01 22:00:56 mwessendorf
069: * ASF switch
070: *
071: * Revision 1.8 2004/06/04 00:26:16 o_rossmueller
072: * modified renderes to comply with JSF 1.1
073: *
074: * Revision 1.7 2004/05/29 10:19:55 mwessendorf
075: * made the class FINAL, because has only one private const
076: *
077: * Revision 1.6 2004/05/18 14:31:39 manolito
078: * user role support completely moved to components source tree
079: *
080: * Revision 1.5 2004/05/18 11:58:16 manolito
081: * typing error fixed
082: *
083: */
084: public final class HTML {
085:
086: private HTML() {
087: // disable instantiation
088: }
089:
090: // Common attributes
091: public static final String ALIGN_ATTR = "align";
092: public static final String DATAFLD_ATTR = "datafld";
093: public static final String DATASRC_ATTR = "datasrc";
094: public static final String DATAFORMATAS_ATTR = "dataformatas";
095: public static final String BORDER_ATTR = "border";
096: public static final String WIDTH_ATTR = "width";
097: public static final String READONLY_ATTR = "readonly";
098: public static final String ACCEPT_ATTR = "accept";
099:
100: // Common event handler attributes
101: public static final String ONCLICK_ATTR = "onclick";
102: public static final String ONDBLCLICK_ATTR = "ondblclick";
103: public static final String ONMOUSEDOWN_ATTR = "onmousedown";
104: public static final String ONMOUSEUP_ATTR = "onmouseup";
105: public static final String ONMOUSEOVER_ATTR = "onmouseover";
106: public static final String ONMOUSEMOVE_ATTR = "onmousemove";
107: public static final String ONMOUSEOUT_ATTR = "onmouseout";
108: public static final String ONKEYPRESS_ATTR = "onkeypress";
109: public static final String ONKEYDOWN_ATTR = "onkeydown";
110: public static final String ONKEYUP_ATTR = "onkeyup";
111: public static final String[] EVENT_HANDLER_ATTRIBUTES_WITHOUT_ONCLICK = {
112: ONDBLCLICK_ATTR, ONMOUSEDOWN_ATTR, ONMOUSEUP_ATTR,
113: ONMOUSEOVER_ATTR, ONMOUSEMOVE_ATTR, ONMOUSEOUT_ATTR,
114: ONKEYPRESS_ATTR, ONKEYDOWN_ATTR, ONKEYUP_ATTR };
115: public static final String[] EVENT_HANDLER_ATTRIBUTES = (String[]) ArrayUtils
116: .concat(EVENT_HANDLER_ATTRIBUTES_WITHOUT_ONCLICK,
117: new String[] { ONCLICK_ATTR });
118:
119: // Input field event handler attributes
120: public static final String ONFOCUS_ATTR = "onfocus";
121: public static final String ONBLUR_ATTR = "onblur";
122: public static final String ONSELECT_ATTR = "onselect";
123: public static final String ONCHANGE_ATTR = "onchange";
124: public static final String[] COMMON_FIELD_EVENT_ATTRIBUTES = {
125: ONFOCUS_ATTR, ONBLUR_ATTR, ONSELECT_ATTR, ONCHANGE_ATTR };
126:
127: // universal attributes
128: public static final String DIR_ATTR = "dir";
129: public static final String LANG_ATTR = "lang";
130: public static final String STYLE_ATTR = "style";
131: public static final String TITLE_ATTR = "title";
132: public static final String STYLE_CLASS_ATTR = "styleClass"; //"class" cannot be used as property name
133: public static final String[] UNIVERSAL_ATTRIBUTES_WITHOUT_STYLE = {
134: DIR_ATTR, LANG_ATTR, TITLE_ATTR,
135:
136: //NOTE: if changed, please verify universal attributes in HtmlMessageRenderer !
137: };
138: public static final String[] UNIVERSAL_ATTRIBUTES = (String[]) ArrayUtils
139: .concat(UNIVERSAL_ATTRIBUTES_WITHOUT_STYLE, new String[] {
140: STYLE_ATTR, STYLE_CLASS_ATTR });
141:
142: //universal, but not the same property-name -
143: //styleClass attribute is rendered as such
144: public static final String CLASS_ATTR = "class";
145:
146: // common form field attributes
147: public static final String ACCESSKEY_ATTR = "accesskey";
148: public static final String TABINDEX_ATTR = "tabindex";
149: public static final String DISABLED_ATTR = "disabled";
150: public static final String[] COMMON_FIELD_ATTRIBUTES_WITHOUT_DISABLED = {
151: ACCESSKEY_ATTR, TABINDEX_ATTR };
152: public static final String[] COMMON_FIELD_ATTRIBUTES = (String[]) ArrayUtils
153: .concat(COMMON_FIELD_ATTRIBUTES_WITHOUT_DISABLED,
154: new String[] { DISABLED_ATTR });
155:
156: // Common Attributes
157: public static final String[] COMMON_PASSTROUGH_ATTRIBUTES = (String[]) ArrayUtils
158: .concat(EVENT_HANDLER_ATTRIBUTES, UNIVERSAL_ATTRIBUTES);
159: public static final String[] COMMON_PASSTROUGH_ATTRIBUTES_WITHOUT_STYLE = (String[]) ArrayUtils
160: .concat(EVENT_HANDLER_ATTRIBUTES,
161: UNIVERSAL_ATTRIBUTES_WITHOUT_STYLE);
162: public static final String[] COMMON_PASSTROUGH_ATTRIBUTES_WITHOUT_ONCLICK = (String[]) ArrayUtils
163: .concat(EVENT_HANDLER_ATTRIBUTES_WITHOUT_ONCLICK,
164: UNIVERSAL_ATTRIBUTES);
165: public static final String[] COMMON_FIELD_PASSTROUGH_ATTRIBUTES_WITHOUT_DISABLED = (String[]) ArrayUtils
166: .concat(COMMON_PASSTROUGH_ATTRIBUTES,
167: COMMON_FIELD_ATTRIBUTES_WITHOUT_DISABLED,
168: COMMON_FIELD_EVENT_ATTRIBUTES);
169: public static final String[] COMMON_FIELD_PASSTROUGH_ATTRIBUTES_WITHOUT_DISABLED_AND_ONCLICK = (String[]) ArrayUtils
170: .concat(COMMON_PASSTROUGH_ATTRIBUTES_WITHOUT_ONCLICK,
171: COMMON_FIELD_ATTRIBUTES_WITHOUT_DISABLED,
172: COMMON_FIELD_EVENT_ATTRIBUTES);
173:
174: // <a>
175: public static final String TARGET_ATTR = "target"; //used by <a> and <form>
176: public static final String CHARSET_ATTR = "charset";
177: public static final String COORDS_ATTR = "coords";
178: public static final String HREF_ATTR = "href";
179: public static final String HREFLANG_ATTR = "hreflang";
180: public static final String REL_ATTR = "rel";
181: public static final String REV_ATTR = "rev";
182: public static final String SHAPE_ATTR = "shape";
183: public static final String TYPE_ATTR = "type";
184: public static final String[] ANCHOR_ATTRIBUTES = { ACCESSKEY_ATTR,
185: CHARSET_ATTR, COORDS_ATTR, HREFLANG_ATTR, REL_ATTR,
186: REV_ATTR, SHAPE_ATTR, TABINDEX_ATTR, TARGET_ATTR, TYPE_ATTR };
187: public static final String[] ANCHOR_PASSTHROUGH_ATTRIBUTES = (String[]) ArrayUtils
188: .concat(ANCHOR_ATTRIBUTES, COMMON_PASSTROUGH_ATTRIBUTES);
189: public static final String[] ANCHOR_PASSTHROUGH_ATTRIBUTES_WITHOUT_STYLE = (String[]) ArrayUtils
190: .concat(ANCHOR_ATTRIBUTES,
191: COMMON_PASSTROUGH_ATTRIBUTES_WITHOUT_STYLE);
192:
193: // <form>
194: public static final String ACCEPT_CHARSET_ATTR = "accept-charset";
195: public static final String ENCTYPE_ATTR = "enctype";
196: public static final String ONRESET_ATTR = "onreset";
197: public static final String ONSUMBIT_ATTR = "onsubmit";
198: public static final String[] FORM_ATTRIBUTES = { ACCEPT_ATTR,
199: ACCEPT_CHARSET_ATTR, ENCTYPE_ATTR, ONRESET_ATTR,
200: ONSUMBIT_ATTR, TARGET_ATTR, };
201: public static final String[] FORM_PASSTHROUGH_ATTRIBUTES = (String[]) ArrayUtils
202: .concat(FORM_ATTRIBUTES, COMMON_PASSTROUGH_ATTRIBUTES);
203:
204: // values for enctype attribute
205: public static String ENCTYPE_MULTIPART_FORMDATA = "multipart/form-data";
206:
207: // <img>
208: public static final String SRC_ATTR = "src";
209: public static final String ALT_ATTR = "alt";
210: public static final String HEIGHT_ATTR = "height";
211: public static final String HSPACE_ATTR = "hspace";
212: public static final String ISMAP_ATTR = "ismap";
213: public static final String LONGDESC_ATTR = "longdesc";
214: public static final String USEMAP_ATTR = "usemap";
215: public static final String VSPACE_ATTR = "vspace";
216:
217: public static final String[] IMG_ATTRIBUTES = { ALIGN_ATTR,
218: ALT_ATTR, BORDER_ATTR, HEIGHT_ATTR, HSPACE_ATTR,
219: ISMAP_ATTR, LONGDESC_ATTR, USEMAP_ATTR, VSPACE_ATTR,
220: WIDTH_ATTR };
221: public static final String[] IMG_PASSTHROUGH_ATTRIBUTES = (String[]) ArrayUtils
222: .concat(IMG_ATTRIBUTES, COMMON_PASSTROUGH_ATTRIBUTES);
223:
224: // <input>
225: public static final String SIZE_ATTR = "size";
226: public static final String CHECKED_ATTR = "checked";
227: public static final String MAXLENGTH_ATTR = "maxlength";
228:
229: public static final String[] INPUT_ATTRIBUTES = { ALIGN_ATTR,
230: ALT_ATTR, CHECKED_ATTR, DATAFLD_ATTR, DATASRC_ATTR,
231: DATAFORMATAS_ATTR, MAXLENGTH_ATTR, READONLY_ATTR,
232: SIZE_ATTR, };
233: public static final String[] INPUT_PASSTHROUGH_ATTRIBUTES_WITHOUT_DISABLED = (String[]) ArrayUtils
234: .concat(INPUT_ATTRIBUTES,
235: COMMON_FIELD_PASSTROUGH_ATTRIBUTES_WITHOUT_DISABLED);
236:
237: //values for input-type attribute
238: public static final String INPUT_TYPE_SUBMIT = "submit";
239: public static final String INPUT_TYPE_IMAGE = "image";
240: public static final String INPUT_TYPE_HIDDEN = "hidden";
241: public static final String INPUT_TYPE_CHECKBOX = "checkbox";
242: public static final String INPUT_TYPE_PASSWORD = "password";
243: public static final String INPUT_TYPE_TEXT = "text";
244: public static final String INPUT_TYPE_RADIO = "radio";
245: public static final String INPUT_TYPE_FILE = "file";
246:
247: // <button>
248: public static final String[] BUTTON_ATTRIBUTES = { ALIGN_ATTR,
249: ALT_ATTR, DATAFLD_ATTR, DATASRC_ATTR, DATAFORMATAS_ATTR, };
250: public static final String[] BUTTON_PASSTHROUGH_ATTRIBUTES_WITHOUT_DISABLED = (String[]) ArrayUtils
251: .concat(BUTTON_ATTRIBUTES,
252: COMMON_FIELD_PASSTROUGH_ATTRIBUTES_WITHOUT_DISABLED);
253: public static final String[] BUTTON_PASSTHROUGH_ATTRIBUTES_WITHOUT_DISABLED_AND_ONCLICK = (String[]) ArrayUtils
254: .concat(BUTTON_ATTRIBUTES,
255: COMMON_FIELD_PASSTROUGH_ATTRIBUTES_WITHOUT_DISABLED_AND_ONCLICK);
256:
257: // <iframe>
258: public static final String FRAMEBORDER_ATTR = "frameborder";
259: public static final String SCROLLING_ATTR = "scrolling";
260:
261: // <label>
262: public static final String FOR_ATTR = "for";
263: public static final String[] LABEL_ATTRIBUTES = { ACCESSKEY_ATTR,
264: ONBLUR_ATTR, ONFOCUS_ATTR
265: //FOR_ATTR is no pass through !
266: };
267: public static final String[] LABEL_PASSTHROUGH_ATTRIBUTES = (String[]) ArrayUtils
268: .concat(LABEL_ATTRIBUTES, COMMON_PASSTROUGH_ATTRIBUTES);
269:
270: // <select>
271: public static final String MULTIPLE_ATTR = "multiple";
272:
273: public static final String[] SELECT_ATTRIBUTES = { DATAFLD_ATTR,
274: DATASRC_ATTR, DATAFORMATAS_ATTR, };
275: public static final String[] SELECT_PASSTHROUGH_ATTRIBUTES_WITHOUT_DISABLED = (String[]) ArrayUtils
276: .concat(SELECT_ATTRIBUTES,
277: COMMON_FIELD_PASSTROUGH_ATTRIBUTES_WITHOUT_DISABLED);
278:
279: // <table>
280: public static final String BGCOLOR_ATTR = "bgcolor";
281: public static final String CELLPADDING_ATTR = "cellpadding";
282: public static final String CELLSPACING_ATTR = "cellspacing";
283: public static final String FRAME_ATTR = "frame";
284: public static final String RULES_ATTR = "rules";
285: public static final String SUMMARY_ATTR = "summary";
286: public static final String[] TABLE_ATTRIBUTES = { ALIGN_ATTR,
287: BGCOLOR_ATTR, BORDER_ATTR, CELLPADDING_ATTR,
288: CELLSPACING_ATTR, DATAFLD_ATTR, DATASRC_ATTR,
289: DATAFORMATAS_ATTR, FRAME_ATTR, RULES_ATTR, HEIGHT_ATTR,
290: SUMMARY_ATTR, WIDTH_ATTR };
291: public static final String[] TABLE_PASSTHROUGH_ATTRIBUTES = (String[]) ArrayUtils
292: .concat(TABLE_ATTRIBUTES, COMMON_PASSTROUGH_ATTRIBUTES);
293:
294: // <textarea>
295: public static final String COLS_ATTR = "cols";
296: public static final String ROWS_ATTR = "rows";
297: public static final String[] TEXTAREA_ATTRIBUTES = { COLS_ATTR,
298: DATAFLD_ATTR, DATASRC_ATTR, DATAFORMATAS_ATTR,
299: READONLY_ATTR, ROWS_ATTR, };
300: public static final String[] TEXTAREA_PASSTHROUGH_ATTRIBUTES_WITHOUT_DISABLED = (String[]) ArrayUtils
301: .concat(TEXTAREA_ATTRIBUTES,
302: COMMON_FIELD_PASSTROUGH_ATTRIBUTES_WITHOUT_DISABLED);
303:
304: // <input type=file>
305: public static final String[] INPUT_FILE_UPLOAD_ATTRIBUTES = { ACCEPT_ATTR };
306: public static final String[] INPUT_FILE_PASSTHROUGH_ATTRIBUTES_WITHOUT_DISABLED = (String[]) ArrayUtils
307: .concat(INPUT_FILE_UPLOAD_ATTRIBUTES,
308: INPUT_PASSTHROUGH_ATTRIBUTES_WITHOUT_DISABLED);
309:
310: /*
311: public static final String[] MESSAGE_PASSTHROUGH_ATTRIBUTES =
312: (String[]) ArrayUtils.concat(
313: new String[] {DIR_ATTR, LANG_ATTR, TITLE_ATTR, STYLE_ATTR, STYLE_CLASS_ATTR},
314: EVENT_HANDLER_ATTRIBUTES);
315: */
316:
317: public static final String[] MESSAGE_PASSTHROUGH_ATTRIBUTES_WITHOUT_TITLE_STYLE_AND_STYLE_CLASS = (String[]) ArrayUtils
318: .concat(new String[] { DIR_ATTR, LANG_ATTR },
319: EVENT_HANDLER_ATTRIBUTES);
320:
321: // selectOne/Many table
322: public static final String[] SELECT_TABLE_PASSTHROUGH_ATTRIBUTES = new String[] {
323: STYLE_ATTR, STYLE_CLASS_ATTR, BORDER_ATTR };
324:
325: //HTML attributes needed for renderding only
326: public static final String ID_ATTR = "id";
327: public static final String NAME_ATTR = "name";
328: public static final String VALUE_ATTR = "value";
329: public static final String METHOD_ATTR = "method";
330: public static final String ACTION_ATTR = "action";
331: public static final String COLSPAN_ATTR = "colspan";
332: public static final String SCOPE_ATTR = "scope";
333: public static final String LABEL_ATTR = "label";
334: public static final String SELECTED_ATTR = "selected";
335:
336: //HTML attributes values
337: public static final String SCOPE_COLGROUP_VALUE = "colgroup";
338:
339: //HTML element constants
340: public static final String SPAN_ELEM = "span";
341: public static final String DIV_ELEM = "div";
342: public static final String INPUT_ELEM = "input";
343: public static final String BUTTON_ELEM = "button";
344: public static final String SELECT_ELEM = "select";
345: public static final String OPTION_ELEM = "option";
346: public static final String OPTGROUP_ELEM = "optgroup";
347: public static final String TEXTAREA_ELEM = "textarea";
348: public static final String FORM_ELEM = "form";
349: public static final String ANCHOR_ELEM = "a";
350: public static final String H1_ELEM = "h1";
351: public static final String H2_ELEM = "h2";
352: public static final String H3_ELEM = "h3";
353: public static final String H4_ELEM = "h4";
354: public static final String H5_ELEM = "h5";
355: public static final String H6_ELEM = "h6";
356: public static final String IFRAME_ELEM = "iframe";
357: public static final String IMG_ELEM = "img";
358: public static final String LABEL_ELEM = "label";
359: public static final String TABLE_ELEM = "table";
360: public static final String TR_ELEM = "tr";
361: public static final String TH_ELEM = "th";
362: public static final String TD_ELEM = "td";
363: public static final String TBODY_ELEM = "tbody";
364: public static final String TFOOT_ELEM = "tfoot";
365: public static final String THEAD_ELEM = "thead";
366: public static final String STYLE_ELEM = "style";
367: public static final String SCRIPT_ELEM = "script";
368: public static final String SCRIPT_TYPE_ATTR = "type";
369: public static final String SCRIPT_TYPE_TEXT_JAVASCRIPT = "text/javascript";
370: public static final String SCRIPT_LANGUAGE_ATTR = "language";
371: public static final String SCRIPT_LANGUAGE_JAVASCRIPT = "JavaScript";
372: public static final String MAP_ELEM = "map";
373: public static final String UL_ELEM = "ul";
374: public static final String OL_ELEM = "ol";
375: public static final String LI_ELEM = "li";
376:
377: //HTML simple element constants
378: public static final String BR_ELEM = "br";
379:
380: //HTML entities
381: public static final String NBSP_ENTITY = " ";
382:
383: public static final String HREF_PATH_SEPARATOR = "/";
384: public static final String HREF_PATH_FROM_PARAM_SEPARATOR = "?";
385: public static final String HREF_PARAM_SEPARATOR = "&";
386: public static final String HREF_PARAM_NAME_FROM_VALUE_SEPARATOR = "=";
387:
388: }
|