Author: nbelaevski
Date: 2010-09-06 11:48:48 -0400 (Mon, 06 Sep 2010)
New Revision: 19123
Added:
branches/RF-7560/core/api/src/main/java/org/richfaces/renderkit/AjaxDataSerializer.java
branches/RF-7560/core/api/src/main/java/org/richfaces/renderkit/util/CoreAjaxRendererUtils.java
branches/RF-7560/core/api/src/main/java/org/richfaces/renderkit/util/HtmlDimensions.java
branches/RF-7560/core/api/src/main/java/org/richfaces/renderkit/util/IdSplitBuilder.java
branches/RF-7560/core/api/src/main/java/org/richfaces/util/
branches/RF-7560/core/api/src/main/java/org/richfaces/util/LRUMap.java
branches/RF-7560/core/api/src/test/java/org/richfaces/util/
branches/RF-7560/core/api/src/test/java/org/richfaces/util/LRUMapTest.java
branches/RF-7560/core/impl/src/main/java/org/richfaces/renderkit/AjaxDataSerializerImpl.java
branches/RF-7560/ui/common/ui/src/main/java/org/richfaces/context/
branches/RF-7560/ui/common/ui/src/main/java/org/richfaces/context/OnOffResponseWriter.java
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/view/facelets/html/EventListenerHandler.java
Removed:
branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/renderkit/AJAXDataSerializer.java
branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/util/LRUMap.java
branches/RF-7560/core/impl/src/main/java/org/richfaces/context/OnOffResponseWriter.java
branches/RF-7560/core/impl/src/main/java/org/richfaces/renderkit/util/CoreAjaxRendererUtils.java
branches/RF-7560/core/impl/src/main/java/org/richfaces/renderkit/util/HtmlDimensions.java
branches/RF-7560/core/impl/src/main/java/org/richfaces/renderkit/util/IdSplitBuilder.java
branches/RF-7560/core/impl/src/test/java/org/ajax4jsf/util/LRUMapTest.java
Modified:
branches/RF-7560/core/api/pom.xml
branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/util/GenericsIntrospectionCache.java
branches/RF-7560/core/impl/src/main/java/org/richfaces/application/DefaultModule.java
branches/RF-7560/core/impl/src/main/java/org/richfaces/cache/lru/CacheMap.java
branches/RF-7560/core/impl/src/main/java/org/richfaces/renderkit/html/images/SpinnerButtonGradient.java
branches/RF-7560/core/impl/src/main/java/org/richfaces/renderkit/html/images/SpinnerFieldGradient.java
branches/RF-7560/examples/iteration-demo/pom.xml
branches/RF-7560/examples/misc-demo/pom.xml
branches/RF-7560/examples/parent/pom.xml
branches/RF-7560/ui/common/ui/src/main/java/org/richfaces/renderkit/util/AjaxRendererUtils.java
branches/RF-7560/ui/common/ui/src/main/java/org/richfaces/renderkit/util/FormUtil.java
branches/RF-7560/ui/common/ui/src/main/java/org/richfaces/renderkit/util/RendererUtils.java
branches/RF-7560/ui/core/ui/src/main/java/org/ajax4jsf/component/behavior/AjaxBehavior.java
branches/RF-7560/ui/core/ui/src/main/java/org/richfaces/component/PushListenersManager.java
branches/RF-7560/ui/core/ui/src/main/java/org/richfaces/renderkit/html/QueueRenderer.java
branches/RF-7560/ui/misc/ui/src/main/java/org/richfaces/function/RichFunction.java
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/component/AbstractTogglePanelItem.java
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/renderkit/html/AccordionItemRenderer.java
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/renderkit/html/TogglePanelRenderer.java
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/view/facelets/html/ChangeExpandListenerHandler.java
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/view/facelets/html/ItemChangeListenerHandler.java
branches/RF-7560/ui/parent/pom.xml
Log:
RF-7560
Modified: branches/RF-7560/core/api/pom.xml
===================================================================
--- branches/RF-7560/core/api/pom.xml 2010-09-06 15:37:00 UTC (rev 19122)
+++ branches/RF-7560/core/api/pom.xml 2010-09-06 15:48:48 UTC (rev 19123)
@@ -36,6 +36,11 @@
</description>
<dependencies>
+ <dependency>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ </dependency>
+
<!-- Provided dependencies -->
<dependency>
<groupId>javax.el</groupId>
Added:
branches/RF-7560/core/api/src/main/java/org/richfaces/renderkit/AjaxDataSerializer.java
===================================================================
---
branches/RF-7560/core/api/src/main/java/org/richfaces/renderkit/AjaxDataSerializer.java
(rev 0)
+++
branches/RF-7560/core/api/src/main/java/org/richfaces/renderkit/AjaxDataSerializer.java 2010-09-06
15:48:48 UTC (rev 19123)
@@ -0,0 +1,32 @@
+/*
+ * 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;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public interface AjaxDataSerializer {
+
+ public String asString(Object o);
+
+}
Copied:
branches/RF-7560/core/api/src/main/java/org/richfaces/renderkit/util/CoreAjaxRendererUtils.java
(from rev 19120,
branches/RF-7560/core/impl/src/main/java/org/richfaces/renderkit/util/CoreAjaxRendererUtils.java)
===================================================================
---
branches/RF-7560/core/api/src/main/java/org/richfaces/renderkit/util/CoreAjaxRendererUtils.java
(rev 0)
+++
branches/RF-7560/core/api/src/main/java/org/richfaces/renderkit/util/CoreAjaxRendererUtils.java 2010-09-06
15:48:48 UTC (rev 19123)
@@ -0,0 +1,337 @@
+/**
+ * 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-1301 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.LinkedHashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.regex.Pattern;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.context.PartialResponseWriter;
+
+import org.ajax4jsf.component.AjaxComponent;
+import org.ajax4jsf.context.AjaxContext;
+import org.richfaces.application.ServiceTracker;
+import org.richfaces.renderkit.AjaxDataSerializer;
+import org.richfaces.renderkit.HtmlConstants;
+
+import com.google.common.base.Strings;
+
+
+/**
+ * @author shura
+ * <p/>
+ * Some utilites for render AJAX components.
+ */
+public final class CoreAjaxRendererUtils {
+
+ /**
+ * Attribute for keep JavaScript function name for call before updating
+ * DOM tree.
+ */
+ public static final String ONBEFOREDOMUPDATE_ATTR_NAME =
"onbeforedomupdate";
+
+ /**
+ * Attribute for keep JavaScript function name for call after complete
+ * request.
+ */
+ public static final String ONCOMPLETE_ATTR_NAME = "oncomplete";
+
+ public static final String DATA_ATTR_NAME = "data";
+
+ /**
+ * Attribute to keep
+ */
+ public static final String LIMITRENDER_ATTR_NAME = "limitRender";
+
+ /**
+ * @since 3.3.0
+ */
+ public static final String AJAX_PROCESS_ATTRIBUTE = "process";
+ public static final String AJAX_REGIONS_ATTRIBUTE = "reRender";
+
+ private static final String EXTENSION_ID = "org.richfaces.extension";
+
+ private static final String BEFOREDOMUPDATE_ELEMENT_NAME =
"beforedomupdate";
+ private static final String COMPLETE_ELEMENT_NAME = "complete";
+ private static final String DATA_ELEMENT_NAME = "data";
+ private static final String COMPONENT_DATA_ELEMENT_NAME = "componentData";
+ private static final Pattern ID_SPLIT_PATTERN =
Pattern.compile("\\s*(\\s|,)\\s*");
+
+ private CoreAjaxRendererUtils() {
+ }
+
+ private static void startExtensionElementIfNecessary(
+ PartialResponseWriter partialResponseWriter,
+ Map<String, String> attributes,
+ boolean[] writingState) throws IOException {
+
+ if (!writingState[0]) {
+ writingState[0] = true;
+
+ partialResponseWriter.startExtension(attributes);
+ }
+ }
+
+ private static void endExtensionElementIfNecessary(
+ PartialResponseWriter partialResponseWriter,
+ boolean[] writingState) throws IOException {
+
+ if (writingState[0]) {
+ writingState[0] = false;
+
+ partialResponseWriter.endExtension();
+ }
+ }
+
+ public static void renderAjaxExtensions(FacesContext facesContext, UIComponent
component) throws IOException {
+ AjaxContext ajaxContext = AjaxContext.getCurrentInstance(facesContext);
+
+ Map<String, String> attributes =
Collections.singletonMap(HtmlConstants.ID_ATTRIBUTE,
+ facesContext.getExternalContext().encodeNamespace(EXTENSION_ID));
+ PartialResponseWriter writer =
facesContext.getPartialViewContext().getPartialResponseWriter();
+ boolean[] writingState = new boolean[]{false};
+
+ Object onbeforedomupdate = ajaxContext.getOnbeforedomupdate();
+ if (onbeforedomupdate != null) {
+ String string = onbeforedomupdate.toString();
+ if (string.length() != 0) {
+ startExtensionElementIfNecessary(writer, attributes, writingState);
+ writer.startElement(BEFOREDOMUPDATE_ELEMENT_NAME, component);
+ writer.writeText(onbeforedomupdate, null);
+ writer.endElement(BEFOREDOMUPDATE_ELEMENT_NAME);
+ }
+ }
+
+ Object oncomplete = ajaxContext.getOncomplete();
+ if (oncomplete != null) {
+ String string = oncomplete.toString();
+ if (string.length() != 0) {
+ startExtensionElementIfNecessary(writer, attributes, writingState);
+ writer.startElement(COMPLETE_ELEMENT_NAME, component);
+ writer.writeText(oncomplete, null);
+ writer.endElement(COMPLETE_ELEMENT_NAME);
+ }
+ }
+
+ Object responseData = ajaxContext.getResponseData();
+ if (responseData != null) {
+ startExtensionElementIfNecessary(writer, attributes, writingState);
+ writer.startElement(DATA_ELEMENT_NAME, component);
+
+ AjaxDataSerializer serializer = ServiceTracker.getService(facesContext,
AjaxDataSerializer.class);
+ writer.writeText(serializer.asString(responseData), null);
+
+ writer.endElement(DATA_ELEMENT_NAME);
+ }
+
+ Map<String, Object> responseComponentDataMap =
ajaxContext.getResponseComponentDataMap();
+ if (responseComponentDataMap != null &&
!responseComponentDataMap.isEmpty()) {
+ startExtensionElementIfNecessary(writer, attributes, writingState);
+ writer.startElement(COMPONENT_DATA_ELEMENT_NAME, component);
+
+ AjaxDataSerializer serializer = ServiceTracker.getService(facesContext,
AjaxDataSerializer.class);
+ writer.writeText(serializer.asString(responseComponentDataMap), null);
+
+ writer.endElement(COMPONENT_DATA_ELEMENT_NAME);
+ }
+
+ endExtensionElementIfNecessary(writer, writingState);
+
+ }
+
+ /**
+ * Split parameter string into array of strings.
+ * @param valuesSet
+ * @return
+ */
+ public static String[] asIdsArray(String valuesSet) {
+ return IdSplitBuilder.split(valuesSet);
+ }
+
+ /**
+ * Get list of clientId's for given component
+ *
+ * @param uiComponent
+ * @return List of areas Id's , updated by this component.
+ */
+ public static Set<String> getAjaxAreas(UIComponent uiComponent) {
+ Object areas;
+
+ if (uiComponent instanceof AjaxComponent) {
+ areas = ((AjaxComponent) uiComponent).getReRender();
+ } else {
+ areas = uiComponent.getAttributes().get(AJAX_REGIONS_ATTRIBUTE);
+ }
+
+ return asIdsSet(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<String> getAjaxAreasToProcess(UIComponent component) {
+ Object areas;
+
+ if (component instanceof AjaxComponent) {
+ areas = ((AjaxComponent) component).getProcess();
+ } else {
+ areas = component.getAttributes().get(AJAX_PROCESS_ATTRIBUTE);
+ }
+
+ return asIdsSet(areas);
+ }
+
+ public static Set<String> asIdsSet(Object valueToSet) {
+ return asSet(valueToSet, true);
+ }
+
+ @SuppressWarnings("unchecked")
+ private static Set<String> asSet(Object valueToSet, boolean idsSet) {
+ if (null != valueToSet) {
+
+ // Simplest case - set.
+ if (valueToSet instanceof Set) {
+ return new LinkedHashSet<String>((Set<String>) valueToSet);
+ } else if (valueToSet instanceof Collection) { // Other collections.
+ return new LinkedHashSet<String>((Collection<String>)
valueToSet);
+ } else if (Object[].class.isAssignableFrom(valueToSet.getClass())) { //
Array
+ return new LinkedHashSet<String>(Arrays.asList((String[])
valueToSet));
+ } else if (valueToSet instanceof String) { // Tokenize string.
+ String areasString = ((String) valueToSet).trim();
+
+ if (areasString.contains(",") || areasString.contains("
")) {
+ String[] values;
+ if (idsSet) {
+ values = IdSplitBuilder.split(areasString);
+ } else {
+ values = ID_SPLIT_PATTERN.split(areasString);
+ }
+
+ Set<String> result = new
LinkedHashSet<String>(values.length);
+ for (String value : values) {
+ if (Strings.isNullOrEmpty(value)) {
+ continue;
+ }
+
+ result.add(value);
+ }
+
+ return result;
+ } else {
+ Set<String> areasSet = new LinkedHashSet<String>(5);
+
+ if (!Strings.isNullOrEmpty(areasString)) {
+ areasSet.add(areasString);
+ }
+
+ return areasSet;
+ }
+ }
+ }
+
+ return null;
+ }
+
+
+ /**
+ * Calculate, must be component render only given areas, or all sended from
+ * server.
+ *
+ * @param component
+ * @return <code>true</code> if client must render ONLY given areas.
+ */
+ public static boolean isAjaxLimitRender(UIComponent component) {
+ boolean result = false;
+
+ if (component instanceof AjaxComponent) {
+ result = ((AjaxComponent) component).isLimitRender();
+ } else {
+ try {
+ result = ((Boolean)
component.getAttributes().get(LIMITRENDER_ATTR_NAME)).booleanValue();
+ } catch (NullPointerException e) {
+
+ // NullPointer - ignore ...
+ } catch (ClassCastException e1) {
+
+ // not Boolean - false ...
+ }
+ }
+
+ return result;
+ }
+
+
+ /**
+ * Get function name for call on completed ajax request.
+ *
+ * @param component for wich calculate function name
+ * @return name of JavaScript function or <code>null</code>
+ */
+ //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 <code>null</code>
+ */
+ //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_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);
+ }
+
+}
Copied:
branches/RF-7560/core/api/src/main/java/org/richfaces/renderkit/util/HtmlDimensions.java
(from rev 19119,
branches/RF-7560/core/impl/src/main/java/org/richfaces/renderkit/util/HtmlDimensions.java)
===================================================================
---
branches/RF-7560/core/api/src/main/java/org/richfaces/renderkit/util/HtmlDimensions.java
(rev 0)
+++
branches/RF-7560/core/api/src/main/java/org/richfaces/renderkit/util/HtmlDimensions.java 2010-09-06
15:48:48 UTC (rev 19123)
@@ -0,0 +1,90 @@
+/**
+ * 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-1301 USA
+ */
+
+package org.richfaces.renderkit.util;
+
+import java.text.DecimalFormat;
+import java.text.NumberFormat;
+import java.text.ParseException;
+import java.util.regex.Pattern;
+
+import org.ajax4jsf.Messages;
+
+public final class HtmlDimensions {
+ private static final Pattern PATTERN_NUMERIC =
Pattern.compile("^[+-]?\\d+(\\.\\d+)?$");
+ private static final Pattern PATTERN_PX =
Pattern.compile("^[+-]?\\d+(\\.\\d+)?px$");
+ private static final Pattern PATTERN_PCT =
Pattern.compile("^[+-]?\\d+(\\.\\d+)?%$");
+ private static final NumberFormat NUMERIC_FORMAT = new DecimalFormat();
+ private static final DecimalFormat PX_FORMAT = new DecimalFormat();
+ private static final NumberFormat PCT_FORMAT = NumberFormat.getPercentInstance();
+
+ static {
+ PX_FORMAT.setPositiveSuffix("px");
+ PX_FORMAT.setNegativeSuffix("px");
+ }
+
+ private HtmlDimensions() {
+ }
+
+ public static Double decode(String size) {
+
+ // TODO - handle px,ex,pt enc suffixes.
+ double d = 0;
+
+ try {
+ if (size != null) {
+ if (PATTERN_NUMERIC.matcher(size).matches()) {
+ synchronized (NUMERIC_FORMAT) {
+ d = NUMERIC_FORMAT.parse(size).doubleValue();
+ }
+ } else if (PATTERN_PX.matcher(size).matches()) {
+ synchronized (PX_FORMAT) {
+ d = PX_FORMAT.parse(size).doubleValue();
+ }
+ } else if (PATTERN_PCT.matcher(size).matches()) {
+ synchronized (PCT_FORMAT) {
+ d = PCT_FORMAT.parse(size).doubleValue();
+ }
+ }
+ }
+ } catch (ParseException e) {
+ throw new
IllegalArgumentException(Messages.getMessage(Messages.DECODE_PARAMETER_ERROR,
+ new Object[]{"size",
+ size, e.getMessage()}));
+ }
+
+ return new Double(d);
+ }
+
+ public static String formatPx(Double value) {
+ return value.intValue() + "px";
+ }
+
+ public static String formatPct(Double value) {
+ String v = "";
+
+ synchronized (PCT_FORMAT) {
+ v = PCT_FORMAT.format(value.doubleValue());
+ }
+
+ return v;
+ }
+}
Copied:
branches/RF-7560/core/api/src/main/java/org/richfaces/renderkit/util/IdSplitBuilder.java
(from rev 19119,
branches/RF-7560/core/impl/src/main/java/org/richfaces/renderkit/util/IdSplitBuilder.java)
===================================================================
---
branches/RF-7560/core/api/src/main/java/org/richfaces/renderkit/util/IdSplitBuilder.java
(rev 0)
+++
branches/RF-7560/core/api/src/main/java/org/richfaces/renderkit/util/IdSplitBuilder.java 2010-09-06
15:48:48 UTC (rev 19123)
@@ -0,0 +1,150 @@
+/*
+ * 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 = 3;
+
+ private enum State {
+ IN_ID (true) {
+
+ @Override
+ public State getNextState(char c) {
+ if (c == '[') {
+ 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 == ']') {
+ return State.IN_ID;
+ } else {
+ return this;
+ }
+ }
+ },
+ OUTSIDE_ID (false) {
+
+ @Override
+ public State getNextState(char c) {
+ if (!isSeparator(c)) {
+ if (c == '[') {
+ return State.IN_ID_INSIDE_BRACKETS;
+ } else {
+ return State.IN_ID;
+ }
+ }
+
+ return this;
+ }
+ };
+
+ private final boolean idSegment;
+
+ private State(boolean idSegment) {
+ this.idSegment = idSegment;
+ }
+
+ private static boolean isSeparator(char c) {
+ return c == ',' || Character.isWhitespace(c);
+ }
+
+ public abstract State getNextState(char c);
+
+ public boolean isIdSegment() {
+ return idSegment;
+ }
+
+ public void processChar(IdSplitBuilder builder, char c, int charIdx) {
+ State nextState = getNextState(c);
+
+ if (nextState.isIdSegment() ^ isIdSegment()) {
+ if (nextState.isIdSegment()) {
+ builder.setStartIndex(charIdx);
+ } else {
+ builder.flushBuilder(charIdx);
+ builder.setStartIndex(-1);
+ }
+ }
+
+ builder.state = nextState;
+ }
+ }
+
+ private int startIdx = -1;
+
+ private String sourceString;
+
+ private List<String> result = new
ArrayList<String>(INITIAL_SPLIT_LIST_SIZE);
+
+ private State state = State.OUTSIDE_ID;
+
+ private IdSplitBuilder(String sourceString) {
+ super();
+ this.sourceString = sourceString;
+ }
+
+ private void setStartIndex(int idx) {
+ startIdx = idx;
+ }
+
+ private void flushBuilder(int endIdx) {
+ if (startIdx >= 0 && endIdx > startIdx) {
+ String id = sourceString.substring(startIdx, endIdx);
+ result.add(id);
+ }
+ }
+
+ private void build() {
+ int length = sourceString.length();
+ for (int i = 0; i < length; i++) {
+ char c = 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 = new IdSplitBuilder(s);
+ splitBuilder.build();
+ return splitBuilder.getSplit();
+ }
+
+}
\ No newline at end of file
Copied: branches/RF-7560/core/api/src/main/java/org/richfaces/util/LRUMap.java (from rev
19119, branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/util/LRUMap.java)
===================================================================
--- branches/RF-7560/core/api/src/main/java/org/richfaces/util/LRUMap.java
(rev 0)
+++ branches/RF-7560/core/api/src/main/java/org/richfaces/util/LRUMap.java 2010-09-06
15:48:48 UTC (rev 19123)
@@ -0,0 +1,62 @@
+/**
+ * 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-1301 USA
+ */
+
+package org.richfaces.util;
+
+import java.io.Serializable;
+import java.util.LinkedHashMap;
+import java.util.Map.Entry;
+
+/**
+ * Last Recent Used Map cache. See {@link LinkedHashMap} for details.
+ *
+ * @author asmirnov
+ */
+public class LRUMap<K, V> extends LinkedHashMap<K, V> implements Serializable
{
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -7232885382582796665L;
+ private int capacity;
+
+ /**
+ * Default capacity constructor
+ */
+ public LRUMap() {
+ this(1000);
+ }
+
+ /**
+ * @param capacity - maximal cache capacity.
+ */
+ public LRUMap(int capacity) {
+ super(capacity, 1.0f, true);
+ this.capacity = capacity;
+ }
+
+ protected boolean removeEldestEntry(Entry<K, V> entry) {
+
+ // Remove last entry if size exceeded.
+ return size() > capacity;
+ }
+
+}
Copied: branches/RF-7560/core/api/src/test/java/org/richfaces/util/LRUMapTest.java (from
rev 19119, branches/RF-7560/core/impl/src/test/java/org/ajax4jsf/util/LRUMapTest.java)
===================================================================
--- branches/RF-7560/core/api/src/test/java/org/richfaces/util/LRUMapTest.java
(rev 0)
+++ branches/RF-7560/core/api/src/test/java/org/richfaces/util/LRUMapTest.java 2010-09-06
15:48:48 UTC (rev 19123)
@@ -0,0 +1,116 @@
+/**
+ * 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-1301 USA
+ */
+
+
+
+package org.richfaces.util;
+
+import java.util.Iterator;
+import java.util.Map.Entry;
+
+import org.richfaces.util.LRUMap;
+
+import junit.framework.TestCase;
+
+/**
+ * @author asmirnov
+ *
+ */
+public class LRUMapTest extends TestCase {
+
+ /**
+ * @param name
+ */
+ public LRUMapTest(String name) {
+ super(name);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see junit.framework.TestCase#tearDown()
+ */
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ /**
+ * Test method for {@link org.richfaces.util.LRUMap#LRUMap(int)}.
+ */
+ public void testLRUMap() {
+ LRUMap map = new LRUMap(5);
+
+ for (int i = 0; i < 10; i++) {
+ map.put(new Integer(i), "Val" + (new Integer(i)));
+ }
+
+ assertEquals(map.size(), 5);
+ }
+
+ /**
+ * Test method for {@link
org.richfaces.util.LRUMap#removeEldestEntry(java.util.Map.Entry)}.
+ */
+ public void testRemoveEldestEntryEntry() {
+ LRUMap map = new LRUMap(5) {
+ protected boolean removeEldestEntry(Entry arg0) {
+ boolean eldestEntry = super.removeEldestEntry(arg0);
+
+ assertTrue(eldestEntry ^ size() <= 5);
+
+ return false;
+ }
+ };
+
+ for (int i = 0; i < 10; i++) {
+ map.put(new Integer(i), "Val" + (new Integer(i)));
+ }
+ }
+
+ /**
+ * Test method for {@link java.util.HashMap#put(K, V)}.
+ */
+ public void testPut() {
+ LRUMap map = new LRUMap(5);
+
+ for (int i = 0; i < 10; i++) {
+ map.put(new Integer(i), "Val" + (new Integer(i)));
+ }
+
+ assertEquals(map.size(), 5);
+
+ Iterator iterator = map.values().iterator();
+
+ for (int i = 5; i < 10; i++) {
+ assertTrue(iterator.hasNext());
+ assertEquals("Val" + (new Integer(i)), iterator.next());
+ }
+
+ assertFalse(iterator.hasNext());
+ }
+
+}
Deleted:
branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/renderkit/AJAXDataSerializer.java
===================================================================
---
branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/renderkit/AJAXDataSerializer.java 2010-09-06
15:37:00 UTC (rev 19122)
+++
branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/renderkit/AJAXDataSerializer.java 2010-09-06
15:48:48 UTC (rev 19123)
@@ -1,34 +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-1301 USA
- */
-
-package org.ajax4jsf.renderkit;
-
-import org.ajax4jsf.javascript.ScriptUtils;
-
-/**
- * @author shura
- */
-public class AJAXDataSerializer {
-
- public String asString(Object data) {
- return ScriptUtils.toScript(data);
- }
-}
Modified:
branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/util/GenericsIntrospectionCache.java
===================================================================
---
branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/util/GenericsIntrospectionCache.java 2010-09-06
15:37:00 UTC (rev 19122)
+++
branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/util/GenericsIntrospectionCache.java 2010-09-06
15:48:48 UTC (rev 19123)
@@ -21,6 +21,7 @@
package org.ajax4jsf.util;
+import org.richfaces.util.LRUMap;
import org.richfaces.util.ReferenceMap;
import javax.faces.context.ExternalContext;
Deleted: branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/util/LRUMap.java
===================================================================
--- branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/util/LRUMap.java 2010-09-06
15:37:00 UTC (rev 19122)
+++ branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/util/LRUMap.java 2010-09-06
15:48:48 UTC (rev 19123)
@@ -1,78 +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-1301 USA
- */
-
-package org.ajax4jsf.util;
-
-import java.io.Serializable;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.Map.Entry;
-
-/**
- * Last Recent Used Map cache. See {@link LinkedHashMap} for details.
- *
- * @author asmirnov
- */
-public class LRUMap<K, V> extends LinkedHashMap<K, V> implements Serializable
{
-
- /**
- *
- */
- private static final long serialVersionUID = -7232885382582796665L;
- private int capacity;
-
- /**
- * Default capacity constructor
- */
- public LRUMap() {
- this(1000);
- }
-
- /**
- * @param capacity - maximal cache capacity.
- */
- public LRUMap(int capacity) {
- super(capacity, 1.0f, true);
- this.capacity = capacity;
- }
-
- protected boolean removeEldestEntry(Entry<K, V> entry) {
-
- // Remove last entry if size exceeded.
- return size() > capacity;
- }
-
- /**
- * Get most recent used element
- *
- * @return the most Recent value
- */
- public V getMostRecent() {
- Iterator<V> iterator = values().iterator();
- V mostRecent = null;
-
- while (iterator.hasNext()) {
- mostRecent = iterator.next();
- }
-
- return mostRecent;
- }
-}
Modified:
branches/RF-7560/core/impl/src/main/java/org/richfaces/application/DefaultModule.java
===================================================================
---
branches/RF-7560/core/impl/src/main/java/org/richfaces/application/DefaultModule.java 2010-09-06
15:37:00 UTC (rev 19122)
+++
branches/RF-7560/core/impl/src/main/java/org/richfaces/application/DefaultModule.java 2010-09-06
15:48:48 UTC (rev 19123)
@@ -1,10 +1,11 @@
package org.richfaces.application;
-import org.ajax4jsf.renderkit.AJAXDataSerializer;
import org.richfaces.application.configuration.ConfigurationService;
import org.richfaces.application.configuration.ConfigurationServiceImpl;
import org.richfaces.cache.Cache;
import org.richfaces.l10n.BundleLoader;
+import org.richfaces.renderkit.AjaxDataSerializer;
+import org.richfaces.renderkit.AjaxDataSerializerImpl;
import org.richfaces.resource.DefaultResourceCodec;
import org.richfaces.resource.ResourceCodec;
import org.richfaces.skin.SkinFactory;
@@ -15,7 +16,7 @@
public void configure(ServicesFactory factory) {
factory.setInstance(ConfigurationService.class, new ConfigurationServiceImpl());
factory.setInstance(SkinFactory.class, new SkinFactoryImpl());
- factory.setInstance(AJAXDataSerializer.class,new AJAXDataSerializer());
+ factory.setInstance(AjaxDataSerializer.class, new AjaxDataSerializerImpl());
factory.setInstance(ResourceCodec.class,ServiceLoader.loadService(ResourceCodec.class,
DefaultResourceCodec.class));
factory.setInstance(Cache.class,new CacheProvider());
factory.setInstance(Uptime.class, new Uptime());
Modified: branches/RF-7560/core/impl/src/main/java/org/richfaces/cache/lru/CacheMap.java
===================================================================
---
branches/RF-7560/core/impl/src/main/java/org/richfaces/cache/lru/CacheMap.java 2010-09-06
15:37:00 UTC (rev 19122)
+++
branches/RF-7560/core/impl/src/main/java/org/richfaces/cache/lru/CacheMap.java 2010-09-06
15:48:48 UTC (rev 19123)
@@ -21,7 +21,7 @@
package org.richfaces.cache.lru;
-import org.ajax4jsf.util.LRUMap;
+import org.richfaces.util.LRUMap;
import java.util.PriorityQueue;
Deleted:
branches/RF-7560/core/impl/src/main/java/org/richfaces/context/OnOffResponseWriter.java
===================================================================
---
branches/RF-7560/core/impl/src/main/java/org/richfaces/context/OnOffResponseWriter.java 2010-09-06
15:37:00 UTC (rev 19122)
+++
branches/RF-7560/core/impl/src/main/java/org/richfaces/context/OnOffResponseWriter.java 2010-09-06
15:48:48 UTC (rev 19123)
@@ -1,101 +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.context;
-
-import java.io.IOException;
-import java.io.Writer;
-
-import javax.faces.context.ResponseWriter;
-import javax.faces.context.ResponseWriterWrapper;
-
-/**
- * @author Nick Belaevski
- *
- */
-public class OnOffResponseWriter extends ResponseWriterWrapper {
-
- private static final Writer NO_OP_WRITER = new Writer() {
-
- @Override
- public void write(char[] cbuf, int off, int len) throws IOException {
- //do nothing
- }
-
- public void write(char[] cbuf) throws IOException {
- //do nothing
- };
-
- public void write(int c) throws IOException {
- //do nothing
- };
-
- public void write(String str) throws IOException {
- //do nothing
- };
-
- public void write(String str, int off, int len) throws IOException {
- //do nothing
- };
-
- @Override
- public void flush() throws IOException {
- //do nothing
- }
-
- @Override
- public void close() throws IOException {
- //do nothing
- }
- };
-
- private boolean switchedOn = false;
-
- private ResponseWriter wrappedWriter;
-
- private ResponseWriter stubWriter;
-
- public OnOffResponseWriter(ResponseWriter wrappedWriter) {
- super();
- this.wrappedWriter = wrappedWriter;
- }
-
- @Override
- public ResponseWriter getWrapped() {
- if (!switchedOn) {
- if (stubWriter == null) {
- stubWriter = wrappedWriter.cloneWithWriter(NO_OP_WRITER);
- }
-
- return stubWriter;
- } else {
- return wrappedWriter;
- }
- }
-
- public void setSwitchedOn(boolean newState) {
- switchedOn = newState;
- }
-
- public boolean isSwitchedOn() {
- return switchedOn;
- }
-}
Added:
branches/RF-7560/core/impl/src/main/java/org/richfaces/renderkit/AjaxDataSerializerImpl.java
===================================================================
---
branches/RF-7560/core/impl/src/main/java/org/richfaces/renderkit/AjaxDataSerializerImpl.java
(rev 0)
+++
branches/RF-7560/core/impl/src/main/java/org/richfaces/renderkit/AjaxDataSerializerImpl.java 2010-09-06
15:48:48 UTC (rev 19123)
@@ -0,0 +1,36 @@
+/*
+ * 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;
+
+import org.ajax4jsf.javascript.ScriptUtils;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class AjaxDataSerializerImpl implements AjaxDataSerializer {
+
+ public String asString(Object data) {
+ return ScriptUtils.toScript(data);
+ }
+
+}
Modified:
branches/RF-7560/core/impl/src/main/java/org/richfaces/renderkit/html/images/SpinnerButtonGradient.java
===================================================================
---
branches/RF-7560/core/impl/src/main/java/org/richfaces/renderkit/html/images/SpinnerButtonGradient.java 2010-09-06
15:37:00 UTC (rev 19122)
+++
branches/RF-7560/core/impl/src/main/java/org/richfaces/renderkit/html/images/SpinnerButtonGradient.java 2010-09-06
15:48:48 UTC (rev 19123)
@@ -23,6 +23,7 @@
import org.richfaces.renderkit.html.BaseGradient;
+
public class SpinnerButtonGradient extends BaseGradient {
public SpinnerButtonGradient() {
super(30, 50, 20, "headerGradientColor",
"headerBackgroundColor");
Modified:
branches/RF-7560/core/impl/src/main/java/org/richfaces/renderkit/html/images/SpinnerFieldGradient.java
===================================================================
---
branches/RF-7560/core/impl/src/main/java/org/richfaces/renderkit/html/images/SpinnerFieldGradient.java 2010-09-06
15:37:00 UTC (rev 19122)
+++
branches/RF-7560/core/impl/src/main/java/org/richfaces/renderkit/html/images/SpinnerFieldGradient.java 2010-09-06
15:48:48 UTC (rev 19123)
@@ -23,6 +23,7 @@
import org.richfaces.renderkit.html.BaseGradient;
+
public class SpinnerFieldGradient extends BaseGradient {
public SpinnerFieldGradient() {
Deleted:
branches/RF-7560/core/impl/src/main/java/org/richfaces/renderkit/util/CoreAjaxRendererUtils.java
===================================================================
---
branches/RF-7560/core/impl/src/main/java/org/richfaces/renderkit/util/CoreAjaxRendererUtils.java 2010-09-06
15:37:00 UTC (rev 19122)
+++
branches/RF-7560/core/impl/src/main/java/org/richfaces/renderkit/util/CoreAjaxRendererUtils.java 2010-09-06
15:48:48 UTC (rev 19123)
@@ -1,343 +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-1301 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.LinkedHashSet;
-import java.util.Map;
-import java.util.Set;
-import java.util.regex.Pattern;
-
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.context.PartialResponseWriter;
-
-import org.ajax4jsf.component.AjaxComponent;
-import org.ajax4jsf.context.AjaxContext;
-import org.ajax4jsf.renderkit.AJAXDataSerializer;
-import org.richfaces.application.ServiceTracker;
-import org.richfaces.log.Logger;
-import org.richfaces.log.RichfacesLogger;
-import org.richfaces.renderkit.HtmlConstants;
-
-import com.google.common.base.Strings;
-
-
-/**
- * @author shura
- * <p/>
- * Some utilites for render AJAX components.
- */
-public final class CoreAjaxRendererUtils {
-
- /**
- * Attribute for keep JavaScript function name for call before updating
- * DOM tree.
- */
- public static final String ONBEFOREDOMUPDATE_ATTR_NAME =
"onbeforedomupdate";
-
- /**
- * Attribute for keep JavaScript function name for call after complete
- * request.
- */
- public static final String ONCOMPLETE_ATTR_NAME = "oncomplete";
-
- public static final String DATA_ATTR_NAME = "data";
-
- /**
- * Attribute to keep
- */
- public static final String LIMITRENDER_ATTR_NAME = "limitRender";
-
- /**
- * @since 3.3.0
- */
- public static final String AJAX_PROCESS_ATTRIBUTE = "process";
- public static final String AJAX_REGIONS_ATTRIBUTE = "reRender";
-
- private static final Logger LOG = RichfacesLogger.RENDERKIT.getLogger();
-
- private static final String EXTENSION_ID = "org.richfaces.extension";
-
- private static final String BEFOREDOMUPDATE_ELEMENT_NAME =
"beforedomupdate";
- private static final String COMPLETE_ELEMENT_NAME = "complete";
- private static final String DATA_ELEMENT_NAME = "data";
- private static final String COMPONENT_DATA_ELEMENT_NAME = "componentData";
- private static final Class<?> STRING_ARRAY_CLASS = String[].class;
- private static final Pattern ID_SPLIT_PATTERN =
Pattern.compile("\\s*(\\s|,)\\s*");
-
- private CoreAjaxRendererUtils() {
- }
-
- private static void startExtensionElementIfNecessary(
- PartialResponseWriter partialResponseWriter,
- Map<String, String> attributes,
- boolean[] writingState) throws IOException {
-
- if (!writingState[0]) {
- writingState[0] = true;
-
- partialResponseWriter.startExtension(attributes);
- }
- }
-
- private static void endExtensionElementIfNecessary(
- PartialResponseWriter partialResponseWriter,
- boolean[] writingState) throws IOException {
-
- if (writingState[0]) {
- writingState[0] = false;
-
- partialResponseWriter.endExtension();
- }
- }
-
- public static void renderAjaxExtensions(FacesContext facesContext, UIComponent
component) throws IOException {
- AjaxContext ajaxContext = AjaxContext.getCurrentInstance(facesContext);
-
- Map<String, String> attributes =
Collections.singletonMap(HtmlConstants.ID_ATTRIBUTE,
- facesContext.getExternalContext().encodeNamespace(EXTENSION_ID));
- PartialResponseWriter writer =
facesContext.getPartialViewContext().getPartialResponseWriter();
- boolean[] writingState = new boolean[]{false};
-
- Object onbeforedomupdate = ajaxContext.getOnbeforedomupdate();
- if (onbeforedomupdate != null) {
- String string = onbeforedomupdate.toString();
- if (string.length() != 0) {
- startExtensionElementIfNecessary(writer, attributes, writingState);
- writer.startElement(BEFOREDOMUPDATE_ELEMENT_NAME, component);
- writer.writeText(onbeforedomupdate, null);
- writer.endElement(BEFOREDOMUPDATE_ELEMENT_NAME);
- }
- }
-
- Object oncomplete = ajaxContext.getOncomplete();
- if (oncomplete != null) {
- String string = oncomplete.toString();
- if (string.length() != 0) {
- startExtensionElementIfNecessary(writer, attributes, writingState);
- writer.startElement(COMPLETE_ELEMENT_NAME, component);
- writer.writeText(oncomplete, null);
- writer.endElement(COMPLETE_ELEMENT_NAME);
- }
- }
-
- Object responseData = ajaxContext.getResponseData();
- if (responseData != null) {
- startExtensionElementIfNecessary(writer, attributes, writingState);
- writer.startElement(DATA_ELEMENT_NAME, component);
-
- AJAXDataSerializer serializer = ServiceTracker.getService(facesContext,
AJAXDataSerializer.class);
- writer.writeText(serializer.asString(responseData), null);
-
- writer.endElement(DATA_ELEMENT_NAME);
- }
-
- Map<String, Object> responseComponentDataMap =
ajaxContext.getResponseComponentDataMap();
- if (responseComponentDataMap != null &&
!responseComponentDataMap.isEmpty()) {
- startExtensionElementIfNecessary(writer, attributes, writingState);
- writer.startElement(COMPONENT_DATA_ELEMENT_NAME, component);
-
- AJAXDataSerializer serializer = ServiceTracker.getService(facesContext,
AJAXDataSerializer.class);
- writer.writeText(serializer.asString(responseComponentDataMap), null);
-
- writer.endElement(COMPONENT_DATA_ELEMENT_NAME);
- }
-
- endExtensionElementIfNecessary(writer, writingState);
-
- }
-
- /**
- * Split parameter string into array of strings.
- * @param valuesSet
- * @return
- */
- public static String[] asIdsArray(String valuesSet) {
- return IdSplitBuilder.split(valuesSet);
- }
-
- /**
- * Get list of clientId's for given component
- *
- * @param uiComponent
- * @return List of areas Id's , updated by this component.
- */
- public static Set<String> getAjaxAreas(UIComponent uiComponent) {
- Object areas;
-
- if (uiComponent instanceof AjaxComponent) {
- areas = ((AjaxComponent) uiComponent).getReRender();
- } else {
- areas = uiComponent.getAttributes().get(AJAX_REGIONS_ATTRIBUTE);
- }
-
- return asIdsSet(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<String> getAjaxAreasToProcess(UIComponent component) {
- Object areas;
-
- if (component instanceof AjaxComponent) {
- areas = ((AjaxComponent) component).getProcess();
- } else {
- areas = component.getAttributes().get(AJAX_PROCESS_ATTRIBUTE);
- }
-
- return asIdsSet(areas);
- }
-
- public static Set<String> asIdsSet(Object valueToSet) {
- return asSet(valueToSet, true);
- }
-
- //TODO - remove code duplication
- @SuppressWarnings("unchecked")
- private static Set<String> asSet(Object valueToSet, boolean idsSet) {
- if (null != valueToSet) {
-
- // Simplest case - set.
- if (valueToSet instanceof Set) {
- return new LinkedHashSet<String>((Set<String>) valueToSet);
- } else if (valueToSet instanceof Collection) { // Other collections.
- return new LinkedHashSet<String>((Collection<String>)
valueToSet);
- } else if (Object[].class.isAssignableFrom(valueToSet.getClass())) { //
Array
- return new LinkedHashSet<String>(Arrays.asList((String[])
valueToSet));
- } else if (valueToSet instanceof String) { // Tokenize string.
- String areasString = ((String) valueToSet).trim();
-
- if (areasString.contains(",") || areasString.contains("
")) {
- String[] values;
- if (idsSet) {
- values = IdSplitBuilder.split(areasString);
- } else {
- values = ID_SPLIT_PATTERN.split(areasString);
- }
-
- Set<String> result = new
LinkedHashSet<String>(values.length);
- for (String value : values) {
- if (Strings.isNullOrEmpty(value)) {
- continue;
- }
-
- result.add(value);
- }
-
- return result;
- } else {
- Set<String> areasSet = new LinkedHashSet<String>(5);
-
- if (!Strings.isNullOrEmpty(areasString)) {
- areasSet.add(areasString);
- }
-
- return areasSet;
- }
- }
- }
-
- return null;
- }
-
-
- /**
- * Calculate, must be component render only given areas, or all sended from
- * server.
- *
- * @param component
- * @return <code>true</code> if client must render ONLY given areas.
- */
- public static boolean isAjaxLimitRender(UIComponent component) {
- boolean result = false;
-
- if (component instanceof AjaxComponent) {
- result = ((AjaxComponent) component).isLimitRender();
- } else {
- try {
- result = ((Boolean)
component.getAttributes().get(LIMITRENDER_ATTR_NAME)).booleanValue();
- } catch (NullPointerException e) {
-
- // NullPointer - ignore ...
- } catch (ClassCastException e1) {
-
- // not Boolean - false ...
- }
- }
-
- return result;
- }
-
-
- /**
- * Get function name for call on completed ajax request.
- *
- * @param component for wich calculate function name
- * @return name of JavaScript function or <code>null</code>
- */
- //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 <code>null</code>
- */
- //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_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);
- }
-
-}
Deleted:
branches/RF-7560/core/impl/src/main/java/org/richfaces/renderkit/util/HtmlDimensions.java
===================================================================
---
branches/RF-7560/core/impl/src/main/java/org/richfaces/renderkit/util/HtmlDimensions.java 2010-09-06
15:37:00 UTC (rev 19122)
+++
branches/RF-7560/core/impl/src/main/java/org/richfaces/renderkit/util/HtmlDimensions.java 2010-09-06
15:48:48 UTC (rev 19123)
@@ -1,90 +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-1301 USA
- */
-
-package org.richfaces.renderkit.util;
-
-import java.text.DecimalFormat;
-import java.text.NumberFormat;
-import java.text.ParseException;
-import java.util.regex.Pattern;
-
-import org.ajax4jsf.Messages;
-
-public final class HtmlDimensions {
- private static final Pattern PATTERN_NUMERIC =
Pattern.compile("^[+-]?\\d+(\\.\\d+)?$");
- private static final Pattern PATTERN_PX =
Pattern.compile("^[+-]?\\d+(\\.\\d+)?px$");
- private static final Pattern PATTERN_PCT =
Pattern.compile("^[+-]?\\d+(\\.\\d+)?%$");
- private static final NumberFormat NUMERIC_FORMAT = new DecimalFormat();
- private static final DecimalFormat PX_FORMAT = new DecimalFormat();
- private static final NumberFormat PCT_FORMAT = NumberFormat.getPercentInstance();
-
- static {
- PX_FORMAT.setPositiveSuffix("px");
- PX_FORMAT.setNegativeSuffix("px");
- }
-
- private HtmlDimensions() {
- }
-
- public static Double decode(String size) {
-
- // TODO - handle px,ex,pt enc suffixes.
- double d = 0;
-
- try {
- if (size != null) {
- if (PATTERN_NUMERIC.matcher(size).matches()) {
- synchronized (NUMERIC_FORMAT) {
- d = NUMERIC_FORMAT.parse(size).doubleValue();
- }
- } else if (PATTERN_PX.matcher(size).matches()) {
- synchronized (PX_FORMAT) {
- d = PX_FORMAT.parse(size).doubleValue();
- }
- } else if (PATTERN_PCT.matcher(size).matches()) {
- synchronized (PCT_FORMAT) {
- d = PCT_FORMAT.parse(size).doubleValue();
- }
- }
- }
- } catch (ParseException e) {
- throw new
IllegalArgumentException(Messages.getMessage(Messages.DECODE_PARAMETER_ERROR,
- new Object[]{"size",
- size, e.getMessage()}));
- }
-
- return new Double(d);
- }
-
- public static String formatPx(Double value) {
- return value.intValue() + "px";
- }
-
- public static String formatPct(Double value) {
- String v = "";
-
- synchronized (PCT_FORMAT) {
- v = PCT_FORMAT.format(value.doubleValue());
- }
-
- return v;
- }
-}
Deleted:
branches/RF-7560/core/impl/src/main/java/org/richfaces/renderkit/util/IdSplitBuilder.java
===================================================================
---
branches/RF-7560/core/impl/src/main/java/org/richfaces/renderkit/util/IdSplitBuilder.java 2010-09-06
15:37:00 UTC (rev 19122)
+++
branches/RF-7560/core/impl/src/main/java/org/richfaces/renderkit/util/IdSplitBuilder.java 2010-09-06
15:48:48 UTC (rev 19123)
@@ -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 = 3;
-
- private enum State {
- IN_ID (true) {
-
- @Override
- public State getNextState(char c) {
- if (c == '[') {
- 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 == ']') {
- return State.IN_ID;
- } else {
- return this;
- }
- }
- },
- OUTSIDE_ID (false) {
-
- @Override
- public State getNextState(char c) {
- if (!isSeparator(c)) {
- if (c == '[') {
- return State.IN_ID_INSIDE_BRACKETS;
- } else {
- return State.IN_ID;
- }
- }
-
- return this;
- }
- };
-
- private final boolean idSegment;
-
- private State(boolean idSegment) {
- this.idSegment = idSegment;
- }
-
- private static boolean isSeparator(char c) {
- return c == ',' || Character.isWhitespace(c);
- }
-
- public abstract State getNextState(char c);
-
- public boolean isIdSegment() {
- return idSegment;
- }
-
- public void processChar(IdSplitBuilder builder, char c, int charIdx) {
- State nextState = getNextState(c);
-
- if (nextState.isIdSegment() ^ isIdSegment()) {
- if (nextState.isIdSegment()) {
- builder.setStartIndex(charIdx);
- } else {
- builder.flushBuilder(charIdx);
- builder.setStartIndex(-1);
- }
- }
-
- builder.state = nextState;
- }
- }
-
- private int startIdx = -1;
-
- private String sourceString;
-
- private List<String> result = new
ArrayList<String>(INITIAL_SPLIT_LIST_SIZE);
-
- private State state = State.OUTSIDE_ID;
-
- private IdSplitBuilder(String sourceString) {
- super();
- this.sourceString = sourceString;
- }
-
- private void setStartIndex(int idx) {
- startIdx = idx;
- }
-
- private void flushBuilder(int endIdx) {
- if (startIdx >= 0 && endIdx > startIdx) {
- String id = sourceString.substring(startIdx, endIdx);
- result.add(id);
- }
- }
-
- private void build() {
- int length = sourceString.length();
- for (int i = 0; i < length; i++) {
- char c = 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 = new IdSplitBuilder(s);
- splitBuilder.build();
- return splitBuilder.getSplit();
- }
-
-}
\ No newline at end of file
Deleted: branches/RF-7560/core/impl/src/test/java/org/ajax4jsf/util/LRUMapTest.java
===================================================================
--- branches/RF-7560/core/impl/src/test/java/org/ajax4jsf/util/LRUMapTest.java 2010-09-06
15:37:00 UTC (rev 19122)
+++ branches/RF-7560/core/impl/src/test/java/org/ajax4jsf/util/LRUMapTest.java 2010-09-06
15:48:48 UTC (rev 19123)
@@ -1,132 +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-1301 USA
- */
-
-
-
-package org.ajax4jsf.util;
-
-import java.util.Iterator;
-import java.util.Map.Entry;
-
-import junit.framework.TestCase;
-
-/**
- * @author asmirnov
- *
- */
-public class LRUMapTest extends TestCase {
-
- /**
- * @param name
- */
- public LRUMapTest(String name) {
- super(name);
- }
-
- /*
- * (non-Javadoc)
- * @see junit.framework.TestCase#setUp()
- */
- protected void setUp() throws Exception {
- super.setUp();
- }
-
- /*
- * (non-Javadoc)
- * @see junit.framework.TestCase#tearDown()
- */
- protected void tearDown() throws Exception {
- super.tearDown();
- }
-
- /**
- * Test method for {@link org.ajax4jsf.util.LRUMap#LRUMap(int)}.
- */
- public void testLRUMap() {
- LRUMap map = new LRUMap(5);
-
- for (int i = 0; i < 10; i++) {
- map.put(new Integer(i), "Val" + (new Integer(i)));
- }
-
- assertEquals(map.size(), 5);
- }
-
- /**
- * Test method for {@link
org.ajax4jsf.util.LRUMap#removeEldestEntry(java.util.Map.Entry)}.
- */
- public void testRemoveEldestEntryEntry() {
- LRUMap map = new LRUMap(5) {
- protected boolean removeEldestEntry(Entry arg0) {
- boolean eldestEntry = super.removeEldestEntry(arg0);
-
- assertTrue(eldestEntry ^ size() <= 5);
-
- return false;
- }
- };
-
- for (int i = 0; i < 10; i++) {
- map.put(new Integer(i), "Val" + (new Integer(i)));
- }
- }
-
- /**
- * Test method for {@link java.util.HashMap#put(K, V)}.
- */
- public void testPut() {
- LRUMap map = new LRUMap(5);
-
- for (int i = 0; i < 10; i++) {
- map.put(new Integer(i), "Val" + (new Integer(i)));
- }
-
- assertEquals(map.size(), 5);
-
- Iterator iterator = map.values().iterator();
-
- for (int i = 5; i < 10; i++) {
- assertTrue(iterator.hasNext());
- assertEquals("Val" + (new Integer(i)), iterator.next());
- }
-
- assertFalse(iterator.hasNext());
- }
-
- public void testGetMostRecent() throws Exception {
- LRUMap map = new LRUMap(5);
-
- for (int i = 0; i < 10; i++) {
- String last = "Val" + (new Integer(i));
-
- map.put(new Integer(i), last);
- assertSame(last, map.getMostRecent());
- }
-
- assertEquals(map.size(), 5);
-
- for (int i = 5; i < 10; i++) {
- Object lastGet = map.get(new Integer(i));
-
- assertSame(lastGet, map.getMostRecent());
- }
- }
-}
Modified: branches/RF-7560/examples/iteration-demo/pom.xml
===================================================================
--- branches/RF-7560/examples/iteration-demo/pom.xml 2010-09-06 15:37:00 UTC (rev 19122)
+++ branches/RF-7560/examples/iteration-demo/pom.xml 2010-09-06 15:48:48 UTC (rev 19123)
@@ -63,10 +63,6 @@
<artifactId>richfaces-core-api</artifactId>
</dependency>
<dependency>
- <groupId>org.richfaces.core</groupId>
- <artifactId>richfaces-core-impl</artifactId>
- </dependency>
- <dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache</artifactId>
</dependency>
Modified: branches/RF-7560/examples/misc-demo/pom.xml
===================================================================
--- branches/RF-7560/examples/misc-demo/pom.xml 2010-09-06 15:37:00 UTC (rev 19122)
+++ branches/RF-7560/examples/misc-demo/pom.xml 2010-09-06 15:48:48 UTC (rev 19123)
@@ -53,10 +53,6 @@
<artifactId>richfaces-ui-core-ui</artifactId>
</dependency>
<dependency>
- <groupId>org.richfaces.core</groupId>
- <artifactId>richfaces-core-impl</artifactId>
- </dependency>
- <dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<scope>provided</scope>
Modified: branches/RF-7560/examples/parent/pom.xml
===================================================================
--- branches/RF-7560/examples/parent/pom.xml 2010-09-06 15:37:00 UTC (rev 19122)
+++ branches/RF-7560/examples/parent/pom.xml 2010-09-06 15:48:48 UTC (rev 19123)
@@ -53,6 +53,13 @@
</dependencies>
</dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.richfaces.core</groupId>
+ <artifactId>richfaces-core-impl</artifactId>
+ </dependency>
+ </dependencies>
+
<!-- Build -->
<build>
<!--
Copied:
branches/RF-7560/ui/common/ui/src/main/java/org/richfaces/context/OnOffResponseWriter.java
(from rev 19119,
branches/RF-7560/core/impl/src/main/java/org/richfaces/context/OnOffResponseWriter.java)
===================================================================
---
branches/RF-7560/ui/common/ui/src/main/java/org/richfaces/context/OnOffResponseWriter.java
(rev 0)
+++
branches/RF-7560/ui/common/ui/src/main/java/org/richfaces/context/OnOffResponseWriter.java 2010-09-06
15:48:48 UTC (rev 19123)
@@ -0,0 +1,101 @@
+/*
+ * 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.context;
+
+import java.io.IOException;
+import java.io.Writer;
+
+import javax.faces.context.ResponseWriter;
+import javax.faces.context.ResponseWriterWrapper;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class OnOffResponseWriter extends ResponseWriterWrapper {
+
+ private static final Writer NO_OP_WRITER = new Writer() {
+
+ @Override
+ public void write(char[] cbuf, int off, int len) throws IOException {
+ //do nothing
+ }
+
+ public void write(char[] cbuf) throws IOException {
+ //do nothing
+ };
+
+ public void write(int c) throws IOException {
+ //do nothing
+ };
+
+ public void write(String str) throws IOException {
+ //do nothing
+ };
+
+ public void write(String str, int off, int len) throws IOException {
+ //do nothing
+ };
+
+ @Override
+ public void flush() throws IOException {
+ //do nothing
+ }
+
+ @Override
+ public void close() throws IOException {
+ //do nothing
+ }
+ };
+
+ private boolean switchedOn = false;
+
+ private ResponseWriter wrappedWriter;
+
+ private ResponseWriter stubWriter;
+
+ public OnOffResponseWriter(ResponseWriter wrappedWriter) {
+ super();
+ this.wrappedWriter = wrappedWriter;
+ }
+
+ @Override
+ public ResponseWriter getWrapped() {
+ if (!switchedOn) {
+ if (stubWriter == null) {
+ stubWriter = wrappedWriter.cloneWithWriter(NO_OP_WRITER);
+ }
+
+ return stubWriter;
+ } else {
+ return wrappedWriter;
+ }
+ }
+
+ public void setSwitchedOn(boolean newState) {
+ switchedOn = newState;
+ }
+
+ public boolean isSwitchedOn() {
+ return switchedOn;
+ }
+}
Modified:
branches/RF-7560/ui/common/ui/src/main/java/org/richfaces/renderkit/util/AjaxRendererUtils.java
===================================================================
---
branches/RF-7560/ui/common/ui/src/main/java/org/richfaces/renderkit/util/AjaxRendererUtils.java 2010-09-06
15:37:00 UTC (rev 19122)
+++
branches/RF-7560/ui/common/ui/src/main/java/org/richfaces/renderkit/util/AjaxRendererUtils.java 2010-09-06
15:48:48 UTC (rev 19123)
@@ -21,15 +21,9 @@
package org.richfaces.renderkit.util;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.LinkedHashSet;
import java.util.Map;
-import java.util.Set;
-import java.util.regex.Pattern;
import javax.faces.component.UIComponent;
-import javax.faces.component.UIForm;
import javax.faces.context.FacesContext;
import org.ajax4jsf.component.AjaxClientBehavior;
@@ -40,8 +34,6 @@
import org.ajax4jsf.javascript.JSReference;
import org.richfaces.renderkit.AjaxEventOptions;
import org.richfaces.renderkit.HtmlConstants;
-
-import com.google.common.base.Strings;
/**
* @author shura
* <p/>
@@ -80,9 +72,6 @@
public static final String QUEUE_ID_ATTRIBUTE = "queueId";
private static final RendererUtils RENDERER_UTILS = RendererUtils.getInstance();
- private static final Class<?> STRING_ARRAY_CLASS = String[].class;
-
- private static final Pattern ID_SPLIT_PATTERN =
Pattern.compile("\\s*(\\s|,)\\s*");
/**
* Static class - protect constructor
@@ -549,69 +538,6 @@
// }
/**
- * 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.
- */
- public static Set<String> asSet(Object valueToSet) {
- return asSet(valueToSet, false);
- }
-
- public static Set<String> asIdsSet(Object valueToSet) {
- return asSet(valueToSet, true);
- }
-
- @SuppressWarnings("unchecked")
- private static Set<String> asSet(Object valueToSet, boolean idsSet) {
- if (null != valueToSet) {
-
- // Simplest case - set.
- if (valueToSet instanceof Set) {
- return new LinkedHashSet<String>((Set<String>) valueToSet);
- } else if (valueToSet instanceof Collection) { // Other collections.
- return new LinkedHashSet<String>((Collection<String>)
valueToSet);
- } else if (STRING_ARRAY_CLASS.isAssignableFrom(valueToSet.getClass())) { //
Array
- return new LinkedHashSet<String>(Arrays.asList((String[])
valueToSet));
- } else if (valueToSet instanceof String) { // Tokenize string.
- String areasString = ((String) valueToSet).trim();
-
- if (areasString.contains(",") || areasString.contains("
")) {
- String[] values;
- if (idsSet) {
- values = IdSplitBuilder.split(areasString);
- } else {
- values = ID_SPLIT_PATTERN.split(areasString);
- }
-
- Set<String> result = new
LinkedHashSet<String>(values.length);
- for (String value : values) {
- if (Strings.isNullOrEmpty(value)) {
- continue;
- }
-
- result.add(value);
- }
-
- return result;
- } else {
- Set<String> areasSet = new LinkedHashSet<String>(5);
-
- if (!Strings.isNullOrEmpty(areasString)) {
- areasSet.add(areasString);
- }
-
- return areasSet;
- }
- }
- }
-
- return null;
- }
-
- /**
* Get status area Id for given component.
*
* @param component
@@ -673,181 +599,10 @@
return (String) component.getAttributes().get(ONBEGIN_ATTR_NAME);
}
- /**
- * Find nested form for given component
- *
- * @param component
- * @return nested <code>UIForm</code> component, or
<code>null</code>
- */
- public static UIComponent getNestingForm(UIComponent component) {
- UIComponent parent = component;
-
- // Search enclosed UIForm or ADF UIXForm component
- while ((parent != null) && !(parent instanceof UIForm)
- &&
!("org.apache.myfaces.trinidad.Form".equals(parent.getFamily()))
- && !("oracle.adf.Form".equals(parent.getFamily()))) {
- parent = parent.getParent();
- }
-
- return parent;
- }
-
protected static String getAjaxActionUrl(FacesContext facesContext) {
return
AjaxContext.getCurrentInstance(facesContext).getAjaxActionURL(facesContext);
}
-// /**
-// * Encode rendered areas as special HTML tag ( span in current release )
-// *
-// * @param context
-// * @param component
-// * @throws IOException
-// */
-// public static void encodeAreas(FacesContext context, UIComponent component) throws
IOException {
-// AjaxContext ajaxContext = AjaxContext.getCurrentInstance(context);
-// ExternalContext externalContext = context.getExternalContext();
-// Map<String, Object> requestMap = externalContext.getRequestMap();
-// Set<String> rendered = 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 = context.getResponseWriter();
-//
-// // Create <span> 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, component);
-// out.writeAttribute(HTML.NAME_ATTRIBUTE,
AjaxContainerRenderer.AJAX_UPDATE_HEADER, null);
-//
-// StringBuffer senderString = new StringBuffer();
-//
-// for (Iterator<String> it = rendered.iterator(); it.hasNext();) {
-// String id = 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, component);
-// 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 <meta>
-// out.startElement(AjaxContainerRenderer.AJAX_RESULT_GROUP_TAG, component);
-// out.writeAttribute(HTML.ID_ATTRIBUTE, AjaxContainerRenderer.AJAX_FLAG_HEADER,
null);
-// out.writeAttribute(HTML.NAME_ATTRIBUTE, AjaxContainerRenderer.AJAX_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 = 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 = (HttpServletResponse) response;
-//
-// httpResponse.setHeader(AjaxContainerRenderer.AJAX_FLAG_HEADER,
"true");
-// } else {
-// try {
-// Method setHeadergMethod =
response.getClass().getMethod("setHeader",
-// new Class[]{String.class, String.class});
-//
-// setHeadergMethod.invoke(response,
AjaxContainerRenderer.AJAX_FLAG_HEADER, "true");
-// } catch (Exception e) {
-//
LOG.error(Messages.getMessage(Messages.DETECTING_ENCODING_DISABLED_ERROR));
-//
LOG.error(Messages.getMessage(Messages.OBTAIN_RESPONSE_SET_HEADER_ERROR, e));
-// }
-// }
-//
-// Map<String, Object> responseDataMap =
ajaxContext.getResponseComponentDataMap();
-//
-// // Get data serializer instance
-// AJAXDataSerializer serializer = ServiceTracker.getService(context,
AJAXDataSerializer.class);
-//
-// // Put data to JavaScript handlers, inside <span> elements.
-// for (Map.Entry<String, Object> entry : responseDataMap.entrySet()) {
-// out.startElement(HTML.SPAN_ELEM, component);
-// out.writeAttribute(HTML.ID_ATTRIBUTE, entry.getKey(), null);
-//
-// String dataString = serializer.asString(entry.getValue());
-//
-// out.write(dataString);
-// out.endElement(HTML.SPAN_ELEM);
-// }
-//
-// // Include active 'oncomplete' function content :
-// Object oncomplete = ajaxContext.getOncomplete();
-//
-// if (null != 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 stateKey by
-// // real value in XML filter.
-// // if(ajaxContext.isSelfRender()){
-// // saveViewState(context, out);
-// // }
-// requestMap.put(AJAX_AREAS_RENDERED, "true");
-// }
-
-// /**
-// * 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 = (AjaxContainer) component;
-// ResponseWriter out = context.getResponseWriter();
-//
-// // DebugUtils.traceView("ViewRoot in AJAX Page encode begin");
-// out.startElement("html", component);
-//
-// Locale locale = 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 component)
throws IOException {
-//
-// // AjaxContainer ajax = (AjaxContainer) component;
-// ResponseWriter out = context.getResponseWriter();
-//
-// // DebugUtils.traceView("ViewRoot in AJAX Page encode begin");
-// encodeAreas(context, component);
-// out.endElement("body");
-// out.endElement("html");
-// }
-
/**
* @param facesContext
* @return
Modified:
branches/RF-7560/ui/common/ui/src/main/java/org/richfaces/renderkit/util/FormUtil.java
===================================================================
---
branches/RF-7560/ui/common/ui/src/main/java/org/richfaces/renderkit/util/FormUtil.java 2010-09-06
15:37:00 UTC (rev 19122)
+++
branches/RF-7560/ui/common/ui/src/main/java/org/richfaces/renderkit/util/FormUtil.java 2010-09-06
15:48:48 UTC (rev 19123)
@@ -21,12 +21,11 @@
package org.richfaces.renderkit.util;
-import org.richfaces.component.SwitchType;
-
import javax.faces.component.UIComponent;
-import javax.faces.component.UIForm;
import javax.faces.context.FacesContext;
+import org.richfaces.component.SwitchType;
+
/**
* @author Filip Antonov - mailto:fantonov@exadel.com
* created 08.02.2007
@@ -38,7 +37,7 @@
public static void throwEnclFormReqExceptionIfNeed(FacesContext context, UIComponent
component)
throws EnclosingFormRequiredException {
- UIForm form = RendererUtils.getInstance().getNestingForm(context, component);
+ UIComponent form = RendererUtils.getInstance().getNestingForm(context,
component);
// TODO nick -> nick - switchType checking can be harmful here
SwitchType switchType = (SwitchType)
component.getAttributes().get("switchType");
Modified:
branches/RF-7560/ui/common/ui/src/main/java/org/richfaces/renderkit/util/RendererUtils.java
===================================================================
---
branches/RF-7560/ui/common/ui/src/main/java/org/richfaces/renderkit/util/RendererUtils.java 2010-09-06
15:37:00 UTC (rev 19122)
+++
branches/RF-7560/ui/common/ui/src/main/java/org/richfaces/renderkit/util/RendererUtils.java 2010-09-06
15:48:48 UTC (rev 19123)
@@ -759,22 +759,17 @@
* @param component
* @return nested <code>UIForm</code> component, or
<code>null</code>
*/
- public UIForm getNestingForm(FacesContext context, UIComponent component) {
- UIComponent parent = component.getParent();
+ public UIComponent getNestingForm(FacesContext context, UIComponent component) {
+ UIComponent parent = component;
- while ((parent != null) && !(parent instanceof UIForm)) {
+ // Search enclosed UIForm or ADF UIXForm component
+ while ((parent != null) && !(parent instanceof UIForm)
+ &&
!("org.apache.myfaces.trinidad.Form".equals(parent.getFamily()))
+ && !("oracle.adf.Form".equals(parent.getFamily()))) {
parent = parent.getParent();
}
- UIForm nestingForm = null;
-
- if (parent != null) {
-
- // link is nested inside a form
- nestingForm = (UIForm) parent;
- }
-
- return nestingForm;
+ return parent;
}
/**
@@ -784,7 +779,7 @@
* @throws IOException
*/
public void encodeBeginFormIfNessesary(FacesContext context, UIComponent component)
throws IOException {
- UIForm form = getNestingForm(context, component);
+ UIComponent form = getNestingForm(context, component);
if (null == form) {
ResponseWriter writer = context.getResponseWriter();
@@ -824,7 +819,7 @@
* @throws IOException
*/
public void encodeEndFormIfNessesary(FacesContext context, UIComponent component)
throws IOException {
- UIForm form = getNestingForm(context, component);
+ UIComponent form = getNestingForm(context, component);
if (null == form) {
ResponseWriter writer = context.getResponseWriter();
Modified:
branches/RF-7560/ui/core/ui/src/main/java/org/ajax4jsf/component/behavior/AjaxBehavior.java
===================================================================
---
branches/RF-7560/ui/core/ui/src/main/java/org/ajax4jsf/component/behavior/AjaxBehavior.java 2010-09-06
15:37:00 UTC (rev 19122)
+++
branches/RF-7560/ui/core/ui/src/main/java/org/ajax4jsf/component/behavior/AjaxBehavior.java 2010-09-06
15:48:48 UTC (rev 19123)
@@ -47,7 +47,7 @@
import org.richfaces.cdk.annotations.JsfBehavior;
import org.richfaces.cdk.annotations.Tag;
import org.richfaces.cdk.annotations.TagType;
-import org.richfaces.renderkit.util.AjaxRendererUtils;
+import org.richfaces.renderkit.util.CoreAjaxRendererUtils;
/**
* @author Anton Belevich
@@ -119,7 +119,7 @@
}
if (result == null) {
- result = AjaxRendererUtils.asIdsSet(value);
+ result = CoreAjaxRendererUtils.asIdsSet(value);
}
if (result == null) {
Modified:
branches/RF-7560/ui/core/ui/src/main/java/org/richfaces/component/PushListenersManager.java
===================================================================
---
branches/RF-7560/ui/core/ui/src/main/java/org/richfaces/component/PushListenersManager.java 2010-09-06
15:37:00 UTC (rev 19122)
+++
branches/RF-7560/ui/core/ui/src/main/java/org/richfaces/component/PushListenersManager.java 2010-09-06
15:48:48 UTC (rev 19123)
@@ -23,17 +23,21 @@
package org.richfaces.component;
+import java.util.Map;
+
import javax.faces.context.FacesContext;
-import org.ajax4jsf.util.LRUMap;
+import org.richfaces.util.LRUMap;
/**
* @author Nick Belaevski
* @since 4.0
*/
public class PushListenersManager {
+
private static final String CONTEXT_ATTRIBUTE_NAME =
"richFacesPushListenersManager";
- private LRUMap<String, PushEventTracker> listeners;
+
+ private Map<String, PushEventTracker> listeners;
public PushListenersManager() {
Modified:
branches/RF-7560/ui/core/ui/src/main/java/org/richfaces/renderkit/html/QueueRenderer.java
===================================================================
---
branches/RF-7560/ui/core/ui/src/main/java/org/richfaces/renderkit/html/QueueRenderer.java 2010-09-06
15:37:00 UTC (rev 19122)
+++
branches/RF-7560/ui/core/ui/src/main/java/org/richfaces/renderkit/html/QueueRenderer.java 2010-09-06
15:48:48 UTC (rev 19123)
@@ -22,7 +22,6 @@
package org.richfaces.renderkit.html;
import javax.faces.component.UIComponent;
-import javax.faces.component.UIForm;
import javax.faces.context.FacesContext;
import org.richfaces.cdk.annotations.JsfRenderer;
@@ -41,7 +40,7 @@
String nameAttributeValue = (String) comp.getAttributes().get(NAME_ATTRIBBUTE);
if (nameAttributeValue == null || nameAttributeValue.length() == 0) {
- UIForm form = utils.getNestingForm(context, comp);
+ UIComponent form = utils.getNestingForm(context, comp);
if (form != null) {
nameAttributeValue = form.getClientId(context);
} else {
Modified:
branches/RF-7560/ui/misc/ui/src/main/java/org/richfaces/function/RichFunction.java
===================================================================
---
branches/RF-7560/ui/misc/ui/src/main/java/org/richfaces/function/RichFunction.java 2010-09-06
15:37:00 UTC (rev 19122)
+++
branches/RF-7560/ui/misc/ui/src/main/java/org/richfaces/function/RichFunction.java 2010-09-06
15:48:48 UTC (rev 19123)
@@ -28,7 +28,7 @@
import javax.faces.context.FacesContext;
import org.richfaces.cdk.annotations.Function;
-import org.richfaces.renderkit.util.AjaxRendererUtils;
+import org.richfaces.renderkit.util.CoreAjaxRendererUtils;
import org.richfaces.renderkit.util.RendererUtils;
/**
@@ -125,7 +125,7 @@
@Function
public static boolean isUserInRole(Object rolesObject) {
//TODO nick - AjaxRendererUtils split text by commas and whitespace, what is the
right variant?
- Set<String> rolesSet = AjaxRendererUtils.asSet(rolesObject);
+ Set<String> rolesSet = CoreAjaxRendererUtils.asIdsSet(rolesObject);
if (rolesSet != null) {
FacesContext facesContext = FacesContext.getCurrentInstance();
ExternalContext externalContext = facesContext.getExternalContext();
Modified:
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/component/AbstractTogglePanelItem.java
===================================================================
---
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/component/AbstractTogglePanelItem.java 2010-09-06
15:37:00 UTC (rev 19122)
+++
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/component/AbstractTogglePanelItem.java 2010-09-06
15:48:48 UTC (rev 19123)
@@ -22,14 +22,15 @@
package org.richfaces.component;
-import org.richfaces.renderkit.HtmlConstants;
+import java.io.IOException;
+import java.util.Map;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.render.Renderer;
-import java.io.IOException;
-import java.util.Map;
+import org.richfaces.renderkit.HtmlConstants;
+
/**
* @author akolonitsky
* @version 1.0
@@ -96,8 +97,8 @@
protected static void hidePanelItem(UIComponent item) {
Map<String,Object> attrs = item.getAttributes();
- Object style = attrs.get(RendererUtils.HTML.STYLE_ATTRIBUTE);
- attrs.put(RendererUtils.HTML.STYLE_ATTRIBUTE, "display:none; " +
style);
+ Object style = attrs.get(HtmlConstants.STYLE_ATTRIBUTE);
+ attrs.put(HtmlConstants.STYLE_ATTRIBUTE, "display:none; " + style);
}
public abstract String getName();
Modified:
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/renderkit/html/AccordionItemRenderer.java
===================================================================
---
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/renderkit/html/AccordionItemRenderer.java 2010-09-06
15:37:00 UTC (rev 19122)
+++
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/renderkit/html/AccordionItemRenderer.java 2010-09-06
15:48:48 UTC (rev 19123)
@@ -22,23 +22,24 @@
package org.richfaces.renderkit.html;
-import org.ajax4jsf.javascript.JSObject;
-import org.richfaces.component.AbstractTogglePanelTitledItem;
-import org.richfaces.renderkit.HtmlConstants;
-import org.richfaces.renderkit.RenderKitUtils;
+import static org.richfaces.component.util.HtmlUtil.concatClasses;
+import static org.richfaces.renderkit.RenderKitUtils.renderPassThroughAttributes;
+import java.io.IOException;
+import java.util.Map;
+
import javax.faces.application.ResourceDependencies;
import javax.faces.application.ResourceDependency;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
-import java.io.IOException;
-import java.util.Map;
-import static org.richfaces.component.AbstractTogglePanelTitledItem.HeaderStates;
-import static org.richfaces.component.html.HtmlAccordionItem.PropertyKeys;
-import static org.richfaces.component.util.HtmlUtil.concatClasses;
-import static org.richfaces.renderkit.RenderKitUtils.renderPassThroughAttributes;
+import org.ajax4jsf.javascript.JSObject;
+import org.richfaces.component.AbstractTogglePanelTitledItem;
+import org.richfaces.component.AbstractTogglePanelTitledItem.HeaderStates;
+import org.richfaces.component.html.HtmlAccordionItem.PropertyKeys;
+import org.richfaces.renderkit.HtmlConstants;
+import org.richfaces.renderkit.RenderKitUtils;
/**
*
@@ -103,10 +104,10 @@
return;
}
- writer.startElement(RendererUtils.HTML.SCRIPT_ELEM, component);
- writer.writeAttribute(RendererUtils.HTML.TYPE_ATTR, "text/javascript",
"type");
+ writer.startElement(HtmlConstants.SCRIPT_ELEM, component);
+ writer.writeAttribute(HtmlConstants.TYPE_ATTR, "text/javascript",
"type");
writer.writeText(script, null);
- writer.endElement(RendererUtils.HTML.SCRIPT_ELEM);
+ writer.endElement(HtmlConstants.SCRIPT_ELEM);
}
private void encodeContentBegin(UIComponent component, ResponseWriter writer) throws
IOException {
Modified:
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/renderkit/html/TogglePanelRenderer.java
===================================================================
---
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/renderkit/html/TogglePanelRenderer.java 2010-09-06
15:37:00 UTC (rev 19122)
+++
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/renderkit/html/TogglePanelRenderer.java 2010-09-06
15:48:48 UTC (rev 19123)
@@ -111,12 +111,12 @@
super.doEncodeBegin(writer, context, comp);
AbstractTogglePanel panel = (AbstractTogglePanel) comp;
- writer.startElement(HTML.INPUT_ELEM, comp);
- writer.writeAttribute(HTML.TYPE_ATTR, HTML.INPUT_TYPE_HIDDEN, null);
- writer.writeAttribute(HTML.VALUE_ATTRIBUTE, panel.getActiveItem(),
"activeItem");
- writer.writeAttribute(HTML.ID_ATTRIBUTE, getValueRequestParamName(context, comp),
null);
- writer.writeAttribute(HTML.NAME_ATTRIBUTE, getValueRequestParamName(context,
comp), null);
- writer.endElement(HTML.INPUT_ELEM);
+ writer.startElement(HtmlConstants.INPUT_ELEM, comp);
+ writer.writeAttribute(HtmlConstants.TYPE_ATTR, HtmlConstants.INPUT_TYPE_HIDDEN,
null);
+ writer.writeAttribute(HtmlConstants.VALUE_ATTRIBUTE, panel.getActiveItem(),
"activeItem");
+ writer.writeAttribute(HtmlConstants.ID_ATTRIBUTE,
getValueRequestParamName(context, comp), null);
+ writer.writeAttribute(HtmlConstants.NAME_ATTRIBUTE,
getValueRequestParamName(context, comp), null);
+ writer.endElement(HtmlConstants.INPUT_ELEM);
}
@Override
Modified:
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/view/facelets/html/ChangeExpandListenerHandler.java
===================================================================
---
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/view/facelets/html/ChangeExpandListenerHandler.java 2010-09-06
15:37:00 UTC (rev 19122)
+++
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/view/facelets/html/ChangeExpandListenerHandler.java 2010-09-06
15:48:48 UTC (rev 19123)
@@ -67,9 +67,5 @@
source.addChangeExpandListener(new LazyChangeExpandListener(this.listenerType,
expression));
}
- @Override
- public boolean isEventSource(UIComponent comp) {
- return comp instanceof ChangeExpandSource;
- }
}
Copied:
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/view/facelets/html/EventListenerHandler.java
(from rev 19094,
trunk/ui/output/ui/src/main/java/org/richfaces/view/facelets/html/EventListenerHandler.java)
===================================================================
---
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/view/facelets/html/EventListenerHandler.java
(rev 0)
+++
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/view/facelets/html/EventListenerHandler.java 2010-09-06
15:48:48 UTC (rev 19123)
@@ -0,0 +1,147 @@
+/**
+ * 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-1301 USA
+ */
+
+package org.richfaces.view.facelets.html;
+
+import java.io.IOException;
+import java.io.Serializable;
+
+import javax.el.ValueExpression;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.event.AbortProcessingException;
+import javax.faces.event.FacesEvent;
+import javax.faces.event.FacesListener;
+import javax.faces.view.EditableValueHolderAttachedObjectHandler;
+import javax.faces.view.facelets.ComponentHandler;
+import javax.faces.view.facelets.FaceletContext;
+import javax.faces.view.facelets.TagAttribute;
+import javax.faces.view.facelets.TagAttributeException;
+import javax.faces.view.facelets.TagConfig;
+import javax.faces.view.facelets.TagException;
+import javax.faces.view.facelets.TagHandler;
+
+import org.richfaces.component.AbstractCollapsiblePanel;
+import org.richfaces.view.facelets.TagHandlerUtils;
+
+/**
+ * @author akolonitsky
+ * @since Aug 31, 2010
+ */
+public abstract class EventListenerHandler extends TagHandler implements
EditableValueHolderAttachedObjectHandler {
+
+ protected final TagAttribute binding;
+
+ protected final String listenerType;
+
+ public abstract static class LazyEventListener<L extends FacesListener>
implements FacesListener, Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ protected final String type;
+
+ protected final ValueExpression binding;
+
+ protected LazyEventListener(String type, ValueExpression binding) {
+ this.type = type;
+ this.binding = binding;
+ }
+
+ public void processEvent(FacesEvent event) throws AbortProcessingException {
+
+ FacesContext faces = FacesContext.getCurrentInstance();
+ if (faces == null) {
+ return;
+ }
+
+ L instance = null;
+ if (this.binding != null) {
+ instance = (L) binding.getValue(faces.getELContext());
+ }
+ if (instance == null && this.type != null) {
+ try {
+ instance = (L) forName(this.type).newInstance();
+ } catch (Exception e) {
+ throw new AbortProcessingException("Couldn't Lazily
instantiate EventListener", e);
+ }
+ if (this.binding != null) {
+ binding.setValue(faces.getELContext(), instance);
+ }
+ }
+
+ if (instance != null) {
+ event.processListener(instance);
+ }
+ }
+ }
+
+ public EventListenerHandler(TagConfig config) {
+ super(config);
+ this.binding = this.getAttribute("binding");
+ TagAttribute type = this.getAttribute("type");
+ if (type != null) {
+ if (type.isLiteral()) {
+ try {
+ forName(type.getValue());
+ } catch (ClassNotFoundException e) {
+ throw new TagAttributeException(type, "Couldn't qualify
EventListener", e);
+ }
+ } else {
+ throw new TagAttributeException(type, "Must be a literal class name
of type EventListener");
+ }
+ this.listenerType = type.getValue();
+ } else {
+ this.listenerType = null;
+ }
+ }
+
+ public void apply(FaceletContext ctx, UIComponent parent) throws IOException {
+
+ // only process if it's been created
+ if (parent == null || !ComponentHandler.isNew(parent)) {
+ return;
+ }
+
+ if (parent instanceof AbstractCollapsiblePanel) {
+ applyAttachedObject(ctx.getFacesContext(), parent);
+ } else if (UIComponent.isCompositeComponent(parent)) {
+ // Allow the composite component to know about the target component.
+ TagHandlerUtils.getOrCreateRetargetableHandlersList(parent).add(this);
+ } else {
+ throw new TagException(this.tag, "Parent is not of type
EditableValueHolder, type is: " + parent);
+ }
+ }
+
+ public String getFor() {
+ TagAttribute attr = this.getAttribute("for");
+ return attr == null ? null : attr.getValue();
+ }
+
+ public static Class<?> forName(String name) throws ClassNotFoundException {
+ if (null == name || "".equals(name)) {
+ return null;
+ }
+
+ return Class.forName(name, false,
Thread.currentThread().getContextClassLoader());
+ }
+}
+
+
Modified:
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/view/facelets/html/ItemChangeListenerHandler.java
===================================================================
---
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/view/facelets/html/ItemChangeListenerHandler.java 2010-09-06
15:37:00 UTC (rev 19122)
+++
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/view/facelets/html/ItemChangeListenerHandler.java 2010-09-06
15:48:48 UTC (rev 19123)
@@ -22,9 +22,7 @@
package org.richfaces.view.facelets.html;
-import org.richfaces.event.ItemChangeEvent;
-import org.richfaces.event.ItemChangeListener;
-import org.richfaces.event.ItemChangeSource;
+import java.io.Serializable;
import javax.el.ValueExpression;
import javax.faces.component.UIComponent;
@@ -32,8 +30,11 @@
import javax.faces.event.AbortProcessingException;
import javax.faces.view.facelets.FaceletContext;
import javax.faces.view.facelets.TagConfig;
-import java.io.Serializable;
+import org.richfaces.event.ItemChangeEvent;
+import org.richfaces.event.ItemChangeListener;
+import org.richfaces.event.ItemChangeSource;
+
/**
*
* @author akolonitsky
@@ -68,9 +69,5 @@
evh.addItemChangeListener(new LazyItemChangeListener(this.listenerType,
valueExpr));
}
- @Override
- public boolean isEventSource(UIComponent comp) {
- return comp instanceof ItemChangeSource;
- }
}
Modified: branches/RF-7560/ui/parent/pom.xml
===================================================================
--- branches/RF-7560/ui/parent/pom.xml 2010-09-06 15:37:00 UTC (rev 19122)
+++ branches/RF-7560/ui/parent/pom.xml 2010-09-06 15:48:48 UTC (rev 19123)
@@ -96,6 +96,7 @@
<!-- todo remove this dependency or move to test scope -->
<groupId>org.richfaces.core</groupId>
<artifactId>richfaces-core-impl</artifactId>
+ <scope>test</scope>
</dependency>
<dependency>