From richfaces-svn-commits at lists.jboss.org Wed Sep 8 15:14:50 2010 Content-Type: multipart/mixed; boundary="===============8486541039917368506==" MIME-Version: 1.0 From: richfaces-svn-commits at lists.jboss.org To: richfaces-svn-commits at lists.jboss.org Subject: [richfaces-svn-commits] JBoss Rich Faces SVN: r19137 - in trunk/core: api/src/test/java/org/ajax4jsf/javascript and 5 other directories. Date: Wed, 08 Sep 2010 15:14:50 -0400 Message-ID: <201009081914.o88JEo7Y019812@svn01.web.mwc.hst.phx2.redhat.com> --===============8486541039917368506== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: nbelaevski Date: 2010-09-08 15:14:49 -0400 (Wed, 08 Sep 2010) New Revision: 19137 Added: trunk/core/api/src/test/java/org/richfaces/renderkit/ trunk/core/api/src/test/java/org/richfaces/renderkit/util/ trunk/core/api/src/test/java/org/richfaces/renderkit/util/IdSplitBuilder= Test.java Removed: trunk/core/impl/src/main/java/org/richfaces/renderkit/util/AjaxRendererU= tils.java trunk/core/impl/src/main/java/org/richfaces/renderkit/util/IdSplitBuilde= r.java trunk/core/impl/src/main/java/org/richfaces/renderkit/util/RendererUtils= .java trunk/core/impl/src/test/java/org/richfaces/renderkit/util/ Modified: trunk/core/api/src/main/java/org/ajax4jsf/javascript/JSEncoder.java trunk/core/api/src/test/java/org/ajax4jsf/javascript/ScriptUtilsTest.java Log: RF-7560 - synchronized unmerged files Modified: trunk/core/api/src/main/java/org/ajax4jsf/javascript/JSEncoder.ja= va =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/core/api/src/main/java/org/ajax4jsf/javascript/JSEncoder.java 201= 0-09-08 17:07:06 UTC (rev 19136) +++ trunk/core/api/src/main/java/org/ajax4jsf/javascript/JSEncoder.java 201= 0-09-08 19:14:49 UTC (rev 19137) @@ -31,13 +31,14 @@ = // private char APOSTROPHE[] =3D { '\\', '\'' }; private static final char[] ENCODE_HEX =3D "0123456789ABCDEF".toCharAr= ray(); - private static final char[] ENCODE_APOS =3D "\\'".toCharArray(); private static final char[] ENCODE_QUOT =3D "\\\"".toCharArray(); private static final char[] ENCODE_LF =3D "\\n".toCharArray(); + private static final char[] ENCODE_BC =3D "\\b".toCharArray(); private static final char[] ENCODE_FF =3D "\\f".toCharArray(); private static final char[] ENCODE_CR =3D "\\r".toCharArray(); private static final char[] ENCODE_TAB =3D "\\t".toCharArray(); private static final char[] ENCODE_BS =3D "\\\\".toCharArray(); + private static final char[] ENCODE_FS =3D "\\/".toCharArray(); = // private static final char ENCODE_ESC[] =3D "\\e".toCharArray(); = @@ -47,32 +48,34 @@ public JSEncoder() {} = /** - * Return true or false wether this encoding can encode the specified + * Return true or false whether this encoding/format can encode the sp= ecified * character or not. *

* This method will return true for the following character range: * - * #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] + * \b | \f | \t | \r | \n | " | \ | / | [#x20-#xD7FF] | [#xE00= 0-#xFFFD] * *

* * @see W3C XML 1.0 = + * @see JSON.org */ public boolean compile(char c) { - if ((c =3D=3D 0x09) || // [\t] - (c =3D=3D 0x0a) || // [\n] - (c =3D=3D 0x0d) || // [\r](c =3D=3D 0x22) || // ["] - (c =3D=3D 0x22) || // ["] - (c =3D=3D 0x27) || // ['] - (c =3D=3D 0x5c) || // [\] - (c =3D=3D 0x03) || // [esc] - (c =3D=3D ']') || // ] - to avoid = conflicts in CDATA - (c =3D=3D '<') || // - escape HTML= markup characters - (c =3D=3D '>') || // - HTML - (c =3D=3D '&') || // - HTML - (c =3D=3D '-') || // - HTML commen= ts - (c < 0x20) || // See - ((c > 0xd7ff) && (c < 0xe000)) || = (c > 0xfffd) || (c > 0xff)) { + if ((c =3D=3D '\b') || + (c =3D=3D '\f') | + (c =3D=3D '\t') || + (c =3D=3D '\n') || + (c =3D=3D '\r') || + (c =3D=3D '"') || + (c =3D=3D '\\') || + (c =3D=3D '/') || + (c =3D=3D ']') || // ] - to av= oid conflicts in CDATA + (c =3D=3D '<') || // - escape = HTML markup characters + (c =3D=3D '>') || // - HTML + (c =3D=3D '&') || // - HTML + (c =3D=3D '-') || // - HTML co= mments + (c < 0x20) || // See + ((c > 0xd7ff) && (c < 0xe000))= || (c > 0xfffd) || (c > 0xff)) { return false; } = @@ -85,39 +88,36 @@ */ public char[] encode(char c) { switch (c) { - case 0x03 : - return ENCODE_FF; // (>) [>] + case '\b' : + return ENCODE_BC; + = + case '\f' : + return ENCODE_FF; = - case 0x09 : - return ENCODE_TAB; // (>) [>] + case '\t' : + return ENCODE_TAB; = - case 0x0a : - return ENCODE_LF; // (>) [>] + case '\n' : + return ENCODE_LF; = - case 0x0d : - return ENCODE_CR; // (>) [>] + case '\r' : + return ENCODE_CR; = - case 0x22 : - return ENCODE_QUOT; // (") ["] + case '"' : + return ENCODE_QUOT; = - case 0x27 : - return ENCODE_APOS; // (') ['] + case '\\' : + return ENCODE_BS; = - case 0x5c : - return ENCODE_BS; // (<) [<] - + case '/' : + return ENCODE_FS; + = default : { - if (c > 0xff) { - char[] ret =3D { - '\\', 'u', ENCODE_HEX[c >> 0xc & 0xf], ENCODE_HEX[= c >> 0x8 & 0xf], ENCODE_HEX[c >> 0x4 & 0xf], - ENCODE_HEX[c & 0xf] - }; + char[] ret =3D { + '\\', 'u', ENCODE_HEX[c >> 0xc & 0xf], ENCODE_HEX[c >>= 0x8 & 0xf], ENCODE_HEX[c >> 0x4 & 0xf], + ENCODE_HEX[c & 0xf] + }; = - return ret; - } - - char[] ret =3D {'\\', 'x', ENCODE_HEX[c >> 0x4 & 0xf], ENC= ODE_HEX[c & 0xf]}; - return ret; } } Modified: trunk/core/api/src/test/java/org/ajax4jsf/javascript/ScriptUtilsT= est.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/core/api/src/test/java/org/ajax4jsf/javascript/ScriptUtilsTest.ja= va 2010-09-08 17:07:06 UTC (rev 19136) +++ trunk/core/api/src/test/java/org/ajax4jsf/javascript/ScriptUtilsTest.ja= va 2010-09-08 19:14:49 UTC (rev 19137) @@ -123,9 +123,9 @@ * Test method for {@link org.ajax4jsf.javascript.ScriptUtils#toScript= (java.lang.Object)}. */ public void testStringToScript() { - Object obj =3D "foo"; + Object obj =3D "f \b\r\t\f\n\"'\\/ oo"; = - assertEquals("\"foo\"", ScriptUtils.toScript(obj)); + assertEquals("\"f \\b\\r\\t\\f\\n\\\"'\\\\\\/ oo\"", ScriptUtils.t= oScript(obj)); } = /** @@ -260,8 +260,8 @@ public void testAddEncoded() { StringBuilder buff =3D new StringBuilder(); = - ScriptUtils.addEncoded(buff, "foo\"\'"); - assertEquals("foo\\\"\\\'", buff.toString()); + ScriptUtils.addEncoded(buff, "foo"); + assertEquals("foo", buff.toString()); } = /** Copied: trunk/core/api/src/test/java/org/richfaces/renderkit/util/IdSplitBu= ilderTest.java (from rev 19136, trunk/core/impl/src/test/java/org/richfaces= /renderkit/util/IdSplitBuilderTest.java) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/core/api/src/test/java/org/richfaces/renderkit/util/IdSplitBuilde= rTest.java (rev 0) +++ trunk/core/api/src/test/java/org/richfaces/renderkit/util/IdSplitBuilde= rTest.java 2010-09-08 19:14:49 UTC (rev 19137) @@ -0,0 +1,81 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2010, Red Hat, Inc. and individual contributors + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ +package org.richfaces.renderkit.util; + +import static org.junit.Assert.assertArrayEquals; + +import org.junit.Test; +import org.richfaces.renderkit.util.IdSplitBuilder; + + +/** + * @author Nick Belaevski + * + */ +public class IdSplitBuilderTest { + + private static String[] asArray(String... strings) { + return strings; + } + + @Test + public void testEmptyString() throws Exception { + assertArrayEquals(asArray(), IdSplitBuilder.split("")); + assertArrayEquals(asArray(), IdSplitBuilder.split(" \r\t\n ")); + } + + @Test + public void testOneStrings() throws Exception { + assertArrayEquals(asArray("test"), IdSplitBuilder.split("test")); + assertArrayEquals(asArray("some:id"), IdSplitBuilder.split("some:i= d")); + assertArrayEquals(asArray("table:[1]"), IdSplitBuilder.split("tabl= e:[1]")); + assertArrayEquals(asArray("table:[1, 2]"), IdSplitBuilder.split("t= able:[1, 2]")); + assertArrayEquals(asArray("table:[1, 2]:nestedTable:[*]"), IdSplit= Builder.split("table:[1, 2]:nestedTable:[*]")); + assertArrayEquals(asArray("table:[1, 2]:[*]:group"), IdSplitBuilde= r.split("table:[1, 2]:[*]:group")); + assertArrayEquals(asArray("table:[1 2]:nestedTable:[*]"), IdSplitB= uilder.split("table:[1 2]:nestedTable:[*]")); + assertArrayEquals(asArray("table:[1 2]:[*]:group"), IdSplitBuilder= .split("table:[1 2]:[*]:group")); + } + + @Test + public void testTwoStrings() throws Exception { + assertArrayEquals(asArray("test", "abc"), IdSplitBuilder.split("te= st abc")); + assertArrayEquals(asArray("some:id", "form:table"), IdSplitBuilder= .split("some:id form:table")); + assertArrayEquals(asArray("test", "abc"), IdSplitBuilder.split("te= st, abc")); + assertArrayEquals(asArray("some:id", "form:table"), IdSplitBuilder= .split("some:id, form:table")); + + assertArrayEquals(asArray("test:[1 2 3]:abc", "form:[2]"), IdSplit= Builder.split("test:[1 2 3]:abc form:[2]")); + assertArrayEquals(asArray("[1 2]:some", "[3\t4]:id"), IdSplitBuil= der.split(" [1 2]:some [3\t4]:id ")); + } + + @Test + public void testSeveralStrings() throws Exception { + assertArrayEquals(asArray("test", "abc", "def", "ghi"), IdSplitBui= lder.split("test abc def ghi")); + assertArrayEquals(asArray("test:[1 2]abc", "def", "ghi"), IdSplit= Builder.split("test:[1 2]abc def ghi")); + assertArrayEquals(asArray("[1 2]abc", "[3, 4]def", "ghi[5 6 7]"), + IdSplitBuilder.split("[1 2]abc [3, 4]def ghi[5 6 7]")); + + assertArrayEquals( + asArray("test:[1 2]:abc", "table", "form:table:[ * ]:child"= , "extTable:[ 0, 3 ]:child:[1 8]:@header"), + IdSplitBuilder.split(" test:[1 2]:abc, table," + + " form:table:[ * ]:child, extTable:[ 0, 3 ]:child:[1 8]:@= header" )); + } +} Deleted: trunk/core/impl/src/main/java/org/richfaces/renderkit/util/AjaxRen= dererUtils.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/core/impl/src/main/java/org/richfaces/renderkit/util/AjaxRenderer= Utils.java 2010-09-08 17:07:06 UTC (rev 19136) +++ trunk/core/impl/src/main/java/org/richfaces/renderkit/util/AjaxRenderer= Utils.java 2010-09-08 19:14:49 UTC (rev 19137) @@ -1,1147 +0,0 @@ -/** - * License Agreement. - * - * Rich Faces - Natural Ajax for Java Server Faces (JSF) - * - * Copyright (C) 2007 Exadel, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License version 2.1 as published by the Free Software Foundation. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-130= 1 USA - */ - -package org.richfaces.renderkit.util; - -import java.io.IOException; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.HashSet; -import java.util.LinkedHashSet; -import java.util.Map; -import java.util.Set; - -import javax.faces.component.NamingContainer; -import javax.faces.component.UIComponent; -import javax.faces.component.UIForm; -import javax.faces.context.FacesContext; -import javax.faces.context.PartialResponseWriter; - -import org.ajax4jsf.Messages; -import org.ajax4jsf.component.AjaxClientBehavior; -import org.ajax4jsf.component.AjaxComponent; -import org.ajax4jsf.context.AjaxContext; -import org.ajax4jsf.javascript.JSFunction; -import org.ajax4jsf.javascript.JSFunctionDefinition; -import org.ajax4jsf.javascript.JSReference; -import org.ajax4jsf.renderkit.AJAXDataSerializer; -import org.ajax4jsf.renderkit.AjaxEventOptions; -import org.richfaces.application.ServiceTracker; -import org.richfaces.log.Logger; -import org.richfaces.log.RichfacesLogger; -import org.richfaces.renderkit.HandlersChain; -import org.richfaces.renderkit.util.RendererUtils.HTML; - -/** - * @author shura - *

- * Some utilites for render AJAX components. - */ -public final class AjaxRendererUtils { - - public static final String AJAX_ABORT_ATTR =3D "ignoreDupResponses"; - public static final String AJAX_AREAS_RENDERED =3D "org.ajax4jsf.areas= .rendered"; - public static final String AJAX_DELAY_ATTR =3D "requestDelay"; - - /** - * Name Javasript function for submit AJAX request - */ - public static final String AJAX_FUNCTION_NAME =3D "RichFaces.ajax"; - - /** - * @since 3.3.0 - */ - public static final String AJAX_PROCESS_ATTRIBUTE =3D "process"; - public static final String AJAX_QUEUE_ATTR =3D "eventsQueue"; - public static final String AJAX_REGIONS_ATTRIBUTE =3D "reRender"; - public static final String AJAX_SINGLE_ATTR =3D "ajaxSingle"; - public static final String AJAX_SINGLE_PARAMETER_NAME =3D "ajaxSingle"; - public static final String ALL =3D "@all"; - public static final String FORM =3D "@form"; - public static final String THIS =3D "@this"; - public static final String REGION =3D "@region"; - public static final String NONE =3D "@none"; - - public static final Set GLOBAL_META_COMPONENTS; - - static { - GLOBAL_META_COMPONENTS =3D new HashSet(2); - - GLOBAL_META_COMPONENTS.add(ALL); - GLOBAL_META_COMPONENTS.add(NONE); - } - - /** - * Attribute to keep - */ - public static final String LIMITRENDER_ATTR_NAME =3D "limitRender"; - - /** - * Attribute for keep JavaScript function name for call before updating - * DOM tree. - */ - public static final String ONBEFOREDOMUPDATE_ATTR_NAME =3D "onbeforedo= mupdate"; - public static final String ONBEGIN_ATTR_NAME =3D "onbegin"; - - /** - * Attribute for keep JavaScript function name for call after complete - * request. - */ - public static final String ONCOMPLETE_ATTR_NAME =3D "oncomplete"; - - public static final String DATA_ATTR_NAME =3D "data"; - - /** - * Attribute for keep JavaScript function name for call after complete - * request. - */ - public static final String ONCOMPLETE_CONTENT_ID =3D "org.ajax4jsf.onc= omplete"; - public static final String SIMILARITY_GROUPING_ID_ATTR =3D "similarity= GroupingId"; - - /** - * Attribute for keep clientId of status component - */ - public static final String STATUS_ATTR_NAME =3D "status"; - public static final String VALUE_ATTR =3D "value"; - - public static final String EXTENSION_ID =3D "org.richfaces.extension"; - public static final String AJAX_COMPONENT_ID_PARAMETER =3D "org.richfa= ces.ajax.component"; - public static final String BEHAVIOR_EVENT_PARAMETER =3D "javax.faces.b= ehavior.event"; - - public static final String QUEUE_ID_ATTRIBUTE =3D "queueId"; - - private static final String BEFOREDOMUPDATE_ELEMENT_NAME =3D "beforedo= mupdate"; - private static final String COMPLETE_ELEMENT_NAME =3D "complete"; - private static final String DATA_ELEMENT_NAME =3D "data"; - private static final String COMPONENT_DATA_ELEMENT_NAME =3D "component= Data"; - - private static final RendererUtils RENDERER_UTILS =3D RendererUtils.ge= tInstance(); - private static final Class OBJECT_ARRAY_CLASS =3D new Object[0].get= Class(); - private static final Logger LOG =3D RichfacesLogger.RENDERKIT.getLogge= r(); - - /** - * Static class - protect constructor - */ - private AjaxRendererUtils() { - } - - private static enum BehaviorEventOptionsData { - begin { - @Override - public String getAttributeValue(AjaxClientBehavior behavior) { - return behavior.getOnbegin(); - } - }, - error { - @Override - public String getAttributeValue(AjaxClientBehavior behavior) { - return behavior.getOnerror(); - } - }, - queueId { - @Override - public String getAttributeValue(AjaxClientBehavior behavior) { - return behavior.getQueueId(); - } - }, - event { - @Override - public String getAttributeValue(AjaxClientBehavior behavior) { - return behavior.getOnevent(); - } - }; - - public abstract String getAttributeValue(AjaxClientBehavior behavi= or); - } - - /** - * Build JavaScript onclick event for given component - * - * @param uiComponent - - * component for build event - * @param facesContext - * @return StringBuffer with Javascript code - */ - public static StringBuffer buildOnClick(UIComponent uiComponent, Faces= Context facesContext) { - return buildOnClick(uiComponent, facesContext, false); - } - - /** - * Build JavaScript onclick event for given component - * - * @param uiComponent - - * component for build event - * @param facesContext - * @param omitDefaultActionUrl - default action URL is not encoded if = parameter is true - * @return StringBuffer with Javascript code - */ - public static StringBuffer buildOnClick(UIComponent uiComponent, Faces= Context facesContext, - boolean omitDefaultActionUrl) { - return buildOnEvent(uiComponent, facesContext, HTML.ONCLICK_ATTRIB= UTE, omitDefaultActionUrl); - } - - /** - * Build JavaScript event for component - * - * @param uiComponent - - * component for build event - * @param facesContext - * @param eventName - - * name of event - * @return StringBuffer with Javascript code - */ - public static StringBuffer buildOnEvent(UIComponent uiComponent, Faces= Context facesContext, String eventName) { - return buildOnEvent(uiComponent, facesContext, eventName, false); - } - - /** - * Build JavaScript event for component - * - * @param uiComponent - - * component for build event - * @param facesContext - * @param eventName - - * name of event - * @param omitDefaultActionUrl - default action URL is not encoded if = parameter is true - * @return StringBuffer with Javascript code - */ - public static StringBuffer buildOnEvent(UIComponent uiComponent, Faces= Context facesContext, String eventName, - boolean omitDefaultActionUrl) { - StringBuffer onEvent =3D new StringBuffer(); - -// if (null !=3D eventName) { -// String commandOnEvent =3D (String) uiComponent.getAttributes()= .get( -// eventName); -// if (commandOnEvent !=3D null) { -// onEvent.append(commandOnEvent); -// onEvent.append(';'); -// } -// } -// JSFunction ajaxFunction =3D buildAjaxFunction(uiComponent, facesCo= ntext); -// // Create formal parameter for non-input elements ??? -// // Link Control pseudo-object -// // Options map. Possible options for function call : -// // control - name of form control for submit. -// // name - name for link control \ -// // value - value of control. - possible replace by parameters ? -// // single true/false - submit all form or only one control. -// // affected - array of element's ID for update on responce. -// // oncomplete - function for call after complete request. -// // status - id of request status component. -// // parameters - map of parameters name/value for append on request. -// // .......... -// ajaxFunction.addParameter(buildEventOptions(facesContext, uiCompon= ent, omitDefaultActionUrl)); -// -// // appendAjaxSubmitParameters(facesContext, uiComponent, onEvent); -// ajaxFunction.appendScript(onEvent); -// if (uiComponent instanceof AjaxSupport) { -// AjaxSupport support =3D (AjaxSupport) uiComponent; -// if (support.isDisableDefault()) { -// onEvent.append("; return false;"); -// } -// } -// LOG.debug(Messages.getMessage(Messages.BUILD_ONCLICK_INFO, uiCompo= nent -// .getId(), onEvent.toString())); - return onEvent; - } - - public static AjaxEventOptions buildEventOptions(FacesContext facesCon= text, UIComponent component) { - return buildEventOptions(facesContext, component, null); - } - - public static AjaxEventOptions buildEventOptions(FacesContext facesCon= text, UIComponent component, - AjaxClientBehavior aj= axBehavior) { - AjaxEventOptions ajaxEventOptions =3D new AjaxEventOptions(); - Map parametersMap =3D RENDERER_UTILS.createParamet= ersMap(facesContext, component); - String ajaxStatusName =3D getAjaxStatus(component); - - if (ajaxBehavior !=3D null) { - ajaxStatusName =3D (ajaxBehavior.getStatus() !=3D null) ? ajax= Behavior.getStatus() : ajaxStatusName; - appenAjaxBehaviorOptions(ajaxBehavior, ajaxEventOptions); - } else { - appendComponentOptions(facesContext, component, ajaxEventOptio= ns); - } - - if ((ajaxStatusName !=3D null) && (ajaxStatusName.length() !=3D 0)= ) { - ajaxEventOptions.set(STATUS_ATTR_NAME, ajaxStatusName); - } - - if (!parametersMap.isEmpty()) { - ajaxEventOptions.getParameters().putAll(parametersMap); - } - - return ajaxEventOptions; - } - - private static boolean isNotEmpty(String value) { - return (value !=3D null) && (value.length() !=3D 0); - } - - private static void appenAjaxBehaviorOptions(AjaxClientBehavior behavi= or, AjaxEventOptions ajaxEventOptions) { - for (BehaviorEventOptionsData optionsData : BehaviorEventOptionsDa= ta.values()) { - String eventHandlerValue =3D optionsData.getAttributeValue(beh= avior); - - if (isNotEmpty(eventHandlerValue)) { - ajaxEventOptions.set(optionsData.toString(), eventHandlerV= alue); - } - } - } - - private static void appendComponentOptions(FacesContext facesContext, = UIComponent component, - AjaxEventOptions ajaxEventO= ptions) { - String behaviorName =3D "begin"; - HandlersChain handlersChain =3D new HandlersChain(facesContext, co= mponent); - String inlineHandler =3D getAjaxOnBegin(component); - - handlersChain.addInlineHandlerAsValue(inlineHandler); - handlersChain.addBehaviors(behaviorName); - - String handlerScript =3D handlersChain.toScript(); - - if (isNotEmpty(handlerScript)) { - ajaxEventOptions.set(behaviorName, handlerScript); - } - - String queueId =3D getQueueId(component); - if (isNotEmpty(queueId)) { - ajaxEventOptions.set(QUEUE_ID_ATTRIBUTE, queueId); - } - = - ajaxEventOptions.set("incId", "1"); - } - -// public static AjaxEventOptions buildEventOptions(FacesContext facesCon= text, -// UIComponent uiComponent, Map params) { -// -// return buildEventOptions(facesContext, uiComponent, params, false); -// } - - /** - * @param facesContext - * @param uiComponent - * @return - */ -// public static Map buildEventOptions(FacesContext faces= Context, -// UIComponent uiComponent, Map params, boolean o= mitDefaultActionUrl) { -// String clientId =3D uiComponent.getClientId(facesContext); -// Map componentAttributes =3D uiComponent.getAttribu= tes(); -// Map options =3D new HashMap(); -// -// UIComponent nestingContainer =3D (UIComponent) findAjaxContainer( -// facesContext, uiComponent); -// String containerClientId =3D nestingContainer.getClientId(facesCon= text); -// if (containerClientId !=3D null && !AjaxViewRoot.ROOT_ID.equals(co= ntainerClientId)) { -// options.put("containerId", containerClientId); -// } -// -// Map parameters =3D new HashMap(); -// UIComponent targetComponent =3D (uiComponent instanceof AjaxSuppor= t)?uiComponent.getParent():uiComponent; -// // UIForm form =3D getNestingForm(uiComponent); -// // "input" - if assigned to html input element. -// boolean input =3D targetComponent instanceof EditableValueHolder; -// // Action component - button etc. -//// boolean action =3D targetComponent instanceof ActionSource; -// -// boolean ajaxSingle =3D Boolean.TRUE.equals(componentAttributes -// .get(AJAX_SINGLE_ATTR)); -// // For input components in single mode or without form submit input -// // control ) -// if (ajaxSingle ) { -// parameters.put(AJAX_SINGLE_PARAMETER_NAME, targetComponent.get= ClientId(facesContext)); -// // options.put("single", JSReference.TRUE); -// if (input) { -// options.put("control", JSReference.THIS); -// } -// } -// // Control value for submit -// String controlName; -// Object controlValue; -// // TODO - make compatible with JSF RI/MyFaces ? use submittedValue= ( if -// // any ) for UIInput, converted value for ValueHolder. -// controlName =3D clientId; -// controlValue =3D clientId; -// parameters.put(controlName, controlValue); -// AjaxContext ajaxContext =3D AjaxContext.getCurrentInstance(facesCo= ntext); -// -// String ajaxActionURL =3D ajaxContext.getAjaxActionURL(facesContext= ); -// if (omitDefaultActionUrl) { -// UIComponent form =3D getNestingForm(uiComponent); -// if (form !=3D null && !RENDERER_UTILS.isBooleanAttribute(form,= "ajaxSubmit")) { -// if (RENDERER_UTILS.getActionUrl(facesContext).equals(ajaxA= ctionURL)) { -// ajaxActionURL =3D null; -// } -// } -// } -// -// if (ajaxActionURL !=3D null) { -// // Setup action URL. For portlet environment, it will be diffe= rent from -// // page. -// options.put("actionUrl", ajaxActionURL); -// } -// -// // Add application-wide Ajax parameters -// parameters.putAll(ajaxContext.getCommonAjaxParameters()); -// // add child parameters -// appendParameters(facesContext, uiComponent, parameters); -// -// if (params !=3D null) { -// parameters.putAll(params); -// } -// -// if (!parameters.isEmpty()) { -// options.put("parameters", parameters); -// } -// // parameter to render only current list of areas. -//// if (isAjaxLimitToList(uiComponent)) { -//// Set ajaxAreas =3D getAjaxAreas(uiCompone= nt); -//// Set areasIds =3D new HashSet(); -//// if (null !=3D ajaxAreas) { -//// for (Iterator iter =3D ajaxAreas.ite= rator(); iter.hasNext();) { -//// String id =3D (String) iter.next(); -//// UIComponent comp =3D RendererUtils.getInstance(). -//// findComponentFor(uiComponent, id); -//// if (null !=3D comp) { -//// areasIds.add(comp.getClientId(facesContext)); -//// } else { -//// areasIds.add(id); -//// } -//// } -//// } -//// options.put("affected", areasIds); -//// } -// String oncomplete =3D getAjaxOncomplete(uiComponent); -// if (null !=3D oncomplete) { -// options.put(ONCOMPLETE_ATTR_NAME, buildAjaxOncomplete(oncomple= te)); -// } -// -// String beforeupdate =3D getAjaxOnBeforeDomUpdate(uiComponent); -// if (null !=3D beforeupdate) { -// options.put(ONBEFOREDOMUPDATE_ATTR_NAME, buildAjaxOnBeforeDomU= pdate(beforeupdate)); -// } -// -// -// String status =3D getAjaxStatus(uiComponent); -// if (null !=3D status) { -// options.put("status", status); -// } -// String queue =3D (String) componentAttributes.get(AJAX_QUEUE_ATTR); -// String implicitQueue =3D null; -// -// Integer requestDelay =3D (Integer) componentAttributes -// .get(AJAX_DELAY_ATTR); -// if (null !=3D requestDelay && requestDelay.intValue() > 0) { -// options.put(AJAX_DELAY_ATTR, requestDelay); -// if (null =3D=3D queue) { -// implicitQueue =3D clientId; -// } -// } -// Boolean ignoreDupResponses =3D (Boolean) componentAttributes -// .get(AJAX_ABORT_ATTR); -// if (null !=3D ignoreDupResponses && ignoreDupResponses.booleanValu= e()) { -// options.put(AJAX_ABORT_ATTR, JSReference.TRUE); -// if (null =3D=3D queue) { -// implicitQueue =3D clientId; -// } -// } -// -// if (null !=3D queue) { -// options.put(AJAX_QUEUE_ATTR, queue); -// } else if (implicitQueue !=3D null) { -// options.put("implicitEventsQueue", clientId); -// } -// -// ExternalContext externalContext =3D facesContext.getExternalContex= t(); -// String namespace =3D externalContext.encodeNamespace(""); -// if (namespace !=3D null && namespace.length() !=3D 0) { -// options.put("namespace", namespace); -// } -// -// String similarityGroupingId =3D (String) componentAttributes.get(S= IMILARITY_GROUPING_ID_ATTR); -// if (similarityGroupingId =3D=3D null || similarityGroupingId.lengt= h() =3D=3D 0) { -// similarityGroupingId =3D clientId; -// } else { -// similarityGroupingId =3D externalContext.encodeNamespace(simil= arityGroupingId); -// } -// -// options.put(SIMILARITY_GROUPING_ID_ATTR, similarityGroupingId); -// -// // request timeout. -// Integer timeout =3D (Integer) componentAttributes.get("timeout"); -// if (null !=3D timeout && timeout.intValue() > 0) { -// options.put("timeout", timeout); -// } -// // Encoding for requests -// String encoding =3D (String) componentAttributes.get("encoding"); -// if (null !=3D encoding) { -// options.put("encoding", encoding); -// } -// return options; -// } -// /** -// * Create call to Ajax Submit function with first two parameters -// * -// * @param uiComponent -// * @param facesContext -// * @param functionName -// * @return -// */ -// public static JSFunction buildAjaxFunction(UIComponent uiComponent, -// FacesContext facesContext) { -// JSFunction ajaxFunction =3D buildAjaxFunction(uiComponent, facesCo= ntext, -// AJAX_FUNCTION_NAME); -// // client-side script must have reference to event-enabled object. -// ajaxFunction.addParameter(new JSReference("event")); -// return ajaxFunction; -// } - - /** - * Create call to Ajax Submit function with first two parameters - * - * @param facesContext - * @param uiComponent - * @param functionName - * @return - */ - public static JSFunction buildAjaxFunction(FacesContext facesContext, = UIComponent uiComponent, - String functionName) { - JSFunction ajaxFunction =3D new JSFunction(functionName); - - ajaxFunction.addParameter(uiComponent.getClientId(facesContext)); - ajaxFunction.addParameter(JSReference.EVENT); - - return ajaxFunction; - } - - /** - * Append common parameters ( array of affected areas, status area id,= on - * complete function ) to JavaScript event string. - * - * @param uiComponent - * @param onClick - - * buffer with JavaScript code eg... AJAX.Submit(form,this - */ - - // public static void appendAjaxSubmitParameters(FacesContext facesCon= text, - // UIComponent uiComponent, StringBuffer onClick) - // { - // Set ajaxAreas =3D getAjaxAreas(uiComponent); - // onClick.append(','); - // // parameter to render only current list of areas. - // if (isAjaxLimitToList(uiComponent) && ajaxAreas !=3D null && - // ajaxAreas.size() > 0) - // { - // onClick.append('['); - // Iterator areas =3D ajaxAreas.iterator(); - // boolean first =3D true; - // while (areas.hasNext()) - // { - // String element =3D (String) areas.next(); - // UIComponent component =3D uiComponent.findComponent(element); - // if (null !=3D component) - // { - // if (!first) - // { - // onClick.append(','); - // } - // else - // { - // first =3D false; - // } - // onClick.append('\''); - // onClick.append(component.getClientId(facesContext)); - // onClick.append('\''); - // } - // } - // onClick.append("]"); - // } - // else - // { - // onClick.append("null"); - // } - // // insert id of request status element. - // onClick.append(','); - // String status =3D getAjaxStatus(uiComponent); - // if (null !=3D status) - // { - // onClick.append('\'').append(status).append('\''); - // } - // else - // { - // onClick.append("null"); - // } - // // insert function name for call after completed request - // onClick.append(','); - // String oncomplete =3D getAjaxOncomplete(uiComponent); - // if (null !=3D oncomplete) - // { - // onClick.append(oncomplete); - // } - // else - // { - // onClick.append("null"); - // } - // - // } - - /** - * Get list of clientId's for given component - * - * @param uiComponent - * @return List of areas Id's , updated by this component. - */ - public static Set getAjaxAreas(UIComponent uiComponent) { - Object areas; - - if (uiComponent instanceof AjaxComponent) { - areas =3D ((AjaxComponent) uiComponent).getReRender(); - } else { - areas =3D uiComponent.getAttributes().get(AjaxRendererUtils.AJ= AX_REGIONS_ATTRIBUTE); - } - - return asSet(areas); - } - - /** - * Returns set of areas to be processed as a result of this component = action invocation - * - * @param component - * @return set of IDs that should be processed as a - * @since 3.3.0 - */ - public static Set getAjaxAreasToProcess(UIComponent component)= { - Object areas; - - if (component instanceof AjaxComponent) { - areas =3D ((AjaxComponent) component).getProcess(); - } else { - areas =3D component.getAttributes().get(AjaxRendererUtils.AJAX= _PROCESS_ATTRIBUTE); - } - - return asSet(areas); - } - - /** - * Split parameter string into array of strings. - * @param valuesSet - * @return - */ - public static String[] asArray(String valuesSet) { - return IdSplitBuilder.split(valuesSet); - } - - /** - * Convert parameter ( Collection, List, array, String, comma-separated - * String, whitespace-separate String) to set of strings. - * - * @param valueToSet - - * object for conversion to Set. - * @return - set of strings. - */ - @SuppressWarnings("unchecked") - public static Set asSet(Object valueToSet) { - if (null !=3D valueToSet) { - - // Simplest case - set. - if (valueToSet instanceof Set) { - return new LinkedHashSet((Set) valueToSet); - } else if (valueToSet instanceof Collection) { // Other collec= tions. - return new LinkedHashSet((Collection) valu= eToSet); - } else if (OBJECT_ARRAY_CLASS.isAssignableFrom(valueToSet.getC= lass())) { // Array - return new LinkedHashSet(Arrays.asList((String[]) = valueToSet)); - } else if (valueToSet instanceof String) { // Tokenize string. - String areasString =3D ((String) valueToSet).trim(); - - if (areasString.contains(",") || areasString.contains(" ")= ) { - String[] values =3D asArray(areasString); - Set result =3D new LinkedHashSet(value= s.length); - for (String value : values) { - result.add(value); - } - - return result; - } else { - Set areasSet =3D new LinkedHashSet(5); - - areasSet.add(areasString); - - return areasSet; - } - } - } - - return null; - } - - /** - * Get status area Id for given component. - * - * @param component - * @return clientId of status area, or null - */ - public static String getAjaxStatus(UIComponent component) { - String statusId; - - if (component instanceof AjaxComponent) { - statusId =3D ((AjaxComponent) component).getStatus(); - } else { - statusId =3D (String) component.getAttributes().get(STATUS_ATT= R_NAME); - } - - return statusId; - -// if (null !=3D statusId) { -// UIComponent status =3D RendererUtils.getInstance(). -// findComponentFor(component, statusId); -// -// if (null !=3D status) { -// statusId =3D status -// .getClientId(FacesContext.getCurrentInstance()); -// } else { -// LOG.warn(Messages.getMessage( -// Messages.AJAX_STATUS_COMPONENT_NOT_FOWND_WARNING, -// component.getId())); -// } -// } -// return statusId; - } - - public static String getQueueId(UIComponent component) { - return (String) component.getAttributes().get(QUEUE_ID_ATTRIBUTE); - } - = - public static JSFunctionDefinition buildAjaxOncomplete(String body) { - JSFunctionDefinition function =3D new JSFunctionDefinition("reques= t", "event", "data"); - - function.addToBody(body); - - return function; - } - - public static JSFunctionDefinition buildAjaxOnBeforeDomUpdate(String b= ody) { - JSFunctionDefinition function =3D new JSFunctionDefinition("reques= t", "event", "data"); - - function.addToBody(body); - - return function; - } - - /** - * Get function name for call on completed ajax request. - * - * @param component for wich calculate function name - * @return name of JavaScript function or null - */ - //TODO nick - refactor - remove this method? - public static String getAjaxOncomplete(UIComponent component) { - if (component instanceof AjaxComponent) { - return ((AjaxComponent) component).getOncomplete(); - } - - return (String) component.getAttributes().get(ONCOMPLETE_ATTR_NAME= ); - } - - /** - * Get function name for call before update DOM. - * - * @param component for wich calculate function name - * @return name of JavaScript function or null - */ - //TODO nick - refactor - remove this method? - public static String getAjaxOnBeforeDomUpdate(UIComponent component) { - if (component instanceof AjaxComponent) { - return ((AjaxComponent) component).getOnbeforedomupdate(); - } - - return (String) component.getAttributes().get(ONBEFOREDOMUPDATE_AT= TR_NAME); - } - - //TODO nick - refactor - remove this method? - public static String getAjaxOnBegin(UIComponent component) { - if (component instanceof AjaxComponent) { - return ((AjaxComponent) component).getOnbegin(); - } - - return (String) component.getAttributes().get(ONBEGIN_ATTR_NAME); - } - - /** - * @param component - * @return - * @since 4.0 - */ - public static Object getAjaxData(UIComponent component) { - if (component instanceof AjaxComponent) { - return ((AjaxComponent) component).getData(); - } - - return component.getAttributes().get(DATA_ATTR_NAME); - } - - /** - * Calculate, must be component render only given areas, or all sended= from - * server. - * - * @param component - * @return true if client must render ONLY given areas. - */ - public static boolean isAjaxLimitRender(UIComponent component) { - boolean result =3D false; - - if (component instanceof AjaxComponent) { - result =3D ((AjaxComponent) component).isLimitRender(); - } else { - try { - result =3D ((Boolean) component.getAttributes().get(LIMITR= ENDER_ATTR_NAME)).booleanValue(); - } catch (NullPointerException e) { - - // NullPointer - ignore ... - } catch (ClassCastException e1) { - - // not Boolean - false ... - } - } - - return result; - } - - /** - * Replacement for buggy in MyFaces RendererUtils - * - * @param component - * @return - */ - public static String getAbsoluteId(UIComponent component) { - if (component =3D=3D null) { - throw new NullPointerException(Messages.getMessage(Messages.CO= MPONENT_NULL_ERROR_2)); - } - - StringBuffer idBuf =3D new StringBuffer(); - - idBuf.append(component.getId()); - - UIComponent parent =3D component; - - while ((parent =3D parent.getParent()) !=3D null) { - if (parent instanceof NamingContainer) { - idBuf.insert(0, NamingContainer.SEPARATOR_CHAR); - idBuf.insert(0, parent.getId()); - } - } - - idBuf.insert(0, NamingContainer.SEPARATOR_CHAR); - LOG.debug(Messages.getMessage(Messages.CALCULATE_COMPONENT_ID_INFO= , component.getId(), idBuf.toString())); - - return idBuf.toString(); - } - - /** - * Find nested form for given component - * - * @param component - * @return nested UIForm component, or null - */ - public static UIComponent getNestingForm(UIComponent component) { - UIComponent parent =3D component; - - // Search enclosed UIForm or ADF UIXForm component - while ((parent !=3D null) && !(parent instanceof UIForm) - && !("org.apache.myfaces.trinidad.Form".equals(parent.getFamil= y())) - && !("oracle.adf.Form".equals(parent.getFamily()))) { - parent =3D parent.getParent(); - } - - return parent; - } - - protected static String getAjaxActionUrl(FacesContext facesContext) { - return AjaxContext.getCurrentInstance(facesContext).getAjaxActionU= RL(facesContext); - } - -// /** -// * Encode rendered areas as special HTML tag ( span in current relea= se ) -// * -// * @param context -// * @param component -// * @throws IOException -// */ -// public static void encodeAreas(FacesContext context, UIComponent com= ponent) throws IOException { -// AjaxContext ajaxContext =3D AjaxContext.getCurrentInstance(conte= xt); -// ExternalContext externalContext =3D context.getExternalContext(); -// Map requestMap =3D externalContext.getRequestMap= (); -// Set rendered =3D ajaxContext.getAjaxRenderedAreas(); -// -// // write special area for list of rendered elements. Client-side -// // Java -// // Script -// // read this structure for update areas of DOM tree. -// ResponseWriter out =3D context.getResponseWriter(); -// -// // Create element to keep list rendered aread ( in title -// // attribute ) -// // More right will create special namespace for such -// // information, -// // but I want to keep simple html ( xhtml ) document - on case -// // I have troubles with microsoft XMLHTTP validations. -// out.startElement(AjaxContainerRenderer.AJAX_RESULT_GROUP_TAG, co= mponent); -// out.writeAttribute(HTML.NAME_ATTRIBUTE, AjaxContainerRenderer.AJ= AX_UPDATE_HEADER, null); -// -// StringBuffer senderString =3D new StringBuffer(); -// -// for (Iterator it =3D rendered.iterator(); it.hasNext();)= { -// String id =3D it.next(); -// -// senderString.append(id); -// -// if (it.hasNext()) { -// senderString.append(','); -// } -// } -// -// out.writeAttribute(AjaxContainerRenderer.AJAX_RESULT_GROUP_ATTR,= senderString, null); -// out.endElement(AjaxContainerRenderer.AJAX_RESULT_GROUP_TAG); -// -// // For sequences and client-saved states. -// out.startElement(AjaxContainerRenderer.AJAX_VIEW_STATE_TAG, comp= onent); -// out.writeAttribute(HTML.ID_ATTRIBUTE, AjaxContainerRenderer.AJAX= _VIEW_STATE_ID, null); -// writeState(context); -// out.endElement(AjaxContainerRenderer.AJAX_VIEW_STATE_TAG); -// -// // Write rendered flag to html -// out.startElement(AjaxContainerRenderer.AJAX_RESULT_GROUP_TAG, co= mponent); -// out.writeAttribute(HTML.ID_ATTRIBUTE, AjaxContainerRenderer.AJAX= _FLAG_HEADER, null); -// out.writeAttribute(HTML.NAME_ATTRIBUTE, AjaxContainerRenderer.AJ= AX_FLAG_HEADER, null); -// out.writeAttribute(AjaxContainerRenderer.AJAX_RESULT_GROUP_ATTR,= "true", null); -// out.endElement(AjaxContainerRenderer.AJAX_RESULT_GROUP_TAG); -// -// // set response header with list of rendered ID's -// Object response =3D externalContext.getResponse(); -// -// // Use reflection for send responce headers - we can get -// // different responces classes -// // for different environment ( portal, cocoon etc ) -// if (response instanceof HttpServletResponse) { -// HttpServletResponse httpResponse =3D (HttpServletResponse) r= esponse; -// -// httpResponse.setHeader(AjaxContainerRenderer.AJAX_FLAG_HEADE= R, "true"); -// } else { -// try { -// Method setHeadergMethod =3D response.getClass().getMetho= d("setHeader", -// new Class[]{String.class, String.class}); -// -// setHeadergMethod.invoke(response, AjaxContainerRenderer.= AJAX_FLAG_HEADER, "true"); -// } catch (Exception e) { -// LOG.error(Messages.getMessage(Messages.DETECTING_ENCODIN= G_DISABLED_ERROR)); -// LOG.error(Messages.getMessage(Messages.OBTAIN_RESPONSE_S= ET_HEADER_ERROR, e)); -// } -// } -// -// Map responseDataMap =3D ajaxContext.getResponseC= omponentDataMap(); -// -// // Get data serializer instance -// AJAXDataSerializer serializer =3D ServiceTracker.getService(cont= ext, AJAXDataSerializer.class); -// -// // Put data to JavaScript handlers, inside elements. -// for (Map.Entry entry : responseDataMap.entrySet(= )) { -// out.startElement(HTML.SPAN_ELEM, component); -// out.writeAttribute(HTML.ID_ATTRIBUTE, entry.getKey(), null); -// -// String dataString =3D serializer.asString(entry.getValue()); -// -// out.write(dataString); -// out.endElement(HTML.SPAN_ELEM); -// } -// -// // Include active 'oncomplete' function content : -// Object oncomplete =3D ajaxContext.getOncomplete(); -// -// if (null !=3D oncomplete) { -// out.startElement(HTML.SPAN_ELEM, component); -// out.writeAttribute(HTML.ID_ATTRIBUTE, ONCOMPLETE_CONTENT_ID,= null); -// out.writeText(oncomplete, null); -// out.endElement(HTML.SPAN_ELEM); -// } -// -// // For self-rendered case, we use own methods for replace stateK= ey by -// // real value in XML filter. -// // if(ajaxContext.isSelfRender()){ -// // saveViewState(context, out); -// // } -// requestMap.put(AJAX_AREAS_RENDERED, "true"); -// } - - /** - * Write state saving markers to context, include MyFaces view sequenc= e. - * - * @param context - * @throws IOException - */ - public static void writeState(FacesContext context) throws IOException= { - context.getApplication().getViewHandler().writeState(context); - } - -// /** -// * Encode declaration for AJAX response. Render <html><body= > -// * -// * @param context -// * @param component -// * @throws IOException -// */ -// public static void encodeAjaxBegin(FacesContext context, UIComponent= component) throws IOException { -// -// // AjaxContainer ajax =3D (AjaxContainer) component; -// ResponseWriter out =3D context.getResponseWriter(); -// -// // DebugUtils.traceView("ViewRoot in AJAX Page encode begin"); -// out.startElement("html", component); -// -// Locale locale =3D context.getViewRoot().getLocale(); -// -// out.writeAttribute(HTML.LANG_ATTRIBUTE, locale.toString(), "lang= "); -// out.startElement("body", component); -// } -// -// /** -// * End encoding of AJAX response. Render tag with included areas and= close -// * </body></html> -// * -// * @param context -// * @param component -// * @throws IOException -// */ -// public static void encodeAjaxEnd(FacesContext context, UIComponent c= omponent) throws IOException { -// -// // AjaxContainer ajax =3D (AjaxContainer) component; -// ResponseWriter out =3D context.getResponseWriter(); -// -// // DebugUtils.traceView("ViewRoot in AJAX Page encode begin"); -// encodeAreas(context, component); -// out.endElement("body"); -// out.endElement("html"); -// } - - /** - * @param facesContext - * @return - */ - public static boolean isAjaxRequest(FacesContext facesContext) { - return AjaxContext.getCurrentInstance(facesContext).isAjaxRequest(= ); - } - - /** - * TODO: add deprecation - * - * @param facesContext - * @param component - * @param id - */ - public static void addRegionByName(FacesContext facesContext, UICompon= ent component, String id) { - AjaxContext.getCurrentInstance(facesContext).addComponentToAjaxRen= der(component, id); - } - - /** - * @param facesContext - * @param component - */ - public static void addRegionsFromComponent(UIComponent component, Face= sContext facesContext) { - AjaxContext.getCurrentInstance(facesContext).addRegionsFromCompone= nt(component); - } - - private static void startExtensionElementIfNecessary( - PartialResponseWriter partialResponseWriter, - Map attributes, - boolean[] writingState) throws IOException { - - if (!writingState[0]) { - writingState[0] =3D true; - - partialResponseWriter.startExtension(attributes); - } - } - - private static void endExtensionElementIfNecessary( - PartialResponseWriter partialResponseWriter, - boolean[] writingState) throws IOException { - - if (writingState[0]) { - writingState[0] =3D false; - - partialResponseWriter.endExtension(); - } - } - - public static void renderAjaxExtensions(FacesContext facesContext, UIC= omponent component) throws IOException { - AjaxContext ajaxContext =3D AjaxContext.getCurrentInstance(facesCo= ntext); - - Map attributes =3D Collections.singletonMap(HTML.I= D_ATTRIBUTE, - facesContext.getExternalContext().encodeNamespace(EXTENSION_ID= )); - PartialResponseWriter writer =3D facesContext.getPartialViewContex= t().getPartialResponseWriter(); - boolean[] writingState =3D new boolean[]{false}; - - Object onbeforedomupdate =3D ajaxContext.getOnbeforedomupdate(); - if (onbeforedomupdate !=3D null) { - String string =3D onbeforedomupdate.toString(); - if (string.length() !=3D 0) { - startExtensionElementIfNecessary(writer, attributes, writi= ngState); - writer.startElement(BEFOREDOMUPDATE_ELEMENT_NAME, componen= t); - writer.writeText(onbeforedomupdate, null); - writer.endElement(BEFOREDOMUPDATE_ELEMENT_NAME); - } - } - - Object oncomplete =3D ajaxContext.getOncomplete(); - if (oncomplete !=3D null) { - String string =3D oncomplete.toString(); - if (string.length() !=3D 0) { - startExtensionElementIfNecessary(writer, attributes, writi= ngState); - writer.startElement(COMPLETE_ELEMENT_NAME, component); - writer.writeText(oncomplete, null); - writer.endElement(COMPLETE_ELEMENT_NAME); - } - } - - Object responseData =3D ajaxContext.getResponseData(); - if (responseData !=3D null) { - startExtensionElementIfNecessary(writer, attributes, writingSt= ate); - writer.startElement(DATA_ELEMENT_NAME, component); - - AJAXDataSerializer serializer =3D ServiceTracker.getService(fa= cesContext, AJAXDataSerializer.class); - writer.writeText(serializer.asString(responseData), null); - - writer.endElement(DATA_ELEMENT_NAME); - } - - Map responseComponentDataMap =3D ajaxContext.getRe= sponseComponentDataMap(); - if (responseComponentDataMap !=3D null && !responseComponentDataMa= p.isEmpty()) { - startExtensionElementIfNecessary(writer, attributes, writingSt= ate); - writer.startElement(COMPONENT_DATA_ELEMENT_NAME, component); - - AJAXDataSerializer serializer =3D ServiceTracker.getService(fa= cesContext, AJAXDataSerializer.class); - writer.writeText(serializer.asString(responseComponentDataMap)= , null); - - writer.endElement(COMPONENT_DATA_ELEMENT_NAME); - } - = - endExtensionElementIfNecessary(writer, writingState); - - } - -} Deleted: trunk/core/impl/src/main/java/org/richfaces/renderkit/util/IdSplit= Builder.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/core/impl/src/main/java/org/richfaces/renderkit/util/IdSplitBuild= er.java 2010-09-08 17:07:06 UTC (rev 19136) +++ trunk/core/impl/src/main/java/org/richfaces/renderkit/util/IdSplitBuild= er.java 2010-09-08 19:14:49 UTC (rev 19137) @@ -1,150 +0,0 @@ -/* - * JBoss, Home of Professional Open Source - * Copyright 2010, Red Hat, Inc. and individual contributors - * by the @authors tag. See the copyright.txt in the distribution for a - * full listing of individual contributors. - * - * This is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this software; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA, or see the FSF site: http://www.fsf.org. - */ -package org.richfaces.renderkit.util; - -import java.util.ArrayList; -import java.util.List; - -/** - * @author Nick Belaevski - */ -final class IdSplitBuilder { - - private static final int INITIAL_SPLIT_LIST_SIZE =3D 3; - - private enum State { - IN_ID (true) { - - @Override - public State getNextState(char c) { - if (c =3D=3D '[') { - return State.IN_ID_INSIDE_BRACKETS; - } else if (isSeparator(c)) { - return State.OUTSIDE_ID; - } else { - return this; - } - } - }, - IN_ID_INSIDE_BRACKETS (true) { - - @Override - public State getNextState(char c) { - if (c =3D=3D ']') { - return State.IN_ID; - } else { - return this; - } - } - }, - OUTSIDE_ID (false) { - - @Override - public State getNextState(char c) { - if (!isSeparator(c)) { - if (c =3D=3D '[') { - return State.IN_ID_INSIDE_BRACKETS; - } else { - return State.IN_ID; - } - } - - return this; - } - }; - - private final boolean idSegment; - - private State(boolean idSegment) { - this.idSegment =3D idSegment; - } - - private static boolean isSeparator(char c) { - return c =3D=3D ',' || Character.isWhitespace(c); - } - - public abstract State getNextState(char c); - - public boolean isIdSegment() { - return idSegment; - } - - public void processChar(IdSplitBuilder builder, char c, int charId= x) { - State nextState =3D getNextState(c); - - if (nextState.isIdSegment() ^ isIdSegment()) { - if (nextState.isIdSegment()) { - builder.setStartIndex(charIdx); - } else { - builder.flushBuilder(charIdx); - builder.setStartIndex(-1); - } - } - - builder.state =3D nextState; - } - } - - private int startIdx =3D -1; - - private String sourceString; - - private List result =3D new ArrayList(INITIAL_SPLIT_LI= ST_SIZE); - - private State state =3D State.OUTSIDE_ID; - - private IdSplitBuilder(String sourceString) { - super(); - this.sourceString =3D sourceString; - } - - private void setStartIndex(int idx) { - startIdx =3D idx; - } - - private void flushBuilder(int endIdx) { - if (startIdx >=3D 0 && endIdx > startIdx) { - String id =3D sourceString.substring(startIdx, endIdx); - result.add(id); - } - } - - private void build() { - int length =3D sourceString.length(); - for (int i =3D 0; i < length; i++) { - char c =3D sourceString.charAt(i); - state.processChar(this, c, i); - } - flushBuilder(length); - } - - private String[] getSplit() { - return result.toArray(new String[result.size()]); - } - - public static String[] split(String s) { - IdSplitBuilder splitBuilder =3D new IdSplitBuilder(s); - splitBuilder.build(); - return splitBuilder.getSplit(); - } - -} \ No newline at end of file Deleted: trunk/core/impl/src/main/java/org/richfaces/renderkit/util/Rendere= rUtils.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/core/impl/src/main/java/org/richfaces/renderkit/util/RendererUtil= s.java 2010-09-08 17:07:06 UTC (rev 19136) +++ trunk/core/impl/src/main/java/org/richfaces/renderkit/util/RendererUtil= s.java 2010-09-08 19:14:49 UTC (rev 19137) @@ -1,1314 +0,0 @@ -/** - * License Agreement. - * - * Rich Faces - Natural Ajax for Java Server Faces (JSF) - * - * Copyright (C) 2007 Exadel, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License version 2.1 as published by the Free Software Foundation. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-130= 1 USA - */ - - - -package org.richfaces.renderkit.util; - -import java.io.IOException; -import java.lang.reflect.Array; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.LinkedHashSet; -import java.util.Map; -import java.util.Set; - -import javax.faces.FacesException; -import javax.faces.application.ViewHandler; -import javax.faces.component.EditableValueHolder; -import javax.faces.component.NamingContainer; -import javax.faces.component.UIComponent; -import javax.faces.component.UIForm; -import javax.faces.component.UIParameter; -import javax.faces.component.UIViewRoot; -import javax.faces.component.ValueHolder; -import javax.faces.component.behavior.ClientBehaviorContext.Parameter; -import javax.faces.component.behavior.ClientBehaviorHolder; -import javax.faces.context.FacesContext; -import javax.faces.context.ResponseWriter; -import javax.faces.convert.Converter; - -import org.ajax4jsf.Messages; -import org.ajax4jsf.component.JavaScriptParameter; -import org.ajax4jsf.javascript.JSEncoder; -import org.ajax4jsf.javascript.JSFunctionDefinition; -import org.ajax4jsf.javascript.JSReference; -import org.ajax4jsf.util.HtmlDimensions; -import org.richfaces.context.ComponentIdResolver; -import org.richfaces.renderkit.HandlersChain; - -/** - * Util class for common render operations - render passthru html attribut= es, - * iterate over child components etc. - * - * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmir= nov $) - * @version $Revision: 1.1.2.6 $ $Date: 2007/02/08 19:07:16 $ - * - */ -public class RendererUtils { - - public static final String DUMMY_FORM_ID =3D ":_form"; - - // we'd better use this instance multithreadly quickly - private static final RendererUtils INSTANCE =3D new RendererUtils(); - - /** - * Substitutions for components properies names and HTML attributes na= mes. - */ - private static final Map SUBSTITUTIONS =3D new HashMap= (); - = - private static final Set REQUIRED_ATTRIBUTES =3D new HashSet(); - - static { - SUBSTITUTIONS.put(HTML.CLASS_ATTRIBUTE, "styleClass"); - = - REQUIRED_ATTRIBUTES.add(HTML.ALT_ATTRIBUTE); - - Arrays.sort(HTML.PASS_THRU); - Arrays.sort(HTML.PASS_THRU_EVENTS); - Arrays.sort(HTML.PASS_THRU_BOOLEAN); - Arrays.sort(HTML.PASS_THRU_URI); - } - - // can be created by subclasses; - // administratively restricted to be created by package members ;) - protected RendererUtils() { - super(); - } - - /** - * Wrapper class around object value used to transform values into par= ticular JS objects - * - * @author Nick Belaevski - * @since 3.3.2 - */ - public static enum ScriptHashVariableWrapper { - - /** - * No-op default wrapper - */ - DEFAULT { - @Override - Object wrap(Object o) { - return o; - } - }, - - /** - * Event handler functions wrapper. Wraps

functionCode
= object into: - *
function(event) {
-         *   functionCode
-         * }
- */ - EVENT_HANDLER { - @Override - Object wrap(Object o) { - return new JSFunctionDefinition("event").addToBody(o); - } - }; - - /** - * Method that does the wrapping - * - * @param o object to wrap - * @return wrapped object - */ - abstract Object wrap(Object o); - } - - /** - * Use this method to get singleton instance of RendererUtils - * @return singleton instance - */ - public static RendererUtils getInstance() { - return INSTANCE; - } - - /** - * Encode id attribute with clientId component property - * - * @param context - * @param component - * @throws IOException - */ - public void encodeId(FacesContext context, UIComponent component) thro= ws IOException { - encodeId(context, component, HTML.ID_ATTRIBUTE); - } - - /** - * Encode clientId to custom attribute ( for example, to control name ) - * - * @param context - * @param component - * @param attribute - * @throws IOException - */ - public void encodeId(FacesContext context, UIComponent component, Stri= ng attribute) throws IOException { - String clientId =3D null; - - try { - clientId =3D component.getClientId(context); - } catch (Exception e) { - - // just ignore if clientId wasn't inited yet - } - - if (null !=3D clientId) { - context.getResponseWriter().writeAttribute(attribute, clientId, - (String) getComponentAttributeName(attribute)); - } - } - - /** - * Encode id attribute with clientId component property. Encoded only = if id - * not auto generated. - * - * @param context - * @param component - * @throws IOException - */ - public void encodeCustomId(FacesContext context, UIComponent component= ) throws IOException { - if (hasExplicitId(component)) { - context.getResponseWriter().writeAttribute(HTML.ID_ATTRIBUTE, = component.getClientId(context), - HTML.ID_ATTRIBUTE); - } - } - - public Map createParametersMap(FacesContext context, U= IComponent component) { - Map parameters =3D new LinkedHashMap(); - - if (component.getChildCount() > 0) { - for (UIComponent child : component.getChildren()) { - if (child instanceof UIParameter) { - UIParameter parameter =3D (UIParameter) child; - String name =3D parameter.getName(); - Object value =3D parameter.getValue(); - - if (null =3D=3D name) { - throw new IllegalArgumentException(Messages.getMes= sage(Messages.UNNAMED_PARAMETER_ERROR, - component.getClientId(context))); - } - - boolean escape =3D true; - - if (child instanceof JavaScriptParameter) { - JavaScriptParameter actionParam =3D (JavaScriptPar= ameter) child; - - escape =3D !actionParam.isNoEscape(); - } - - if (escape) { - if (value =3D=3D null) { - value =3D ""; - } - } else { - value =3D new JSReference(value.toString()); - - // if(it.hasNext()){onEvent.append(',');}; - // renderAjaxLinkParameter( name, - // value, onClick, jsForm, nestingForm); - } - - parameters.put(name, value); - } - } - } - - return parameters; - } - - private void encodeBehaviors(FacesContext context, ClientBehaviorHolde= r behaviorHolder, - String defaultHtmlEventName, String[] att= ributesExclusions) - throws IOException { - -// if (attributesExclusions !=3D null && attributesExclusions.length = !=3D 0) { -// assert false : "Not supported yet"; -// } - // TODO: disabled component check - String defaultEventName =3D behaviorHolder.getDefaultEventName(); - Collection eventNames =3D behaviorHolder.getEventNames(); - - if (eventNames !=3D null) { - UIComponent component =3D (UIComponent) behaviorHolder; - ResponseWriter writer =3D context.getResponseWriter(); - Collection parametersList =3D HandlersChain.createP= arametersList(createParametersMap(context, - component)); - - for (String behaviorEventName : eventNames) { - if (behaviorEventName.equals(defaultEventName)) { - continue; - } - - String htmlEventName =3D "on" + behaviorEventName; - - if ((attributesExclusions =3D=3D null) || (Arrays.binarySe= arch(attributesExclusions, htmlEventName) < 0)) { - HandlersChain handlersChain =3D new HandlersChain(cont= ext, component, parametersList); - - handlersChain.addInlineHandlerFromAttribute(htmlEventN= ame); - handlersChain.addBehaviors(behaviorEventName); - - String handlerScript =3D handlersChain.toScript(); - - if (!isEmpty(handlerScript)) { - writer.writeAttribute(htmlEventName, handlerScript= , htmlEventName); - } - } - } - } - } - - /** - * Encode common pass-thru html attributes. - * - * @param context - * @param component - * @throws IOException - */ - public void encodePassThru(FacesContext context, UIComponent component= , String defaultHtmlEvent) - throws IOException { - - encodeAttributesFromArray(context, component, HTML.PASS_THRU); - - if (component instanceof ClientBehaviorHolder) { - ClientBehaviorHolder clientBehaviorHolder =3D (ClientBehaviorH= older) component; - - encodeBehaviors(context, clientBehaviorHolder, defaultHtmlEven= t, null); - } else { - encodeAttributesFromArray(context, component, HTML.PASS_THRU_E= VENTS); - } - } - - /** - * Encode pass-through attributes except specified ones - * - * @param context - * @param component - * @param exclusions - * @throws IOException - */ - public void encodePassThruWithExclusions(FacesContext context, UICompo= nent component, String exclusions, - String defaultHtmlEvent) throws IOException { - - if (null !=3D exclusions) { - String[] exclusionsArray =3D exclusions.split(","); - - encodePassThruWithExclusionsArray(context, component, exclusio= nsArray, defaultHtmlEvent); - } - } - - public void encodePassThruWithExclusionsArray(FacesContext context, UI= Component component, String[] exclusions, - String defaultHtmlEvent) throws IOException { - - ResponseWriter writer =3D context.getResponseWriter(); - Map attributes =3D component.getAttributes(); - - Arrays.sort(exclusions); - - for (int i =3D 0; i < HTML.PASS_THRU.length; i++) { - String attribute =3D HTML.PASS_THRU[i]; - - if (Arrays.binarySearch(exclusions, attribute) < 0) { - encodePassThruAttribute(context, attributes, writer, attri= bute); - } - } - - if (component instanceof ClientBehaviorHolder) { - ClientBehaviorHolder clientBehaviorHolder =3D (ClientBehaviorH= older) component; - - encodeBehaviors(context, clientBehaviorHolder, defaultHtmlEven= t, exclusions); - } else { - for (int i =3D 0; i < HTML.PASS_THRU_EVENTS.length; i++) { - String attribute =3D HTML.PASS_THRU_EVENTS[i]; - - if (Arrays.binarySearch(exclusions, attribute) < 0) { - encodePassThruAttribute(context, attributes, writer, a= ttribute); - } - } - } - } - - /** - * Encode one pass-thru attribute, with plain/boolean/url value, got f= rom - * properly component attribute. - * - * @param context - * @param writer - * @param attribute - * @throws IOException - */ - public void encodePassThruAttribute(FacesContext context, Map attributes, ResponseWriter writer, - String attribute) throws IOException { - - Object value =3D attributeValue(attribute, attributes.get(getCompo= nentAttributeName(attribute))); - - if ((null !=3D value) && shouldRenderAttribute(attribute, value)) { - if (Arrays.binarySearch(HTML.PASS_THRU_URI, attribute) >=3D 0)= { - String url =3D context.getApplication().getViewHandler().g= etResourceURL(context, value.toString()); - - url =3D context.getExternalContext().encodeResourceURL(url= ); - writer.writeURIAttribute(attribute, url, attribute); - } else { - writer.writeAttribute(attribute, value, attribute); - } - } - } - - public void encodeAttributesFromArray(FacesContext context, UIComponen= t component, String[] attrs) - throws IOException { - - ResponseWriter writer =3D context.getResponseWriter(); - Map attributes =3D component.getAttributes(); - - for (int i =3D 0; i < attrs.length; i++) { - String attribute =3D attrs[i]; - - encodePassThruAttribute(context, attributes, writer, attribute= ); - } - } - - /** - * Encode attributes given by comma-separated string list. - * - * @param context - * current JSF context - * @param component - * for with render attributes values - * @param attrs - * comma separated list of attributes - * @throws IOException - */ - public void encodeAttributes(FacesContext context, UIComponent compone= nt, String attrs) throws IOException { - if (null !=3D attrs) { - String[] attrsArray =3D attrs.split(","); - - encodeAttributesFromArray(context, component, attrsArray); - } - } - - /** - * @param context - * @param component - * @param property - * @param attributeName - * - * @throws IOException - */ - public void encodeAttribute(FacesContext context, UIComponent componen= t, Object property, String attributeName) - throws IOException { - - ResponseWriter writer =3D context.getResponseWriter(); - Object value =3D component.getAttributes().get(property); - - if (shouldRenderAttribute(attributeName, value)) { - writer.writeAttribute(attributeName, value, property.toString(= )); - } - } - - public void encodeAttribute(FacesContext context, UIComponent componen= t, String attribute) throws IOException { - encodeAttribute(context, component, getComponentAttributeName(attr= ibute), attribute); - } - - /** - * Write html-attribute - * - * @param writer - * @param attribute - * @param value - * @throws IOException - */ - public void writeAttribute(ResponseWriter writer, String attribute, Ob= ject value) throws IOException { - if (shouldRenderAttribute(attribute, value)) { - writer.writeAttribute(attribute, value.toString(), attribute); - } - } - - /** - * @return true if and only if the argument attributeVal = is - * an instance of a wrapper for a primitive type and its value= is - * equal to the default value for that type as given in the sp= ec. - */ - public boolean shouldRenderAttribute(Object attributeVal) { - if (null =3D=3D attributeVal) { - return false; - } else if ((attributeVal instanceof Boolean) - && ((Boolean) attributeVal).booleanValue() =3D=3D Boole= an.FALSE.booleanValue()) { - return false; - } else if (attributeVal.toString().length() =3D=3D 0) { - return false; - } else { - return isValidProperty(attributeVal); - } - } - - public boolean shouldRenderAttribute(String attributeName, Object attr= ibuteVal) { - if (REQUIRED_ATTRIBUTES.contains(attributeName)) { - if (attributeVal =3D=3D null) { - return false; - } - } else { - return shouldRenderAttribute(attributeVal); - } - - return true; - } - - /** - * Test for valid value of property. by default, for non-setted proper= ties - * with Java primitive types of JSF component return appropriate MIN_V= ALUE . - * - * @param property - - * value of property returned from - * {@link UIComponent#getAttributes()} - * @return true for setted property, false otherthise. - */ - public boolean isValidProperty(Object property) { - if (null =3D=3D property) { - return false; - } else if ((property instanceof Integer) && ((Integer) property).i= ntValue() =3D=3D Integer.MIN_VALUE) { - return false; - } else if ((property instanceof Double) && ((Double) property).dou= bleValue() =3D=3D Double.MIN_VALUE) { - return false; - } else if ((property instanceof Character) && ((Character) propert= y).charValue() =3D=3D Character.MIN_VALUE) { - return false; - } else if ((property instanceof Float) && ((Float) property).float= Value() =3D=3D Float.MIN_VALUE) { - return false; - } else if ((property instanceof Short) && ((Short) property).short= Value() =3D=3D Short.MIN_VALUE) { - return false; - } else if ((property instanceof Byte) && ((Byte) property).byteVal= ue() =3D=3D Byte.MIN_VALUE) { - return false; - } else if ((property instanceof Long) && ((Long) property).longVal= ue() =3D=3D Long.MIN_VALUE) { - return false; - } - - return true; - } - - /** - * Checks if the argument passed in is empty or not. - * Object is empty if it is:
- * - null
- * - zero-length string
- * - empty collection
- * - empty map
- * - zero-length array
- * - * @param o object to check for emptiness - * @since 3.3.2 - * @return true if the argument is empty, false otherwise - */ - public boolean isEmpty(Object o) { - if (null =3D=3D o) { - return true; - } - - if (o instanceof String) { - return 0 =3D=3D ((String) o).length(); - } - - if (o instanceof Collection) { - return ((Collection) o).isEmpty(); - } - - if (o instanceof Map) { - return ((Map) o).isEmpty(); - } - - if (o.getClass().isArray()) { - return Array.getLength(o) =3D=3D 0; - } - - return false; - } - - /** - * Puts value into map under specified key if the value is not empty a= nd not default. - * Performs optional value wrapping. - * - * @param hash - * @param name - * @param value - * @param defaultValue - * @param wrapper - * - * @since 3.3.2 - */ - public void addToScriptHash(Map hash, String name, Obj= ect value, String defaultValue, - ScriptHashVariableWrapper wrapper) { - ScriptHashVariableWrapper wrapperOrDefault =3D (wrapper !=3D null)= ? wrapper : ScriptHashVariableWrapper.DEFAULT; - - if (isValidProperty(value) && !isEmpty(value)) { - if (!isEmpty(defaultValue)) { - if (!defaultValue.equals(value.toString())) { - hash.put(name, wrapperOrDefault.wrap(value)); - } - } else { - if (!(value instanceof Boolean) || ((Boolean) value).boole= anValue()) { - hash.put(name, wrapperOrDefault.wrap(value)); - } - } - } - } - - /** - * Puts value into map under specified key if the value is not empty a= nd not default. - * Performs optional value wrapping. - * - * @param hash - * @param name - * @param value - * @param defaultValue - * - * @since 3.3.2 - */ - public void addToScriptHash(Map hash, String name, Obj= ect value, String defaultValue) { - addToScriptHash(hash, name, value, defaultValue, null); - } - - /** - * Puts value into map under specified key if the value is not empty a= nd not default. - * Performs optional value wrapping. - * - * @param hash - * @param name - * @param value - * - * @since 3.3.2 - */ - public void addToScriptHash(Map hash, String name, Obj= ect value) { - addToScriptHash(hash, name, value, null, null); - } - - /** - * Convert HTML attribute name to component property name. - * - * @param key - * @return - */ - protected Object getComponentAttributeName(Object key) { - Object converted =3D SUBSTITUTIONS.get(key); - - if (null =3D=3D converted) { - return key; - } else { - return converted; - } - } - - /** - * Convert attribute value to proper object. For known html boolean - * attributes return name for true value, otherthise - null. For non-b= oolean - * attributes return same value. - * - * @param name - * attribute name. - * @param value - * @return - */ - protected Object attributeValue(String name, Object value) { - if (null =3D=3D value || Arrays.binarySearch(HTML.PASS_THRU_BOOLEA= N, name) < 0) { - return value; - } - - boolean checked; - - if (value instanceof Boolean) { - checked =3D ((Boolean) value).booleanValue(); - } else { - checked =3D Boolean.parseBoolean(value.toString()); - } - - return checked ? name : null; - } - - /** - * Get boolean value of logical attribute - * - * @param component - * @param name - * attribute name - * @return true if attribute is equals Boolean.TRUE or String "true" ,= false - * otherwise. - */ - public boolean isBooleanAttribute(UIComponent component, String name) { - Object attrValue =3D component.getAttributes().get(name); - boolean result =3D false; - - if (null !=3D attrValue) { - if (attrValue instanceof String) { - result =3D "true".equalsIgnoreCase((String) attrValue); - } else { - result =3D Boolean.TRUE.equals(attrValue); - } - } - - return result; - } - - /** - * Return converted value for {@link javax.faces.component.ValueHolder= } as - * String, perform nessesary convertions. - * - * @param context - * @param component - * @return - */ - public String getValueAsString(FacesContext context, UIComponent compo= nent) { - - // First - get submitted value for input components - if (component instanceof EditableValueHolder) { - EditableValueHolder input =3D (EditableValueHolder) component; - String submittedValue =3D (String) input.getSubmittedValue(); - - if (null !=3D submittedValue) { - return submittedValue; - } - } - - // If no submitted value presented - convert same for UIInput/UIOu= tput - if (component instanceof ValueHolder) { - return formatValue(context, component, ((ValueHolder) componen= t).getValue()); - } else { - throw new IllegalArgumentException( - Messages.getMessage(Messages.CONVERTING_NON_VALUE_HOLDER_C= OMPONENT_ERROR, component.getId())); - } - } - - /** - * Convert any object value to string. If component instance of - * {@link ValueHolder } got {@link Converter} for formatting. If not, - * attempt to use converter based on value type. - * - * @param context - * @param component - * @return - */ - public String formatValue(FacesContext context, UIComponent component,= Object value) { - if (value instanceof String) { - return (String) value; - } - - Converter converter =3D null; - - if (component instanceof ValueHolder) { - ValueHolder holder =3D (ValueHolder) component; - - converter =3D holder.getConverter(); - } - - if ((null =3D=3D converter) && (null !=3D value)) { - try { - converter =3D context.getApplication().createConverter(val= ue.getClass()); - } catch (FacesException e) { - - // TODO - log converter exception. - } - } - - if (null =3D=3D converter) { - if (null !=3D value) { - return value.toString(); - } - } else { - return converter.getAsString(context, component, value); - } - - return ""; - } - - public String encodePx(String value) { - return HtmlDimensions.formatPx(HtmlDimensions.decode(value)); - } - - /** - * formats given value to - * - * @param value - * - * @return - */ - public String encodePctOrPx(String value) { - if (value.indexOf('%') > 0) { - return value; - } else { - return encodePx(value); - } - } - - /** - * Find nested form for given component - * - * @param component - * @return nested UIForm component, or null - */ - public UIForm getNestingForm(FacesContext context, UIComponent compone= nt) { - UIComponent parent =3D component.getParent(); - - while ((parent !=3D null) && !(parent instanceof UIForm)) { - parent =3D parent.getParent(); - } - - UIForm nestingForm =3D null; - - if (parent !=3D null) { - - // link is nested inside a form - nestingForm =3D (UIForm) parent; - } - - return nestingForm; - } - - /** - * @param context - * @param component - * @return - * @throws IOException - */ - public void encodeBeginFormIfNessesary(FacesContext context, UICompone= nt component) throws IOException { - UIForm form =3D getNestingForm(context, component); - - if (null =3D=3D form) { - ResponseWriter writer =3D context.getResponseWriter(); - String clientId =3D component.getClientId(context) + DUMMY_FOR= M_ID; - - encodeBeginForm(context, component, writer, clientId); - - // writer.writeAttribute(HTML.STYLE_ATTRIBUTE, "margin:0; - // padding:0;", null); - } - } - - /** - * @param context - * @param component - * @param writer - * @param clientId - * @throws IOException - */ - public void encodeBeginForm(FacesContext context, UIComponent componen= t, ResponseWriter writer, String clientId) - throws IOException { - - String actionURL =3D getActionUrl(context); - String encodeActionURL =3D context.getExternalContext().encodeActi= onURL(actionURL); - - writer.startElement(HTML.FORM_ELEMENT, component); - writer.writeAttribute(HTML.ID_ATTRIBUTE, clientId, null); - writer.writeAttribute(HTML.NAME_ATTRIBUTE, clientId, null); - writer.writeAttribute(HTML.METHOD_ATTRIBUTE, "post", null); - writer.writeAttribute(HTML.STYLE_ATTRIBUTE, "margin:0; padding:0; = display: inline;", null); - writer.writeURIAttribute(HTML.ACTION_ATTRIBUTE, encodeActionURL, "= action"); - } - - /** - * @param context - * @param component - * @throws IOException - */ - public void encodeEndFormIfNessesary(FacesContext context, UIComponent= component) throws IOException { - UIForm form =3D getNestingForm(context, component); - - if (null =3D=3D form) { - ResponseWriter writer =3D context.getResponseWriter(); - - // TODO - hidden form parameters ? - encodeEndForm(context, writer); - } - } - - /** - * @param context - * @param writer - * @throws IOException - */ - public void encodeEndForm(FacesContext context, ResponseWriter writer)= throws IOException { - AjaxRendererUtils.writeState(context); - writer.endElement(HTML.FORM_ELEMENT); - } - - /** - * @param facesContext - * @return String A String representing the action URL - */ - public String getActionUrl(FacesContext facesContext) { - ViewHandler viewHandler =3D facesContext.getApplication().getViewH= andler(); - String viewId =3D facesContext.getViewRoot().getViewId(); - - return viewHandler.getActionURL(facesContext, viewId); - } - - /** - * Simplified version of {@link encodeId} - * - * @param context - * @param component - * @return client id of current component - */ - public String clientId(FacesContext context, UIComponent component) { - String clientId =3D ""; - - try { - clientId =3D component.getClientId(context); - } catch (Exception e) { - - // just ignore - } - - return clientId; - } - - /** - * Wtrie JavaScript with start/end elements and type. - * - * @param context - * @param component - * @param script - */ - public void writeScript(FacesContext context, UIComponent component, O= bject script) throws IOException { - ResponseWriter writer =3D context.getResponseWriter(); - - writer.startElement(HTML.SCRIPT_ELEM, component); - writer.writeAttribute(HTML.TYPE_ATTR, "text/javascript", "type"); - writer.writeText(script, null); - writer.endElement(HTML.SCRIPT_ELEM); - } - - /** - * @param ids - * @param keyword - * @return - * @since 4.0 - */ - private static boolean checkKeyword(Collection ids, String key= word) { - if (ids.contains(keyword)) { - if (ids.size() !=3D 1) { - //TODO log - } - - return true; - } - - return false; - } - - public String getPredefinedMetaComponentId(FacesContext facesContext, = UIComponent component, String id) { - - if (AjaxRendererUtils.ALL.equals(id)) { - return AjaxRendererUtils.ALL; - } else if (AjaxRendererUtils.NONE.equals(id)) { - return AjaxRendererUtils.NONE; - } else if (AjaxRendererUtils.THIS.equals(id)) { - return component.getClientId(facesContext); - } else if (AjaxRendererUtils.FORM.equals(id)) { - UIForm nestingForm =3D getNestingForm(facesContext, component); - if (nestingForm !=3D null) { - return nestingForm.getClientId(facesContext); - } else { - //TODO nick - log warning for missing form - } - } - - return null; - } - - /** - * @param context - * @param component - * @param shortIds - * @since 4.0 - * @return - */ - public Collection findComponentsFor(FacesContext context, UICo= mponent component, - Collection shortIds) { - - // TODO - implement - // TODO add support for @* - Set result =3D new LinkedHashSet(shortIds.size()); - - if (checkKeyword(shortIds, AjaxRendererUtils.ALL)) { - result.add(AjaxRendererUtils.ALL); - } else if (checkKeyword(shortIds, AjaxRendererUtils.NONE)) { - //do nothing, use empty set - } else { - ComponentIdResolver locator =3D new ComponentIdResolver(contex= t); - - for (String id : shortIds) { - String predefinedMetaComponentId =3D getPredefinedMetaComp= onentId(context, component, id); - if (predefinedMetaComponentId !=3D null) { - if (AjaxRendererUtils.GLOBAL_META_COMPONENTS.contains(= predefinedMetaComponentId)) { - result.clear(); - result.add(predefinedMetaComponentId); - break; - } else { - result.add(predefinedMetaComponentId); - continue; - } - } - - locator.addId(id); - } - - locator.resolve(component); - - result.addAll(locator.getResolvedIds()); - } - - return result; - } - - public UIComponent findComponentFor(FacesContext context, UIComponent = component, String id) { - return findComponentFor(component, id); - } - - /** - * @param component - * @param id - * @return - */ - public UIComponent findComponentFor(UIComponent component, String id) { - if (id =3D=3D null) { - throw new NullPointerException("id is null!"); - } - - if (id.length() =3D=3D 0) { - return null; - } - - UIComponent target =3D null; - UIComponent parent =3D component; - UIComponent root =3D component; - - while ((null =3D=3D target) && (null !=3D parent)) { - target =3D parent.findComponent(id); - root =3D parent; - parent =3D parent.getParent(); - } - - if (null =3D=3D target) { - target =3D findUIComponentBelow(root, id); - } - - return target; - } - - /** - * If target component contains generated id and for doesn't, correct = for id - * @param forAttr - * @param component - * - */ - public String correctForIdReference(String forAttr, UIComponent compon= ent) { - int contains =3D forAttr.indexOf(UIViewRoot.UNIQUE_ID_PREFIX); - - if (contains <=3D 0) { - String id =3D component.getId(); - int pos =3D id.indexOf(UIViewRoot.UNIQUE_ID_PREFIX); - - if (pos > 0) { - return forAttr.concat(id.substring(pos)); - } - } - - return forAttr; - } - - private UIComponent findUIComponentBelow(UIComponent root, String id) { - UIComponent target =3D null; - - for (Iterator iter =3D root.getFacetsAndChildren(); i= ter.hasNext();) { - UIComponent child =3D (UIComponent) iter.next(); - - if (child instanceof NamingContainer) { - try { - target =3D child.findComponent(id); - } catch (IllegalArgumentException iae) { - continue; - } - } - - if (target =3D=3D null) { - if ((child.getChildCount() > 0) || (child.getFacetCount() = > 0)) { - target =3D findUIComponentBelow(child, id); - } - } - - if (target !=3D null) { - break; - } - } - - return target; - } - - public static void writeEventHandlerFunction(FacesContext context, UIC= omponent component, String eventName) - throws IOException { - - ResponseWriter writer =3D context.getResponseWriter(); - Object script =3D component.getAttributes().get(eventName); - - if ((script !=3D null) && !script.equals("")) { - JSFunctionDefinition onEventDefinition =3D new JSFunctionDefin= ition(); - - onEventDefinition.addParameter("event"); - onEventDefinition.addToBody(script); - writer.writeText(eventName + ": " + onEventDefinition.toScript= (), null); - } else { - writer.writeText(eventName + ": ''", null); - } - } - - public JSFunctionDefinition getAsEventHandler(FacesContext context, UI= Component component, String attributeName, - String append) { - String event =3D (String) component.getAttributes().get(attributeN= ame); - - if (event !=3D null) { - event =3D event.trim(); - - if (event.length() !=3D 0) { - JSFunctionDefinition function =3D new JSFunctionDefinition= (); - - function.addParameter("event"); - - if ((null !=3D append) && (append.length() > 0)) { - function.addToBody(event + append); - } else { - function.addToBody(event); - } - - return function; - } - } - - return null; - } - - public String escapeJavaScript(Object o) { - if (o !=3D null) { - StringBuilder result =3D new StringBuilder(); - JSEncoder encoder =3D new JSEncoder(); - char[] chars =3D o.toString().toCharArray(); - int start =3D 0; - int end =3D chars.length; - - for (int x =3D start; x < end; x++) { - char c =3D chars[x]; - - if (encoder.compile(c)) { - continue; - } - - if (start !=3D x) { - result.append(chars, start, x - start); - } - - result.append(encoder.encode(c)); - start =3D x + 1; - - continue; - } - - if (start !=3D end) { - result.append(chars, start, end - start); - } - - return result.toString(); - } else { - return null; - } - } - - public void encodeChildren(FacesContext context, UIComponent component= ) throws IOException { - if (component.getChildCount() > 0) { - for (UIComponent child : component.getChildren()) { - child.encodeAll(context); - } - } - } - = - public boolean hasExplicitId(UIComponent component) { - return component.getId() !=3D null && !component.getId().startsWit= h(UIViewRoot.UNIQUE_ID_PREFIX); - } - = - /** - * Common HTML elements and attributes names. - * - * @author asmirnov(a)exadel.com (latest modification by $Author: alex= smirnov $) - * @version $Revision: 1.1.2.6 $ $Date: 2007/02/08 19:07:16 $ - * - */ - public interface HTML { - // elements - public static final String A_ELEMENT =3D "a"; - public static final String BODY_ELEMENT =3D "body"; - public static final String IMG_ELEMENT =3D "img"; - public static final String INPUT_ELEM =3D "input"; - public static final String INPUT_TYPE_HIDDEN =3D "hidden"; - public static final String BUTTON =3D "button"; - public static final String CAPTION_ELEMENT =3D "caption"; - public static final String CHARSET_ATTR =3D "charset"; - public static final String COORDS_ATTR =3D "coords"; - public static final String COLGROUP_ELEMENT =3D "colgroup"; - public static final String COL_ELEMENT =3D "col"; - public static final String DISABLED_ATTR =3D "disabled"; - public static final String DIV_ELEM =3D "div"; - public static final String DD_ELEMENT =3D "dd"; - public static final String DL_ELEMENT =3D "dl"; - public static final String DT_ELEMENT =3D "dt"; - public static final String FORM_ELEMENT =3D "form"; - public static final String HEAD_ELEMENT =3D "head"; - public static final String HEIGHT_ATTRIBUTE =3D "height"; - public static final String HREFLANG_ATTR =3D "hreflang"; - public static final String HREF_ATTR =3D "href"; - public static final String HTML_ELEMENT =3D "html"; - public static final String LINK_ELEMENT =3D "link"; - public static final String SCRIPT_ELEM =3D "script"; - public static final String SPAN_ELEM =3D "span"; - public static final String TFOOT_ELEMENT =3D "tfoot"; - public static final String THEAD_ELEMENT =3D "thead"; - public static final String TABLE_ELEMENT =3D "table"; - public static final String TBODY_ELEMENT =3D "tbody"; - public static final String TD_ELEM =3D "td"; - public static final String TR_ELEMENT =3D "tr"; - public static final String TH_ELEM =3D "th"; - public static final String TITLE_ELEM =3D "title"; - public static final String UL_ELEMENT =3D "ul"; - public static final String OL_ELEMENT =3D "ol"; - public static final String LI_ELEMENT =3D "li"; - = - // attributes - public static final String FRAME_ATTRIBUTE =3D "frame"; - public static final String BORDER_ATTRIBUTE =3D "border"; - public static final String BGCOLOR_ATTRIBUTE =3D "bgcolor"; - public static final String ACCEPT_ATTRIBUTE =3D "accept"; - public static final String ACCEPT_CHARSET_ATTRIBUTE =3D "accept-ch= arset"; - public static final String ACCESSKEY_ATTRIBUTE =3D "accesskey"; - public static final String ACTION_ATTRIBUTE =3D "action"; - public static final String ALIGN_ATTRIBUTE =3D "align"; - public static final String ALT_ATTRIBUTE =3D "alt"; - public static final String AUTOCOMPLETE_ATTRIBUTE =3D "autocomplet= e"; - public static final String CLASS_ATTRIBUTE =3D "class"; - public static final String COLS_ATTRIBUTE =3D "cols"; - public static final String COLSPAN_ATTRIBUTE =3D "colspan"; - public static final String CELLPADDING_ATTRIBUTE =3D "cellpadding"; - public static final String CELLSPACING_ATTRIBUTE =3D "cellspacing"; - public static final String DIR_ATTRIBUTE =3D "dir"; - public static final String ENCTYPE_ATTRIBUTE =3D "enctype"; - = - public static final String ID_ATTRIBUTE =3D "id"; - public static final String LANG_ATTRIBUTE =3D "lang"; - public static final String LONGDESC_ATTRIBUTE =3D "longdesc"; - public static final String MAXLENGTH_ATTRIBUTE =3D "maxlength"; - public static final String MEDIA_ATTRIBUTE =3D "media"; - public static final String METHOD_ATTRIBUTE =3D "method"; - public static final String NAME_ATTRIBUTE =3D "name"; - public static final String NOWRAP_ATTRIBUTE =3D "nowrap"; - public static final String ROWS_ATTRIBUTE =3D "rows"; - public static final String RULES_ATTRIBUTE =3D "rules"; - public static final String ROWSPAN_ATTRIBUTE =3D "rowspan"; - public static final String READONLY_ATTRIBUTE =3D "readonly"; - public static final String SIZE_ATTRIBUTE =3D "size"; - public static final String SRC_ATTRIBUTE =3D "src"; - public static final String STYLE_ATTRIBUTE =3D "style"; - public static final String SUMMARY_ATTRIBUTE =3D "summary"; - public static final String SCOPE_ATTRIBUTE =3D "scope"; - public static final String TABINDEX_ATTRIBUTE =3D "tabindex"; - public static final String TITLE_ATTRIBUTE =3D "title"; - public static final String TARGET_ATTRIBUTE =3D "target"; - public static final String TYPE_ATTR =3D "type"; - = - public static final String USEMAP_ATTRIBUTE =3D "usemap"; - - public static final String VALIGN_ATTRIBUTE =3D "valign"; - public static final String VALUE_ATTRIBUTE =3D "value"; - public static final String WIDTH_ATTRIBUTE =3D "width"; - - - public static final String ONBLUR_ATTRIBUTE =3D "onblur"; - public static final String ONCHANGE_ATTRIBUTE =3D "onchange"; - public static final String ONCLICK_ATTRIBUTE =3D "onclick"; - public static final String ONDBLCLICK_ATTRIBUTE =3D "ondblclick"; - public static final String ONFOCUS_ATTRIBUTE =3D "onfocus"; - public static final String ONKEYDOWN_ATTRIBUTE =3D "onkeydown"; - public static final String ONKEYPRESS_ATTRIBUTE =3D "onkeypress"; - public static final String ONKEYUP_ATTRIBUTE =3D "onkeyup"; - public static final String ONLOAD_ATTRIBUTE =3D "onload"; - public static final String ONMOUSEDOWN_ATTRIBUTE =3D "onmousedown"; - public static final String ONMOUSEMOVE_ATTRIBUTE =3D "onmousemove"; - public static final String ONMOUSEOUT_ATTRIBUTE =3D "onmouseout"; - public static final String ONMOUSEOVER_ATTRIBUTE =3D "onmouseover"; - public static final String ONMOUSEUP_ATTRIBUTE =3D "onmouseup"; - public static final String ONRESET_ATTRIBUTE =3D "onreset"; - public static final String ONSELECT_ATTRIBUTE =3D "onselect"; - public static final String ONSUBMIT_ATTRIBUTE =3D "onsubmit"; - public static final String ONUNLOAD_ATTRIBUTE =3D "onunload"; - = - public static final String REL_ATTR =3D "rel"; - public static final String REV_ATTR =3D "rev"; - public static final String SHAPE_ATTR =3D "shape"; - public static final String STYLE_CLASS_ATTR =3D "styleClass"; - - - - // public static final String ONRESET_ATTRIBUTE =3D "onreset"; - // attributes sets. - public static final String[] PASS_THRU =3D { - - // DIR_ATTRIBUTE, - // LANG_ATTRIBUTE, - // STYLE_ATTRIBUTE, - // TITLE_ATTRIBUTE - "accesskey", "alt", "cols", "height", "lang", "longdesc", "max= length", "rows", "size", "tabindex", "title", - "width", "dir", "rules", "frame", "border", "cellspacing", "ce= llpadding", "summary", "bgcolor", "usemap", - "enctype", "accept-charset", "accept", "target", "charset", "c= oords", "hreflang", "rel", "rev", "shape", - "disabled", "readonly", "ismap", "align" - }; - - /** - * HTML attributes allowed boolean-values only - */ - public static final String[] PASS_THRU_BOOLEAN =3D { - "disabled", "declare", "readonly", "compact", "ismap", "select= ed", "checked", "nowrap", "noresize", - "nohref", "noshade", "multiple" - }; - public static final String[] PASS_THRU_EVENTS =3D { - "onblur", "onchange", "onclick", "ondblclick", "onfocus", "onk= eydown", "onkeypress", "onkeyup", "onload", - "onmousedown", "onmousemove", "onmouseout", "onmouseover", "on= mouseup", "onreset", "onselect", "onsubmit", - "onunload" - }; - public static final String[] PASS_THRU_STYLES =3D {"style", "class= ", }; - - /** - * all HTML attributes with URI value. - */ - public static final String[] PASS_THRU_URI =3D { - "usemap", "background", "codebase", "cite", "data", "classid",= "href", "longdesc", "profile", "src" - }; - - = - public static final String TEXT_JAVASCRIPT_TYPE =3D "text/javascri= pt"; - public static final String REL_STYLESHEET =3D "stylesheet"; - public static final String CSS_TYPE =3D "text/css"; - public static final String JAVASCRIPT_TYPE =3D "text/javascript"; - } -} --===============8486541039917368506==--