JBoss Rich Faces SVN: r19054 - in branches/RF-7560: core/impl/src/main/java/org/ajax4jsf/renderkit and 43 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-08-31 14:46:44 -0400 (Tue, 31 Aug 2010)
New Revision: 19054
Added:
branches/RF-7560/core/impl/src/main/java/org/richfaces/renderkit/HandlersChain.java
branches/RF-7560/core/impl/src/main/java/org/richfaces/renderkit/util/
branches/RF-7560/core/impl/src/main/java/org/richfaces/renderkit/util/AjaxRendererUtils.java
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/RendererUtils.java
branches/RF-7560/core/impl/src/test/java/org/richfaces/application/MessageFactoryImplTest1.java
branches/RF-7560/core/impl/src/test/java/org/richfaces/application/TestFacesMessages.java
branches/RF-7560/core/impl/src/test/java/org/richfaces/renderkit/util/
branches/RF-7560/core/impl/src/test/java/org/richfaces/renderkit/util/IdSplitBuilderTest.java
branches/RF-7560/core/impl/src/test/java/org/richfaces/renderkit/util/RendererUtilsTest.java
branches/RF-7560/ui/common/ui/src/main/java/org/richfaces/component/UIRangedNumberInput.java
branches/RF-7560/ui/common/ui/src/main/java/org/richfaces/component/util/
branches/RF-7560/ui/common/ui/src/main/java/org/richfaces/component/util/HtmlUtil.java
branches/RF-7560/ui/common/ui/src/main/java/org/richfaces/component/util/MessageUtil.java
branches/RF-7560/ui/common/ui/src/test/java/org/richfaces/component/UIRangedNumberInputTest.java
branches/RF-7560/ui/common/ui/src/test/java/org/richfaces/component/util/
branches/RF-7560/ui/common/ui/src/test/java/org/richfaces/component/util/HtmlUtilTest.java
Removed:
branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/renderkit/AjaxRendererUtils.java
branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/renderkit/HandlersChain.java
branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/renderkit/IdSplitBuilder.java
branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/renderkit/RendererUtils.java
branches/RF-7560/core/impl/src/main/java/org/richfaces/component/UIRangedNumberInput.java
branches/RF-7560/core/impl/src/main/java/org/richfaces/component/util/AbstractMessageUtil.java
branches/RF-7560/core/impl/src/main/java/org/richfaces/component/util/ComponentMessageUtil.java
branches/RF-7560/core/impl/src/main/java/org/richfaces/component/util/HtmlUtil.java
branches/RF-7560/core/impl/src/main/java/org/richfaces/component/util/MessageUtil.java
branches/RF-7560/core/impl/src/test/java/org/ajax4jsf/renderkit/IdSplitBuilderTest.java
branches/RF-7560/core/impl/src/test/java/org/ajax4jsf/renderkit/RendererUtilsTest.java
branches/RF-7560/core/impl/src/test/java/org/richfaces/application/FacesMessages.java
branches/RF-7560/core/impl/src/test/java/org/richfaces/application/MessageFactoryImpltest.java
branches/RF-7560/core/impl/src/test/java/org/richfaces/component/UIRangedNumberInputTest.java
branches/RF-7560/core/impl/src/test/java/org/richfaces/component/util/HtmlUtilTest.java
Modified:
branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/context/AjaxContextImpl.java
branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/context/ResponseWriterContentHandler.java
branches/RF-7560/core/impl/src/main/java/org/richfaces/context/ComponentCallback.java
branches/RF-7560/core/impl/src/main/java/org/richfaces/context/ComponentIdResolver.java
branches/RF-7560/core/impl/src/main/java/org/richfaces/context/IdTreeNode.java
branches/RF-7560/core/impl/src/main/java/org/richfaces/context/PartialViewContextImpl.java
branches/RF-7560/core/impl/src/main/java/org/richfaces/context/RenderComponentCallback.java
branches/RF-7560/examples/input-demo/src/main/webapp/META-INF/MANIFEST.MF
branches/RF-7560/examples/iteration-demo/src/main/webapp/META-INF/MANIFEST.MF
branches/RF-7560/examples/output-demo/src/main/webapp/META-INF/MANIFEST.MF
branches/RF-7560/ui/common/api/src/main/java/org/richfaces/appplication/FacesMessages.java
branches/RF-7560/ui/common/ui/src/main/java/org/richfaces/renderkit/RendererBase.java
branches/RF-7560/ui/common/ui/src/main/java/org/richfaces/renderkit/util/FormUtil.java
branches/RF-7560/ui/core/ui/pom.xml
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/renderkit/AjaxBehaviorRenderer.java
branches/RF-7560/ui/core/ui/src/main/java/org/richfaces/component/AbstractAttachQueue.java
branches/RF-7560/ui/core/ui/src/main/java/org/richfaces/renderkit/AjaxCommandRendererBase.java
branches/RF-7560/ui/core/ui/src/main/java/org/richfaces/renderkit/AjaxFunctionRendererBase.java
branches/RF-7560/ui/core/ui/src/main/java/org/richfaces/renderkit/html/AjaxOutputPanelRenderer.java
branches/RF-7560/ui/core/ui/src/main/java/org/richfaces/renderkit/html/AjaxPollRenderer.java
branches/RF-7560/ui/core/ui/src/main/java/org/richfaces/renderkit/html/AjaxPushRenderer.java
branches/RF-7560/ui/core/ui/src/main/java/org/richfaces/renderkit/html/AjaxStatusRenderer.java
branches/RF-7560/ui/core/ui/src/main/java/org/richfaces/renderkit/html/MediaOutputRenderer.java
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/QueueResourceComponentRenderer.java
branches/RF-7560/ui/core/ui/src/test/java/org/richfaces/component/RegionTest.java
branches/RF-7560/ui/core/ui/src/test/java/org/richfaces/view/facelets/html/AttachQueueHandlerTest.java
branches/RF-7560/ui/dist/richfaces-components-api/pom.xml
branches/RF-7560/ui/dist/richfaces-components-ui/pom.xml
branches/RF-7560/ui/input/ui/pom.xml
branches/RF-7560/ui/input/ui/src/main/java/org/richfaces/renderkit/AutocompleteDivLayoutStrategy.java
branches/RF-7560/ui/input/ui/src/main/java/org/richfaces/renderkit/AutocompleteListLayoutStrategy.java
branches/RF-7560/ui/input/ui/src/main/java/org/richfaces/renderkit/AutocompleteRendererBase.java
branches/RF-7560/ui/input/ui/src/main/java/org/richfaces/renderkit/AutocompleteTableLayoutStrategy.java
branches/RF-7560/ui/input/ui/src/main/java/org/richfaces/renderkit/InplaceInputBaseRenderer.java
branches/RF-7560/ui/input/ui/src/test/java/org/richfaces/renderkit/InplaceInputRendererTest.java
branches/RF-7560/ui/iteration/ui/src/main/java/org/richfaces/DataScrollerUtils.java
branches/RF-7560/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractDataScroller.java
branches/RF-7560/ui/iteration/ui/src/main/java/org/richfaces/renderkit/AbstractTableBaseRenderer.java
branches/RF-7560/ui/iteration/ui/src/main/java/org/richfaces/renderkit/AbstractTableRenderer.java
branches/RF-7560/ui/iteration/ui/src/main/java/org/richfaces/renderkit/DataGridRenderer.java
branches/RF-7560/ui/iteration/ui/src/main/java/org/richfaces/renderkit/DataScrollerBaseRenderer.java
branches/RF-7560/ui/iteration/ui/src/main/java/org/richfaces/renderkit/DataTableRenderer.java
branches/RF-7560/ui/iteration/ui/src/main/java/org/richfaces/renderkit/ExtendedDataTableRenderer.java
branches/RF-7560/ui/iteration/ui/src/main/java/org/richfaces/renderkit/ListRendererBase.java
branches/RF-7560/ui/iteration/ui/src/main/java/org/richfaces/renderkit/SelectionRenderer.java
branches/RF-7560/ui/iteration/ui/src/main/java/org/richfaces/renderkit/SubTableRenderer.java
branches/RF-7560/ui/iteration/ui/src/main/java/org/richfaces/renderkit/SubTableToggleControlRendererBase.java
branches/RF-7560/ui/iteration/ui/src/test/java/org/richfaces/renderkit/DataScrollerRenderTest.java
branches/RF-7560/ui/iteration/ui/src/test/java/org/richfaces/renderkit/ListRendererTest.java
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/renderkit/ComponentControlBehaviorRenderer.java
branches/RF-7560/ui/misc/ui/src/main/java/org/richfaces/renderkit/JQueryRendererBase.java
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/component/AbstractTogglePanel.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/component/behavior/ToggleControl.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/AccordionRenderer.java
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/renderkit/html/DivPanelRenderer.java
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/renderkit/html/PopupPanelBaseRenderer.java
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/renderkit/html/TogglePanelRenderer.java
Log:
RF-7560
Modified: branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/context/AjaxContextImpl.java
===================================================================
--- branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/context/AjaxContextImpl.java 2010-08-31 17:45:24 UTC (rev 19053)
+++ branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/context/AjaxContextImpl.java 2010-08-31 18:46:44 UTC (rev 19054)
@@ -49,11 +49,11 @@
import javax.servlet.ServletResponse;
import org.ajax4jsf.Messages;
-import org.ajax4jsf.renderkit.AjaxRendererUtils;
-import org.ajax4jsf.renderkit.RendererUtils;
-import org.ajax4jsf.renderkit.RendererUtils.HTML;
import org.richfaces.log.Logger;
import org.richfaces.log.RichfacesLogger;
+import org.richfaces.renderkit.util.AjaxRendererUtils;
+import org.richfaces.renderkit.util.RendererUtils;
+import org.richfaces.renderkit.util.RendererUtils.HTML;
/**
* This class incapsulated
Modified: branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/context/ResponseWriterContentHandler.java
===================================================================
--- branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/context/ResponseWriterContentHandler.java 2010-08-31 17:45:24 UTC (rev 19053)
+++ branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/context/ResponseWriterContentHandler.java 2010-08-31 18:46:44 UTC (rev 19054)
@@ -21,7 +21,7 @@
package org.ajax4jsf.context;
-import org.ajax4jsf.renderkit.RendererUtils.HTML;
+import org.richfaces.renderkit.util.RendererUtils.HTML;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
Deleted: branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/renderkit/AjaxRendererUtils.java
===================================================================
--- branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/renderkit/AjaxRendererUtils.java 2010-08-31 17:45:24 UTC (rev 19053)
+++ branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/renderkit/AjaxRendererUtils.java 2010-08-31 18:46:44 UTC (rev 19054)
@@ -1,1144 +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 java.io.IOException;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.LinkedHashSet;
-import java.util.Map;
-import java.util.Set;
-
-import javax.faces.component.NamingContainer;
-import javax.faces.component.UIComponent;
-import javax.faces.component.UIForm;
-import javax.faces.context.FacesContext;
-import javax.faces.context.PartialResponseWriter;
-
-import org.ajax4jsf.Messages;
-import org.ajax4jsf.component.AjaxClientBehavior;
-import org.ajax4jsf.component.AjaxComponent;
-import org.ajax4jsf.context.AjaxContext;
-import org.ajax4jsf.javascript.JSFunction;
-import org.ajax4jsf.javascript.JSFunctionDefinition;
-import org.ajax4jsf.javascript.JSReference;
-import org.ajax4jsf.renderkit.RendererUtils.HTML;
-import org.richfaces.application.ServiceTracker;
-import org.richfaces.log.Logger;
-import org.richfaces.log.RichfacesLogger;
-
-/**
- * @author shura
- * <p/>
- * Some utilites for render AJAX components.
- */
-public final class AjaxRendererUtils {
-
- public static final String AJAX_ABORT_ATTR = "ignoreDupResponses";
- public static final String AJAX_AREAS_RENDERED = "org.ajax4jsf.areas.rendered";
- public static final String AJAX_DELAY_ATTR = "requestDelay";
-
- /**
- * Name Javasript function for submit AJAX request
- */
- public static final String AJAX_FUNCTION_NAME = "RichFaces.ajax";
-
- /**
- * @since 3.3.0
- */
- public static final String AJAX_PROCESS_ATTRIBUTE = "process";
- public static final String AJAX_QUEUE_ATTR = "eventsQueue";
- public static final String AJAX_REGIONS_ATTRIBUTE = "reRender";
- public static final String AJAX_SINGLE_ATTR = "ajaxSingle";
- public static final String AJAX_SINGLE_PARAMETER_NAME = "ajaxSingle";
- public static final String ALL = "@all";
- public static final String FORM = "@form";
- public static final String THIS = "@this";
- public static final String REGION = "@region";
- public static final String NONE = "@none";
-
- public static final Set<String> GLOBAL_META_COMPONENTS;
-
- static {
- GLOBAL_META_COMPONENTS = new HashSet<String>(2);
-
- GLOBAL_META_COMPONENTS.add(ALL);
- GLOBAL_META_COMPONENTS.add(NONE);
- }
-
- /**
- * Attribute to keep
- */
- public static final String LIMITRENDER_ATTR_NAME = "limitRender";
-
- /**
- * Attribute for keep JavaScript function name for call before updating
- * DOM tree.
- */
- public static final String ONBEFOREDOMUPDATE_ATTR_NAME = "onbeforedomupdate";
- public static final String ONBEGIN_ATTR_NAME = "onbegin";
-
- /**
- * 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 for keep JavaScript function name for call after complete
- * request.
- */
- public static final String ONCOMPLETE_CONTENT_ID = "org.ajax4jsf.oncomplete";
- public static final String SIMILARITY_GROUPING_ID_ATTR = "similarityGroupingId";
-
- /**
- * Attribute for keep clientId of status component
- */
- public static final String STATUS_ATTR_NAME = "status";
- public static final String VALUE_ATTR = "value";
-
- public static final String EXTENSION_ID = "org.richfaces.extension";
- public static final String AJAX_COMPONENT_ID_PARAMETER = "org.richfaces.ajax.component";
- public static final String BEHAVIOR_EVENT_PARAMETER = "javax.faces.behavior.event";
-
- public static final String QUEUE_ID_ATTRIBUTE = "queueId";
-
- 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 RendererUtils RENDERER_UTILS = RendererUtils.getInstance();
- private static final Class<?> OBJECT_ARRAY_CLASS = new Object[0].getClass();
- private static final Logger LOG = RichfacesLogger.RENDERKIT.getLogger();
-
- /**
- * Static class - protect constructor
- */
- private AjaxRendererUtils() {
- }
-
- private static enum BehaviorEventOptionsData {
- begin {
- @Override
- public String getAttributeValue(AjaxClientBehavior behavior) {
- return behavior.getOnbegin();
- }
- },
- error {
- @Override
- public String getAttributeValue(AjaxClientBehavior behavior) {
- return behavior.getOnerror();
- }
- },
- queueId {
- @Override
- public String getAttributeValue(AjaxClientBehavior behavior) {
- return behavior.getQueueId();
- }
- },
- event {
- @Override
- public String getAttributeValue(AjaxClientBehavior behavior) {
- return behavior.getOnevent();
- }
- };
-
- public abstract String getAttributeValue(AjaxClientBehavior behavior);
- }
-
- /**
- * Build JavaScript onclick event for given component
- *
- * @param uiComponent -
- * component for build event
- * @param facesContext
- * @return <code>StringBuffer</code> with Javascript code
- */
- public static StringBuffer buildOnClick(UIComponent uiComponent, FacesContext facesContext) {
- return buildOnClick(uiComponent, facesContext, false);
- }
-
- /**
- * Build JavaScript onclick event for given component
- *
- * @param uiComponent -
- * component for build event
- * @param facesContext
- * @param omitDefaultActionUrl - default action URL is not encoded if parameter is true
- * @return <code>StringBuffer</code> with Javascript code
- */
- public static StringBuffer buildOnClick(UIComponent uiComponent, FacesContext facesContext,
- boolean omitDefaultActionUrl) {
- return buildOnEvent(uiComponent, facesContext, HTML.ONCLICK_ATTRIBUTE, omitDefaultActionUrl);
- }
-
- /**
- * Build JavaScript event for component
- *
- * @param uiComponent -
- * component for build event
- * @param facesContext
- * @param eventName -
- * name of event
- * @return <code>StringBuffer</code> with Javascript code
- */
- public static StringBuffer buildOnEvent(UIComponent uiComponent, FacesContext facesContext, String eventName) {
- return buildOnEvent(uiComponent, facesContext, eventName, false);
- }
-
- /**
- * Build JavaScript event for component
- *
- * @param uiComponent -
- * component for build event
- * @param facesContext
- * @param eventName -
- * name of event
- * @param omitDefaultActionUrl - default action URL is not encoded if parameter is true
- * @return <code>StringBuffer</code> with Javascript code
- */
- public static StringBuffer buildOnEvent(UIComponent uiComponent, FacesContext facesContext, String eventName,
- boolean omitDefaultActionUrl) {
- StringBuffer onEvent = new StringBuffer();
-
-// if (null != eventName) {
-// String commandOnEvent = (String) uiComponent.getAttributes().get(
-// eventName);
-// if (commandOnEvent != null) {
-// onEvent.append(commandOnEvent);
-// onEvent.append(';');
-// }
-// }
-// JSFunction ajaxFunction = buildAjaxFunction(uiComponent, facesContext);
-// // Create formal parameter for non-input elements ???
-// // Link Control pseudo-object
-// // Options map. Possible options for function call :
-// // control - name of form control for submit.
-// // name - name for link control \
-// // value - value of control. - possible replace by parameters ?
-// // single true/false - submit all form or only one control.
-// // affected - array of element's ID for update on responce.
-// // oncomplete - function for call after complete request.
-// // status - id of request status component.
-// // parameters - map of parameters name/value for append on request.
-// // ..........
-// ajaxFunction.addParameter(buildEventOptions(facesContext, uiComponent, omitDefaultActionUrl));
-//
-// // appendAjaxSubmitParameters(facesContext, uiComponent, onEvent);
-// ajaxFunction.appendScript(onEvent);
-// if (uiComponent instanceof AjaxSupport) {
-// AjaxSupport support = (AjaxSupport) uiComponent;
-// if (support.isDisableDefault()) {
-// onEvent.append("; return false;");
-// }
-// }
-// LOG.debug(Messages.getMessage(Messages.BUILD_ONCLICK_INFO, uiComponent
-// .getId(), onEvent.toString()));
- return onEvent;
- }
-
- public static AjaxEventOptions buildEventOptions(FacesContext facesContext, UIComponent component) {
- return buildEventOptions(facesContext, component, null);
- }
-
- public static AjaxEventOptions buildEventOptions(FacesContext facesContext, UIComponent component,
- AjaxClientBehavior ajaxBehavior) {
- AjaxEventOptions ajaxEventOptions = new AjaxEventOptions();
- Map<String, Object> parametersMap = RENDERER_UTILS.createParametersMap(facesContext, component);
- String ajaxStatusName = getAjaxStatus(component);
-
- if (ajaxBehavior != null) {
- ajaxStatusName = (ajaxBehavior.getStatus() != null) ? ajaxBehavior.getStatus() : ajaxStatusName;
- appenAjaxBehaviorOptions(ajaxBehavior, ajaxEventOptions);
- } else {
- appendComponentOptions(facesContext, component, ajaxEventOptions);
- }
-
- if ((ajaxStatusName != null) && (ajaxStatusName.length() != 0)) {
- ajaxEventOptions.set(STATUS_ATTR_NAME, ajaxStatusName);
- }
-
- if (!parametersMap.isEmpty()) {
- ajaxEventOptions.getParameters().putAll(parametersMap);
- }
-
- return ajaxEventOptions;
- }
-
- private static boolean isNotEmpty(String value) {
- return (value != null) && (value.length() != 0);
- }
-
- private static void appenAjaxBehaviorOptions(AjaxClientBehavior behavior, AjaxEventOptions ajaxEventOptions) {
- for (BehaviorEventOptionsData optionsData : BehaviorEventOptionsData.values()) {
- String eventHandlerValue = optionsData.getAttributeValue(behavior);
-
- if (isNotEmpty(eventHandlerValue)) {
- ajaxEventOptions.set(optionsData.toString(), eventHandlerValue);
- }
- }
- }
-
- private static void appendComponentOptions(FacesContext facesContext, UIComponent component,
- AjaxEventOptions ajaxEventOptions) {
- String behaviorName = "begin";
- HandlersChain handlersChain = new HandlersChain(facesContext, component);
- String inlineHandler = getAjaxOnBegin(component);
-
- handlersChain.addInlineHandlerAsValue(inlineHandler);
- handlersChain.addBehaviors(behaviorName);
-
- String handlerScript = handlersChain.toScript();
-
- if (isNotEmpty(handlerScript)) {
- ajaxEventOptions.set(behaviorName, handlerScript);
- }
-
- String queueId = getQueueId(component);
- if (isNotEmpty(queueId)) {
- ajaxEventOptions.set(QUEUE_ID_ATTRIBUTE, queueId);
- }
-
- ajaxEventOptions.set("incId", "1");
- }
-
-// public static AjaxEventOptions buildEventOptions(FacesContext facesContext,
-// UIComponent uiComponent, Map<String, Object> params) {
-//
-// return buildEventOptions(facesContext, uiComponent, params, false);
-// }
-
- /**
- * @param facesContext
- * @param uiComponent
- * @return
- */
-// public static Map<String, Object> buildEventOptions(FacesContext facesContext,
-// UIComponent uiComponent, Map<String, Object> params, boolean omitDefaultActionUrl) {
-// String clientId = uiComponent.getClientId(facesContext);
-// Map<String, Object> componentAttributes = uiComponent.getAttributes();
-// Map<String, Object> options = new HashMap<String, Object>();
-//
-// UIComponent nestingContainer = (UIComponent) findAjaxContainer(
-// facesContext, uiComponent);
-// String containerClientId = nestingContainer.getClientId(facesContext);
-// if (containerClientId != null && !AjaxViewRoot.ROOT_ID.equals(containerClientId)) {
-// options.put("containerId", containerClientId);
-// }
-//
-// Map<String, Object> parameters = new HashMap<String, Object>();
-// UIComponent targetComponent = (uiComponent instanceof AjaxSupport)?uiComponent.getParent():uiComponent;
-// // UIForm form = getNestingForm(uiComponent);
-// // "input" - if assigned to html input element.
-// boolean input = targetComponent instanceof EditableValueHolder;
-// // Action component - button etc.
-//// boolean action = targetComponent instanceof ActionSource;
-//
-// boolean ajaxSingle = Boolean.TRUE.equals(componentAttributes
-// .get(AJAX_SINGLE_ATTR));
-// // For input components in single mode or without form submit input
-// // control )
-// if (ajaxSingle ) {
-// parameters.put(AJAX_SINGLE_PARAMETER_NAME, targetComponent.getClientId(facesContext));
-// // options.put("single", JSReference.TRUE);
-// if (input) {
-// options.put("control", JSReference.THIS);
-// }
-// }
-// // Control value for submit
-// String controlName;
-// Object controlValue;
-// // TODO - make compatible with JSF RI/MyFaces ? use submittedValue ( if
-// // any ) for UIInput, converted value for ValueHolder.
-// controlName = clientId;
-// controlValue = clientId;
-// parameters.put(controlName, controlValue);
-// AjaxContext ajaxContext = AjaxContext.getCurrentInstance(facesContext);
-//
-// String ajaxActionURL = ajaxContext.getAjaxActionURL(facesContext);
-// if (omitDefaultActionUrl) {
-// UIComponent form = getNestingForm(uiComponent);
-// if (form != null && !RENDERER_UTILS.isBooleanAttribute(form, "ajaxSubmit")) {
-// if (RENDERER_UTILS.getActionUrl(facesContext).equals(ajaxActionURL)) {
-// ajaxActionURL = null;
-// }
-// }
-// }
-//
-// if (ajaxActionURL != null) {
-// // Setup action URL. For portlet environment, it will be different from
-// // page.
-// options.put("actionUrl", ajaxActionURL);
-// }
-//
-// // Add application-wide Ajax parameters
-// parameters.putAll(ajaxContext.getCommonAjaxParameters());
-// // add child parameters
-// appendParameters(facesContext, uiComponent, parameters);
-//
-// if (params != null) {
-// parameters.putAll(params);
-// }
-//
-// if (!parameters.isEmpty()) {
-// options.put("parameters", parameters);
-// }
-// // parameter to render only current list of areas.
-//// if (isAjaxLimitToList(uiComponent)) {
-//// Set<? extends Object> ajaxAreas = getAjaxAreas(uiComponent);
-//// Set<String> areasIds = new HashSet<String>();
-//// if (null != ajaxAreas) {
-//// for (Iterator<? extends Object> iter = ajaxAreas.iterator(); iter.hasNext();) {
-//// String id = (String) iter.next();
-//// UIComponent comp = RendererUtils.getInstance().
-//// findComponentFor(uiComponent, id);
-//// if (null != comp) {
-//// areasIds.add(comp.getClientId(facesContext));
-//// } else {
-//// areasIds.add(id);
-//// }
-//// }
-//// }
-//// options.put("affected", areasIds);
-//// }
-// String oncomplete = getAjaxOncomplete(uiComponent);
-// if (null != oncomplete) {
-// options.put(ONCOMPLETE_ATTR_NAME, buildAjaxOncomplete(oncomplete));
-// }
-//
-// String beforeupdate = getAjaxOnBeforeDomUpdate(uiComponent);
-// if (null != beforeupdate) {
-// options.put(ONBEFOREDOMUPDATE_ATTR_NAME, buildAjaxOnBeforeDomUpdate(beforeupdate));
-// }
-//
-//
-// String status = getAjaxStatus(uiComponent);
-// if (null != status) {
-// options.put("status", status);
-// }
-// String queue = (String) componentAttributes.get(AJAX_QUEUE_ATTR);
-// String implicitQueue = null;
-//
-// Integer requestDelay = (Integer) componentAttributes
-// .get(AJAX_DELAY_ATTR);
-// if (null != requestDelay && requestDelay.intValue() > 0) {
-// options.put(AJAX_DELAY_ATTR, requestDelay);
-// if (null == queue) {
-// implicitQueue = clientId;
-// }
-// }
-// Boolean ignoreDupResponses = (Boolean) componentAttributes
-// .get(AJAX_ABORT_ATTR);
-// if (null != ignoreDupResponses && ignoreDupResponses.booleanValue()) {
-// options.put(AJAX_ABORT_ATTR, JSReference.TRUE);
-// if (null == queue) {
-// implicitQueue = clientId;
-// }
-// }
-//
-// if (null != queue) {
-// options.put(AJAX_QUEUE_ATTR, queue);
-// } else if (implicitQueue != null) {
-// options.put("implicitEventsQueue", clientId);
-// }
-//
-// ExternalContext externalContext = facesContext.getExternalContext();
-// String namespace = externalContext.encodeNamespace("");
-// if (namespace != null && namespace.length() != 0) {
-// options.put("namespace", namespace);
-// }
-//
-// String similarityGroupingId = (String) componentAttributes.get(SIMILARITY_GROUPING_ID_ATTR);
-// if (similarityGroupingId == null || similarityGroupingId.length() == 0) {
-// similarityGroupingId = clientId;
-// } else {
-// similarityGroupingId = externalContext.encodeNamespace(similarityGroupingId);
-// }
-//
-// options.put(SIMILARITY_GROUPING_ID_ATTR, similarityGroupingId);
-//
-// // request timeout.
-// Integer timeout = (Integer) componentAttributes.get("timeout");
-// if (null != timeout && timeout.intValue() > 0) {
-// options.put("timeout", timeout);
-// }
-// // Encoding for requests
-// String encoding = (String) componentAttributes.get("encoding");
-// if (null != encoding) {
-// options.put("encoding", encoding);
-// }
-// return options;
-// }
-// /**
-// * Create call to Ajax Submit function with first two parameters
-// *
-// * @param uiComponent
-// * @param facesContext
-// * @param functionName
-// * @return
-// */
-// public static JSFunction buildAjaxFunction(UIComponent uiComponent,
-// FacesContext facesContext) {
-// JSFunction ajaxFunction = buildAjaxFunction(uiComponent, facesContext,
-// AJAX_FUNCTION_NAME);
-// // client-side script must have reference to event-enabled object.
-// ajaxFunction.addParameter(new JSReference("event"));
-// return ajaxFunction;
-// }
-
- /**
- * Create call to Ajax Submit function with first two parameters
- *
- * @param facesContext
- * @param uiComponent
- * @param functionName
- * @return
- */
- public static JSFunction buildAjaxFunction(FacesContext facesContext, UIComponent uiComponent,
- String functionName) {
- JSFunction ajaxFunction = new JSFunction(functionName);
-
- ajaxFunction.addParameter(uiComponent.getClientId(facesContext));
- ajaxFunction.addParameter(JSReference.EVENT);
-
- return ajaxFunction;
- }
-
- /**
- * Append common parameters ( array of affected areas, status area id, on
- * complete function ) to JavaScript event string.
- *
- * @param uiComponent
- * @param onClick -
- * buffer with JavaScript code eg... AJAX.Submit(form,this
- */
-
- // public static void appendAjaxSubmitParameters(FacesContext facesContext,
- // UIComponent uiComponent, StringBuffer onClick)
- // {
- // Set ajaxAreas = getAjaxAreas(uiComponent);
- // onClick.append(',');
- // // parameter to render only current list of areas.
- // if (isAjaxLimitToList(uiComponent) && ajaxAreas != null &&
- // ajaxAreas.size() > 0)
- // {
- // onClick.append('[');
- // Iterator areas = ajaxAreas.iterator();
- // boolean first = true;
- // while (areas.hasNext())
- // {
- // String element = (String) areas.next();
- // UIComponent component = uiComponent.findComponent(element);
- // if (null != component)
- // {
- // if (!first)
- // {
- // onClick.append(',');
- // }
- // else
- // {
- // first = false;
- // }
- // onClick.append('\'');
- // onClick.append(component.getClientId(facesContext));
- // onClick.append('\'');
- // }
- // }
- // onClick.append("]");
- // }
- // else
- // {
- // onClick.append("null");
- // }
- // // insert id of request status element.
- // onClick.append(',');
- // String status = getAjaxStatus(uiComponent);
- // if (null != status)
- // {
- // onClick.append('\'').append(status).append('\'');
- // }
- // else
- // {
- // onClick.append("null");
- // }
- // // insert function name for call after completed request
- // onClick.append(',');
- // String oncomplete = getAjaxOncomplete(uiComponent);
- // if (null != oncomplete)
- // {
- // onClick.append(oncomplete);
- // }
- // else
- // {
- // onClick.append("null");
- // }
- //
- // }
-
- /**
- * Get list of clientId's for given component
- *
- * @param uiComponent
- * @return List of areas Id's , updated by this component.
- */
- public static Set<String> getAjaxAreas(UIComponent uiComponent) {
- Object areas;
-
- if (uiComponent instanceof AjaxComponent) {
- areas = ((AjaxComponent) uiComponent).getReRender();
- } else {
- areas = uiComponent.getAttributes().get(AjaxRendererUtils.AJAX_REGIONS_ATTRIBUTE);
- }
-
- return asSet(areas);
- }
-
- /**
- * Returns set of areas to be processed as a result of this component action invocation
- *
- * @param component
- * @return set of IDs that should be processed as a
- * @since 3.3.0
- */
- public static Set<String> getAjaxAreasToProcess(UIComponent component) {
- Object areas;
-
- if (component instanceof AjaxComponent) {
- areas = ((AjaxComponent) component).getProcess();
- } else {
- areas = component.getAttributes().get(AjaxRendererUtils.AJAX_PROCESS_ATTRIBUTE);
- }
-
- return asSet(areas);
- }
-
- /**
- * Split parameter string into array of strings.
- * @param valuesSet
- * @return
- */
- public static String[] asArray(String valuesSet) {
- return IdSplitBuilder.split(valuesSet);
- }
-
- /**
- * Convert parameter ( Collection, List, array, String, comma-separated
- * String, whitespace-separate String) to set of strings.
- *
- * @param valueToSet -
- * object for conversion to Set.
- * @return - set of strings.
- */
- @SuppressWarnings("unchecked")
- public static Set<String> asSet(Object valueToSet) {
- 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_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 = asArray(areasString);
- Set<String> result = new LinkedHashSet<String>(values.length);
- for (String value : values) {
- result.add(value);
- }
-
- return result;
- } else {
- Set<String> areasSet = new LinkedHashSet<String>(5);
-
- areasSet.add(areasString);
-
- return areasSet;
- }
- }
- }
-
- return null;
- }
-
- /**
- * Get status area Id for given component.
- *
- * @param component
- * @return clientId of status area, or <code>null</code>
- */
- public static String getAjaxStatus(UIComponent component) {
- String statusId;
-
- if (component instanceof AjaxComponent) {
- statusId = ((AjaxComponent) component).getStatus();
- } else {
- statusId = (String) component.getAttributes().get(STATUS_ATTR_NAME);
- }
-
- return statusId;
-
-// if (null != statusId) {
-// UIComponent status = RendererUtils.getInstance().
-// findComponentFor(component, statusId);
-//
-// if (null != status) {
-// statusId = status
-// .getClientId(FacesContext.getCurrentInstance());
-// } else {
-// LOG.warn(Messages.getMessage(
-// Messages.AJAX_STATUS_COMPONENT_NOT_FOWND_WARNING,
-// component.getId()));
-// }
-// }
-// return statusId;
- }
-
- public static String getQueueId(UIComponent component) {
- return (String) component.getAttributes().get(QUEUE_ID_ATTRIBUTE);
- }
-
- public static JSFunctionDefinition buildAjaxOncomplete(String body) {
- JSFunctionDefinition function = new JSFunctionDefinition("request", "event", "data");
-
- function.addToBody(body);
-
- return function;
- }
-
- public static JSFunctionDefinition buildAjaxOnBeforeDomUpdate(String body) {
- JSFunctionDefinition function = new JSFunctionDefinition("request", "event", "data");
-
- function.addToBody(body);
-
- return function;
- }
-
- /**
- * Get function name for call on completed ajax request.
- *
- * @param component for wich calculate function name
- * @return name of JavaScript function or <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);
- }
-
- //TODO nick - refactor - remove this method?
- public static String getAjaxOnBegin(UIComponent component) {
- if (component instanceof AjaxComponent) {
- return ((AjaxComponent) component).getOnbegin();
- }
-
- return (String) component.getAttributes().get(ONBEGIN_ATTR_NAME);
- }
-
- /**
- * @param component
- * @return
- * @since 4.0
- */
- public static Object getAjaxData(UIComponent component) {
- if (component instanceof AjaxComponent) {
- return ((AjaxComponent) component).getData();
- }
-
- return component.getAttributes().get(DATA_ATTR_NAME);
- }
-
- /**
- * Calculate, must be component render only given areas, or all sended from
- * server.
- *
- * @param component
- * @return <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;
- }
-
- /**
- * Replacement for buggy in MyFaces <code>RendererUtils</code>
- *
- * @param component
- * @return
- */
- public static String getAbsoluteId(UIComponent component) {
- if (component == null) {
- throw new NullPointerException(Messages.getMessage(Messages.COMPONENT_NULL_ERROR_2));
- }
-
- StringBuffer idBuf = new StringBuffer();
-
- idBuf.append(component.getId());
-
- UIComponent parent = component;
-
- while ((parent = parent.getParent()) != null) {
- if (parent instanceof NamingContainer) {
- idBuf.insert(0, NamingContainer.SEPARATOR_CHAR);
- idBuf.insert(0, parent.getId());
- }
- }
-
- idBuf.insert(0, NamingContainer.SEPARATOR_CHAR);
- LOG.debug(Messages.getMessage(Messages.CALCULATE_COMPONENT_ID_INFO, component.getId(), idBuf.toString()));
-
- return idBuf.toString();
- }
-
- /**
- * Find nested form for given component
- *
- * @param component
- * @return nested <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");
-// }
-
- /**
- * Write state saving markers to context, include MyFaces view sequence.
- *
- * @param context
- * @throws IOException
- */
- public static void writeState(FacesContext context) throws IOException {
- context.getApplication().getViewHandler().writeState(context);
- }
-
-// /**
-// * Encode declaration for AJAX response. Render <html><body>
-// *
-// * @param context
-// * @param component
-// * @throws IOException
-// */
-// public static void encodeAjaxBegin(FacesContext context, UIComponent component) throws IOException {
-//
-// // AjaxContainer ajax = (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
- */
- public static boolean isAjaxRequest(FacesContext facesContext) {
- return AjaxContext.getCurrentInstance(facesContext).isAjaxRequest();
- }
-
- /**
- * TODO: add deprecation
- *
- * @param facesContext
- * @param component
- * @param id
- */
- public static void addRegionByName(FacesContext facesContext, UIComponent component, String id) {
- AjaxContext.getCurrentInstance(facesContext).addComponentToAjaxRender(component, id);
- }
-
- /**
- * @param facesContext
- * @param component
- */
- public static void addRegionsFromComponent(UIComponent component, FacesContext facesContext) {
- AjaxContext.getCurrentInstance(facesContext).addRegionsFromComponent(component);
- }
-
- 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(HTML.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);
-
- }
-
-}
Deleted: branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/renderkit/HandlersChain.java
===================================================================
--- branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/renderkit/HandlersChain.java 2010-08-31 17:45:24 UTC (rev 19053)
+++ branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/renderkit/HandlersChain.java 2010-08-31 18:46:44 UTC (rev 19054)
@@ -1,209 +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 static org.ajax4jsf.renderkit.AjaxRendererUtils.AJAX_FUNCTION_NAME;
-import static org.ajax4jsf.renderkit.AjaxRendererUtils.buildAjaxFunction;
-import static org.ajax4jsf.renderkit.AjaxRendererUtils.buildEventOptions;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import javax.faces.component.UIComponent;
-import javax.faces.component.behavior.ClientBehavior;
-import javax.faces.component.behavior.ClientBehaviorContext;
-import javax.faces.component.behavior.ClientBehaviorContext.Parameter;
-import javax.faces.component.behavior.ClientBehaviorHint;
-import javax.faces.component.behavior.ClientBehaviorHolder;
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.javascript.JSFunction;
-import org.ajax4jsf.javascript.JSReference;
-
-/**
- * @author Nick Belaevski
- * @since 4.0
- */
-public final class HandlersChain {
-
- // private static final Logger LOG = RichfacesLogger.RENDERKIT.getLogger();
- private boolean hasSubmittingBehavior = false;
- private boolean includeClientId = false;
-
- // TODO: review for optimization
- private List<String> handlers = new ArrayList<String>(2);
-
- private FacesContext facesContext;
- private UIComponent component;
- private Collection<Parameter> parameters;
-
- public HandlersChain(FacesContext facesContext, UIComponent component) {
- this.facesContext = facesContext;
- this.component = component;
- }
-
- public HandlersChain(FacesContext facesContext, UIComponent component, boolean includeClientId) {
- this.facesContext = facesContext;
- this.component = component;
- this.includeClientId = includeClientId;
- }
-
- public HandlersChain(FacesContext facesContext, UIComponent component, Collection<Parameter> parameters) {
- this.facesContext = facesContext;
- this.component = component;
- this.parameters = parameters;
- }
-
- public HandlersChain(FacesContext facesContext, UIComponent component, Collection<Parameter> parameters, boolean includeClientId) {
- this.facesContext = facesContext;
- this.component = component;
- this.parameters = parameters;
- this.includeClientId = includeClientId;
- }
-
- private static boolean isNotEmpty(String s) {
- return (s != null) && (s.length() != 0);
- }
-
- private List<ClientBehavior> getBehaviorsList(String behaviorName) {
- List<ClientBehavior> behaviors = null;
-
- if (component instanceof ClientBehaviorHolder) {
- ClientBehaviorHolder clientBehaviorHolder = (ClientBehaviorHolder) component;
- Map<String, List<ClientBehavior>> clientBehaviorsMap = clientBehaviorHolder.getClientBehaviors();
-
- if (clientBehaviorsMap != null) {
- behaviors = clientBehaviorsMap.get(behaviorName);
- }
- }
-
- return behaviors;
- }
-
- private Collection<Parameter> getParameters() {
- if (parameters == null) {
- RendererUtils rendererUtils = RendererUtils.getInstance();
- Map<String, Object> parametersMap = rendererUtils.createParametersMap(facesContext, component);
-
- parameters = createParametersList(parametersMap);
- }
-
- return parameters;
- }
-
- public boolean hasSubmittingBehavior() {
- return hasSubmittingBehavior;
- }
-
- public void addInlineHandlerAsValue(String handlerValue) {
- if (isNotEmpty(handlerValue)) {
- handlers.add(handlerValue);
- }
- }
-
- public void addInlineHandlerFromAttribute(String attributeName) {
- addInlineHandlerAsValue((String) component.getAttributes().get(attributeName));
- }
-
- public void addBehaviors(String domEventName) {
- addBehaviors(domEventName, null);
- }
-
- public void addBehaviors(String domEventName, String logicalEventName) {
- String name = domEventName;
- List<ClientBehavior> behaviorsList = getBehaviorsList(domEventName);
-
- if ((behaviorsList == null) && (logicalEventName != null)) {
- behaviorsList = getBehaviorsList(logicalEventName);
- name = logicalEventName;
- }
-
- if (behaviorsList == null) {
- return;
- }
-
- ClientBehaviorContext behaviorContext = ClientBehaviorContext.createClientBehaviorContext(facesContext, component,
- name, includeClientId ? component.getClientId(facesContext) : null,
- getParameters());
-
- for (ClientBehavior clientBehavior : behaviorsList) {
- String behaviorScript = clientBehavior.getScript(behaviorContext);
-
- if (isNotEmpty(behaviorScript)) {
- if (clientBehavior.getHints().contains(ClientBehaviorHint.SUBMITTING)) {
- hasSubmittingBehavior = true;
- }
-
- handlers.add(behaviorScript);
- }
- }
- }
-
- public void addAjaxSubmitFunction() {
- if (!this.hasSubmittingBehavior()) {
- hasSubmittingBehavior = true;
-
- JSFunction ajaxFunction = buildAjaxFunction(facesContext, component, AJAX_FUNCTION_NAME);
- AjaxEventOptions eventOptions = buildEventOptions(facesContext, component);
-
- if (!eventOptions.isEmpty()) {
- ajaxFunction.addParameter(eventOptions);
- }
-
- this.addInlineHandlerAsValue(ajaxFunction.toScript());
- }
- }
-
- public String toScript() {
- String result = null;
-
- if (!handlers.isEmpty()) {
- if (handlers.size() == 1) {
- result = handlers.get(0);
- } else {
- JSFunction jsFunction = new JSFunction("jsf.util.chain", JSReference.THIS, JSReference.EVENT);
-
- for (String handler : handlers) {
- jsFunction.addParameter(handler);
- }
-
- result = jsFunction.toScript();
- }
- }
-
- return result;
- }
-
- public static List<Parameter> createParametersList(Map<String, Object> parametersMap) {
- List<Parameter> parameters = new ArrayList<Parameter>(parametersMap.size());
-
- for (Entry<String, Object> entry : parametersMap.entrySet()) {
- parameters.add(new Parameter(entry.getKey(), entry.getValue()));
- }
-
- return parameters;
- }
-
-}
Deleted: branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/renderkit/IdSplitBuilder.java
===================================================================
--- branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/renderkit/IdSplitBuilder.java 2010-08-31 17:45:24 UTC (rev 19053)
+++ branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/renderkit/IdSplitBuilder.java 2010-08-31 18:46:44 UTC (rev 19054)
@@ -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.ajax4jsf.renderkit;
-
-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/main/java/org/ajax4jsf/renderkit/RendererUtils.java
===================================================================
--- branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/renderkit/RendererUtils.java 2010-08-31 17:45:24 UTC (rev 19053)
+++ branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/renderkit/RendererUtils.java 2010-08-31 18:46:44 UTC (rev 19054)
@@ -1,1313 +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 java.io.IOException;
-import java.lang.reflect.Array;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.LinkedHashSet;
-import java.util.Map;
-import java.util.Set;
-
-import javax.faces.FacesException;
-import javax.faces.application.ViewHandler;
-import javax.faces.component.EditableValueHolder;
-import javax.faces.component.NamingContainer;
-import javax.faces.component.UIComponent;
-import javax.faces.component.UIForm;
-import javax.faces.component.UIParameter;
-import javax.faces.component.UIViewRoot;
-import javax.faces.component.ValueHolder;
-import javax.faces.component.behavior.ClientBehaviorContext.Parameter;
-import javax.faces.component.behavior.ClientBehaviorHolder;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-import javax.faces.convert.Converter;
-
-import org.ajax4jsf.Messages;
-import org.ajax4jsf.component.JavaScriptParameter;
-import org.ajax4jsf.javascript.JSEncoder;
-import org.ajax4jsf.javascript.JSFunctionDefinition;
-import org.ajax4jsf.javascript.JSReference;
-import org.ajax4jsf.util.HtmlDimensions;
-import org.richfaces.context.ComponentIdResolver;
-
-/**
- * Util class for common render operations - render passthru html attributes,
- * iterate over child components etc.
- *
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.6 $ $Date: 2007/02/08 19:07:16 $
- *
- */
-public class RendererUtils {
-
- public static final String DUMMY_FORM_ID = ":_form";
-
- // we'd better use this instance multithreadly quickly
- private static final RendererUtils INSTANCE = new RendererUtils();
-
- /**
- * Substitutions for components properies names and HTML attributes names.
- */
- private static final Map<String, String> SUBSTITUTIONS = new HashMap<String, String>();
-
- private static final Set<String> REQUIRED_ATTRIBUTES = new HashSet<String>();
-
- static {
- SUBSTITUTIONS.put(HTML.CLASS_ATTRIBUTE, "styleClass");
-
- REQUIRED_ATTRIBUTES.add(HTML.ALT_ATTRIBUTE);
-
- Arrays.sort(HTML.PASS_THRU);
- Arrays.sort(HTML.PASS_THRU_EVENTS);
- Arrays.sort(HTML.PASS_THRU_BOOLEAN);
- Arrays.sort(HTML.PASS_THRU_URI);
- }
-
- // can be created by subclasses;
- // administratively restricted to be created by package members ;)
- protected RendererUtils() {
- super();
- }
-
- /**
- * Wrapper class around object value used to transform values into particular JS objects
- *
- * @author Nick Belaevski
- * @since 3.3.2
- */
- public static enum ScriptHashVariableWrapper {
-
- /**
- * No-op default wrapper
- */
- DEFAULT {
- @Override
- Object wrap(Object o) {
- return o;
- }
- },
-
- /**
- * Event handler functions wrapper. Wraps <pre>functionCode</pre> object into:
- * <pre>function(event) {
- * functionCode
- * }</pre>
- */
- EVENT_HANDLER {
- @Override
- Object wrap(Object o) {
- return new JSFunctionDefinition("event").addToBody(o);
- }
- };
-
- /**
- * Method that does the wrapping
- *
- * @param o object to wrap
- * @return wrapped object
- */
- abstract Object wrap(Object o);
- }
-
- /**
- * Use this method to get singleton instance of RendererUtils
- * @return singleton instance
- */
- public static RendererUtils getInstance() {
- return INSTANCE;
- }
-
- /**
- * Encode id attribute with clientId component property
- *
- * @param context
- * @param component
- * @throws IOException
- */
- public void encodeId(FacesContext context, UIComponent component) throws IOException {
- encodeId(context, component, HTML.ID_ATTRIBUTE);
- }
-
- /**
- * Encode clientId to custom attribute ( for example, to control name )
- *
- * @param context
- * @param component
- * @param attribute
- * @throws IOException
- */
- public void encodeId(FacesContext context, UIComponent component, String attribute) throws IOException {
- String clientId = null;
-
- try {
- clientId = component.getClientId(context);
- } catch (Exception e) {
-
- // just ignore if clientId wasn't inited yet
- }
-
- if (null != clientId) {
- context.getResponseWriter().writeAttribute(attribute, clientId,
- (String) getComponentAttributeName(attribute));
- }
- }
-
- /**
- * Encode id attribute with clientId component property. Encoded only if id
- * not auto generated.
- *
- * @param context
- * @param component
- * @throws IOException
- */
- public void encodeCustomId(FacesContext context, UIComponent component) throws IOException {
- if (hasExplicitId(component)) {
- context.getResponseWriter().writeAttribute(HTML.ID_ATTRIBUTE, component.getClientId(context),
- HTML.ID_ATTRIBUTE);
- }
- }
-
- public Map<String, Object> createParametersMap(FacesContext context, UIComponent component) {
- Map<String, Object> parameters = new LinkedHashMap<String, Object>();
-
- if (component.getChildCount() > 0) {
- for (UIComponent child : component.getChildren()) {
- if (child instanceof UIParameter) {
- UIParameter parameter = (UIParameter) child;
- String name = parameter.getName();
- Object value = parameter.getValue();
-
- if (null == name) {
- throw new IllegalArgumentException(Messages.getMessage(Messages.UNNAMED_PARAMETER_ERROR,
- component.getClientId(context)));
- }
-
- boolean escape = true;
-
- if (child instanceof JavaScriptParameter) {
- JavaScriptParameter actionParam = (JavaScriptParameter) child;
-
- escape = !actionParam.isNoEscape();
- }
-
- if (escape) {
- if (value == null) {
- value = "";
- }
- } else {
- value = new JSReference(value.toString());
-
- // if(it.hasNext()){onEvent.append(',');};
- // renderAjaxLinkParameter( name,
- // value, onClick, jsForm, nestingForm);
- }
-
- parameters.put(name, value);
- }
- }
- }
-
- return parameters;
- }
-
- private void encodeBehaviors(FacesContext context, ClientBehaviorHolder behaviorHolder,
- String defaultHtmlEventName, String[] attributesExclusions)
- throws IOException {
-
-// if (attributesExclusions != null && attributesExclusions.length != 0) {
-// assert false : "Not supported yet";
-// }
- // TODO: disabled component check
- String defaultEventName = behaviorHolder.getDefaultEventName();
- Collection<String> eventNames = behaviorHolder.getEventNames();
-
- if (eventNames != null) {
- UIComponent component = (UIComponent) behaviorHolder;
- ResponseWriter writer = context.getResponseWriter();
- Collection<Parameter> parametersList = HandlersChain.createParametersList(createParametersMap(context,
- component));
-
- for (String behaviorEventName : eventNames) {
- if (behaviorEventName.equals(defaultEventName)) {
- continue;
- }
-
- String htmlEventName = "on" + behaviorEventName;
-
- if ((attributesExclusions == null) || (Arrays.binarySearch(attributesExclusions, htmlEventName) < 0)) {
- HandlersChain handlersChain = new HandlersChain(context, component, parametersList);
-
- handlersChain.addInlineHandlerFromAttribute(htmlEventName);
- handlersChain.addBehaviors(behaviorEventName);
-
- String handlerScript = handlersChain.toScript();
-
- if (!isEmpty(handlerScript)) {
- writer.writeAttribute(htmlEventName, handlerScript, htmlEventName);
- }
- }
- }
- }
- }
-
- /**
- * Encode common pass-thru html attributes.
- *
- * @param context
- * @param component
- * @throws IOException
- */
- public void encodePassThru(FacesContext context, UIComponent component, String defaultHtmlEvent)
- throws IOException {
-
- encodeAttributesFromArray(context, component, HTML.PASS_THRU);
-
- if (component instanceof ClientBehaviorHolder) {
- ClientBehaviorHolder clientBehaviorHolder = (ClientBehaviorHolder) component;
-
- encodeBehaviors(context, clientBehaviorHolder, defaultHtmlEvent, null);
- } else {
- encodeAttributesFromArray(context, component, HTML.PASS_THRU_EVENTS);
- }
- }
-
- /**
- * Encode pass-through attributes except specified ones
- *
- * @param context
- * @param component
- * @param exclusions
- * @throws IOException
- */
- public void encodePassThruWithExclusions(FacesContext context, UIComponent component, String exclusions,
- String defaultHtmlEvent) throws IOException {
-
- if (null != exclusions) {
- String[] exclusionsArray = exclusions.split(",");
-
- encodePassThruWithExclusionsArray(context, component, exclusionsArray, defaultHtmlEvent);
- }
- }
-
- public void encodePassThruWithExclusionsArray(FacesContext context, UIComponent component, String[] exclusions,
- String defaultHtmlEvent) throws IOException {
-
- ResponseWriter writer = context.getResponseWriter();
- Map<String, Object> attributes = component.getAttributes();
-
- Arrays.sort(exclusions);
-
- for (int i = 0; i < HTML.PASS_THRU.length; i++) {
- String attribute = HTML.PASS_THRU[i];
-
- if (Arrays.binarySearch(exclusions, attribute) < 0) {
- encodePassThruAttribute(context, attributes, writer, attribute);
- }
- }
-
- if (component instanceof ClientBehaviorHolder) {
- ClientBehaviorHolder clientBehaviorHolder = (ClientBehaviorHolder) component;
-
- encodeBehaviors(context, clientBehaviorHolder, defaultHtmlEvent, exclusions);
- } else {
- for (int i = 0; i < HTML.PASS_THRU_EVENTS.length; i++) {
- String attribute = HTML.PASS_THRU_EVENTS[i];
-
- if (Arrays.binarySearch(exclusions, attribute) < 0) {
- encodePassThruAttribute(context, attributes, writer, attribute);
- }
- }
- }
- }
-
- /**
- * Encode one pass-thru attribute, with plain/boolean/url value, got from
- * properly component attribute.
- *
- * @param context
- * @param writer
- * @param attribute
- * @throws IOException
- */
- public void encodePassThruAttribute(FacesContext context, Map<String, Object> attributes, ResponseWriter writer,
- String attribute) throws IOException {
-
- Object value = attributeValue(attribute, attributes.get(getComponentAttributeName(attribute)));
-
- if ((null != value) && shouldRenderAttribute(attribute, value)) {
- if (Arrays.binarySearch(HTML.PASS_THRU_URI, attribute) >= 0) {
- String url = context.getApplication().getViewHandler().getResourceURL(context, value.toString());
-
- url = context.getExternalContext().encodeResourceURL(url);
- writer.writeURIAttribute(attribute, url, attribute);
- } else {
- writer.writeAttribute(attribute, value, attribute);
- }
- }
- }
-
- public void encodeAttributesFromArray(FacesContext context, UIComponent component, String[] attrs)
- throws IOException {
-
- ResponseWriter writer = context.getResponseWriter();
- Map<String, Object> attributes = component.getAttributes();
-
- for (int i = 0; i < attrs.length; i++) {
- String attribute = attrs[i];
-
- encodePassThruAttribute(context, attributes, writer, attribute);
- }
- }
-
- /**
- * Encode attributes given by comma-separated string list.
- *
- * @param context
- * current JSF context
- * @param component
- * for with render attributes values
- * @param attrs
- * comma separated list of attributes
- * @throws IOException
- */
- public void encodeAttributes(FacesContext context, UIComponent component, String attrs) throws IOException {
- if (null != attrs) {
- String[] attrsArray = attrs.split(",");
-
- encodeAttributesFromArray(context, component, attrsArray);
- }
- }
-
- /**
- * @param context
- * @param component
- * @param property
- * @param attributeName
- *
- * @throws IOException
- */
- public void encodeAttribute(FacesContext context, UIComponent component, Object property, String attributeName)
- throws IOException {
-
- ResponseWriter writer = context.getResponseWriter();
- Object value = component.getAttributes().get(property);
-
- if (shouldRenderAttribute(attributeName, value)) {
- writer.writeAttribute(attributeName, value, property.toString());
- }
- }
-
- public void encodeAttribute(FacesContext context, UIComponent component, String attribute) throws IOException {
- encodeAttribute(context, component, getComponentAttributeName(attribute), attribute);
- }
-
- /**
- * Write html-attribute
- *
- * @param writer
- * @param attribute
- * @param value
- * @throws IOException
- */
- public void writeAttribute(ResponseWriter writer, String attribute, Object value) throws IOException {
- if (shouldRenderAttribute(attribute, value)) {
- writer.writeAttribute(attribute, value.toString(), attribute);
- }
- }
-
- /**
- * @return true if and only if the argument <code>attributeVal</code> is
- * an instance of a wrapper for a primitive type and its value is
- * equal to the default value for that type as given in the spec.
- */
- public boolean shouldRenderAttribute(Object attributeVal) {
- if (null == attributeVal) {
- return false;
- } else if ((attributeVal instanceof Boolean)
- && ((Boolean) attributeVal).booleanValue() == Boolean.FALSE.booleanValue()) {
- return false;
- } else if (attributeVal.toString().length() == 0) {
- return false;
- } else {
- return isValidProperty(attributeVal);
- }
- }
-
- public boolean shouldRenderAttribute(String attributeName, Object attributeVal) {
- if (REQUIRED_ATTRIBUTES.contains(attributeName)) {
- if (attributeVal == null) {
- return false;
- }
- } else {
- return shouldRenderAttribute(attributeVal);
- }
-
- return true;
- }
-
- /**
- * Test for valid value of property. by default, for non-setted properties
- * with Java primitive types of JSF component return appropriate MIN_VALUE .
- *
- * @param property -
- * value of property returned from
- * {@link UIComponent#getAttributes()}
- * @return true for setted property, false otherthise.
- */
- public boolean isValidProperty(Object property) {
- if (null == property) {
- return false;
- } else if ((property instanceof Integer) && ((Integer) property).intValue() == Integer.MIN_VALUE) {
- return false;
- } else if ((property instanceof Double) && ((Double) property).doubleValue() == Double.MIN_VALUE) {
- return false;
- } else if ((property instanceof Character) && ((Character) property).charValue() == Character.MIN_VALUE) {
- return false;
- } else if ((property instanceof Float) && ((Float) property).floatValue() == Float.MIN_VALUE) {
- return false;
- } else if ((property instanceof Short) && ((Short) property).shortValue() == Short.MIN_VALUE) {
- return false;
- } else if ((property instanceof Byte) && ((Byte) property).byteValue() == Byte.MIN_VALUE) {
- return false;
- } else if ((property instanceof Long) && ((Long) property).longValue() == Long.MIN_VALUE) {
- return false;
- }
-
- return true;
- }
-
- /**
- * Checks if the argument passed in is empty or not.
- * Object is empty if it is: <br />
- * - <code>null</code><br />
- * - zero-length string<br />
- * - empty collection<br />
- * - empty map<br />
- * - zero-length array<br />
- *
- * @param o object to check for emptiness
- * @since 3.3.2
- * @return <code>true</code> if the argument is empty, <code>false</code> otherwise
- */
- public boolean isEmpty(Object o) {
- if (null == o) {
- return true;
- }
-
- if (o instanceof String) {
- return 0 == ((String) o).length();
- }
-
- if (o instanceof Collection<?>) {
- return ((Collection<?>) o).isEmpty();
- }
-
- if (o instanceof Map<?, ?>) {
- return ((Map<?, ?>) o).isEmpty();
- }
-
- if (o.getClass().isArray()) {
- return Array.getLength(o) == 0;
- }
-
- return false;
- }
-
- /**
- * Puts value into map under specified key if the value is not empty and not default.
- * Performs optional value wrapping.
- *
- * @param hash
- * @param name
- * @param value
- * @param defaultValue
- * @param wrapper
- *
- * @since 3.3.2
- */
- public void addToScriptHash(Map<String, Object> hash, String name, Object value, String defaultValue,
- ScriptHashVariableWrapper wrapper) {
- ScriptHashVariableWrapper wrapperOrDefault = (wrapper != null) ? wrapper : ScriptHashVariableWrapper.DEFAULT;
-
- if (isValidProperty(value) && !isEmpty(value)) {
- if (!isEmpty(defaultValue)) {
- if (!defaultValue.equals(value.toString())) {
- hash.put(name, wrapperOrDefault.wrap(value));
- }
- } else {
- if (!(value instanceof Boolean) || ((Boolean) value).booleanValue()) {
- hash.put(name, wrapperOrDefault.wrap(value));
- }
- }
- }
- }
-
- /**
- * Puts value into map under specified key if the value is not empty and not default.
- * Performs optional value wrapping.
- *
- * @param hash
- * @param name
- * @param value
- * @param defaultValue
- *
- * @since 3.3.2
- */
- public void addToScriptHash(Map<String, Object> hash, String name, Object value, String defaultValue) {
- addToScriptHash(hash, name, value, defaultValue, null);
- }
-
- /**
- * Puts value into map under specified key if the value is not empty and not default.
- * Performs optional value wrapping.
- *
- * @param hash
- * @param name
- * @param value
- *
- * @since 3.3.2
- */
- public void addToScriptHash(Map<String, Object> hash, String name, Object value) {
- addToScriptHash(hash, name, value, null, null);
- }
-
- /**
- * Convert HTML attribute name to component property name.
- *
- * @param key
- * @return
- */
- protected Object getComponentAttributeName(Object key) {
- Object converted = SUBSTITUTIONS.get(key);
-
- if (null == converted) {
- return key;
- } else {
- return converted;
- }
- }
-
- /**
- * Convert attribute value to proper object. For known html boolean
- * attributes return name for true value, otherthise - null. For non-boolean
- * attributes return same value.
- *
- * @param name
- * attribute name.
- * @param value
- * @return
- */
- protected Object attributeValue(String name, Object value) {
- if (null == value || Arrays.binarySearch(HTML.PASS_THRU_BOOLEAN, name) < 0) {
- return value;
- }
-
- boolean checked;
-
- if (value instanceof Boolean) {
- checked = ((Boolean) value).booleanValue();
- } else {
- checked = Boolean.parseBoolean(value.toString());
- }
-
- return checked ? name : null;
- }
-
- /**
- * Get boolean value of logical attribute
- *
- * @param component
- * @param name
- * attribute name
- * @return true if attribute is equals Boolean.TRUE or String "true" , false
- * otherwise.
- */
- public boolean isBooleanAttribute(UIComponent component, String name) {
- Object attrValue = component.getAttributes().get(name);
- boolean result = false;
-
- if (null != attrValue) {
- if (attrValue instanceof String) {
- result = "true".equalsIgnoreCase((String) attrValue);
- } else {
- result = Boolean.TRUE.equals(attrValue);
- }
- }
-
- return result;
- }
-
- /**
- * Return converted value for {@link javax.faces.component.ValueHolder} as
- * String, perform nessesary convertions.
- *
- * @param context
- * @param component
- * @return
- */
- public String getValueAsString(FacesContext context, UIComponent component) {
-
- // First - get submitted value for input components
- if (component instanceof EditableValueHolder) {
- EditableValueHolder input = (EditableValueHolder) component;
- String submittedValue = (String) input.getSubmittedValue();
-
- if (null != submittedValue) {
- return submittedValue;
- }
- }
-
- // If no submitted value presented - convert same for UIInput/UIOutput
- if (component instanceof ValueHolder) {
- return formatValue(context, component, ((ValueHolder) component).getValue());
- } else {
- throw new IllegalArgumentException(
- Messages.getMessage(Messages.CONVERTING_NON_VALUE_HOLDER_COMPONENT_ERROR, component.getId()));
- }
- }
-
- /**
- * Convert any object value to string. If component instance of
- * {@link ValueHolder } got {@link Converter} for formatting. If not,
- * attempt to use converter based on value type.
- *
- * @param context
- * @param component
- * @return
- */
- public String formatValue(FacesContext context, UIComponent component, Object value) {
- if (value instanceof String) {
- return (String) value;
- }
-
- Converter converter = null;
-
- if (component instanceof ValueHolder) {
- ValueHolder holder = (ValueHolder) component;
-
- converter = holder.getConverter();
- }
-
- if ((null == converter) && (null != value)) {
- try {
- converter = context.getApplication().createConverter(value.getClass());
- } catch (FacesException e) {
-
- // TODO - log converter exception.
- }
- }
-
- if (null == converter) {
- if (null != value) {
- return value.toString();
- }
- } else {
- return converter.getAsString(context, component, value);
- }
-
- return "";
- }
-
- public String encodePx(String value) {
- return HtmlDimensions.formatPx(HtmlDimensions.decode(value));
- }
-
- /**
- * formats given value to
- *
- * @param value
- *
- * @return
- */
- public String encodePctOrPx(String value) {
- if (value.indexOf('%') > 0) {
- return value;
- } else {
- return encodePx(value);
- }
- }
-
- /**
- * Find nested form for given component
- *
- * @param component
- * @return nested <code>UIForm</code> component, or <code>null</code>
- */
- public UIForm getNestingForm(FacesContext context, UIComponent component) {
- UIComponent parent = component.getParent();
-
- while ((parent != null) && !(parent instanceof UIForm)) {
- parent = parent.getParent();
- }
-
- UIForm nestingForm = null;
-
- if (parent != null) {
-
- // link is nested inside a form
- nestingForm = (UIForm) parent;
- }
-
- return nestingForm;
- }
-
- /**
- * @param context
- * @param component
- * @return
- * @throws IOException
- */
- public void encodeBeginFormIfNessesary(FacesContext context, UIComponent component) throws IOException {
- UIForm form = getNestingForm(context, component);
-
- if (null == form) {
- ResponseWriter writer = context.getResponseWriter();
- String clientId = component.getClientId(context) + DUMMY_FORM_ID;
-
- encodeBeginForm(context, component, writer, clientId);
-
- // writer.writeAttribute(HTML.STYLE_ATTRIBUTE, "margin:0;
- // padding:0;", null);
- }
- }
-
- /**
- * @param context
- * @param component
- * @param writer
- * @param clientId
- * @throws IOException
- */
- public void encodeBeginForm(FacesContext context, UIComponent component, ResponseWriter writer, String clientId)
- throws IOException {
-
- String actionURL = getActionUrl(context);
- String encodeActionURL = context.getExternalContext().encodeActionURL(actionURL);
-
- writer.startElement(HTML.FORM_ELEMENT, component);
- writer.writeAttribute(HTML.ID_ATTRIBUTE, clientId, null);
- writer.writeAttribute(HTML.NAME_ATTRIBUTE, clientId, null);
- writer.writeAttribute(HTML.METHOD_ATTRIBUTE, "post", null);
- writer.writeAttribute(HTML.STYLE_ATTRIBUTE, "margin:0; padding:0; display: inline;", null);
- writer.writeURIAttribute(HTML.ACTION_ATTRIBUTE, encodeActionURL, "action");
- }
-
- /**
- * @param context
- * @param component
- * @throws IOException
- */
- public void encodeEndFormIfNessesary(FacesContext context, UIComponent component) throws IOException {
- UIForm form = getNestingForm(context, component);
-
- if (null == form) {
- ResponseWriter writer = context.getResponseWriter();
-
- // TODO - hidden form parameters ?
- encodeEndForm(context, writer);
- }
- }
-
- /**
- * @param context
- * @param writer
- * @throws IOException
- */
- public void encodeEndForm(FacesContext context, ResponseWriter writer) throws IOException {
- AjaxRendererUtils.writeState(context);
- writer.endElement(HTML.FORM_ELEMENT);
- }
-
- /**
- * @param facesContext
- * @return String A String representing the action URL
- */
- public String getActionUrl(FacesContext facesContext) {
- ViewHandler viewHandler = facesContext.getApplication().getViewHandler();
- String viewId = facesContext.getViewRoot().getViewId();
-
- return viewHandler.getActionURL(facesContext, viewId);
- }
-
- /**
- * Simplified version of {@link encodeId}
- *
- * @param context
- * @param component
- * @return client id of current component
- */
- public String clientId(FacesContext context, UIComponent component) {
- String clientId = "";
-
- try {
- clientId = component.getClientId(context);
- } catch (Exception e) {
-
- // just ignore
- }
-
- return clientId;
- }
-
- /**
- * Wtrie JavaScript with start/end elements and type.
- *
- * @param context
- * @param component
- * @param script
- */
- public void writeScript(FacesContext context, UIComponent component, Object script) throws IOException {
- ResponseWriter writer = context.getResponseWriter();
-
- writer.startElement(HTML.SCRIPT_ELEM, component);
- writer.writeAttribute(HTML.TYPE_ATTR, "text/javascript", "type");
- writer.writeText(script, null);
- writer.endElement(HTML.SCRIPT_ELEM);
- }
-
- /**
- * @param ids
- * @param keyword
- * @return
- * @since 4.0
- */
- private static boolean checkKeyword(Collection<String> ids, String keyword) {
- if (ids.contains(keyword)) {
- if (ids.size() != 1) {
- //TODO log
- }
-
- return true;
- }
-
- return false;
- }
-
- public String getPredefinedMetaComponentId(FacesContext facesContext, UIComponent component, String id) {
-
- if (AjaxRendererUtils.ALL.equals(id)) {
- return AjaxRendererUtils.ALL;
- } else if (AjaxRendererUtils.NONE.equals(id)) {
- return AjaxRendererUtils.NONE;
- } else if (AjaxRendererUtils.THIS.equals(id)) {
- return component.getClientId(facesContext);
- } else if (AjaxRendererUtils.FORM.equals(id)) {
- UIForm nestingForm = getNestingForm(facesContext, component);
- if (nestingForm != null) {
- return nestingForm.getClientId(facesContext);
- } else {
- //TODO nick - log warning for missing form
- }
- }
-
- return null;
- }
-
- /**
- * @param context
- * @param component
- * @param shortIds
- * @since 4.0
- * @return
- */
- public Collection<String> findComponentsFor(FacesContext context, UIComponent component,
- Collection<String> shortIds) {
-
- // TODO - implement
- // TODO add support for @*
- Set<String> result = new LinkedHashSet<String>(shortIds.size());
-
- if (checkKeyword(shortIds, AjaxRendererUtils.ALL)) {
- result.add(AjaxRendererUtils.ALL);
- } else if (checkKeyword(shortIds, AjaxRendererUtils.NONE)) {
- //do nothing, use empty set
- } else {
- ComponentIdResolver locator = new ComponentIdResolver(context);
-
- for (String id : shortIds) {
- String predefinedMetaComponentId = getPredefinedMetaComponentId(context, component, id);
- if (predefinedMetaComponentId != null) {
- if (AjaxRendererUtils.GLOBAL_META_COMPONENTS.contains(predefinedMetaComponentId)) {
- result.clear();
- result.add(predefinedMetaComponentId);
- break;
- } else {
- result.add(predefinedMetaComponentId);
- continue;
- }
- }
-
- locator.addId(id);
- }
-
- locator.resolve(component);
-
- result.addAll(locator.getResolvedIds());
- }
-
- return result;
- }
-
- public UIComponent findComponentFor(FacesContext context, UIComponent component, String id) {
- return findComponentFor(component, id);
- }
-
- /**
- * @param component
- * @param id
- * @return
- */
- public UIComponent findComponentFor(UIComponent component, String id) {
- if (id == null) {
- throw new NullPointerException("id is null!");
- }
-
- if (id.length() == 0) {
- return null;
- }
-
- UIComponent target = null;
- UIComponent parent = component;
- UIComponent root = component;
-
- while ((null == target) && (null != parent)) {
- target = parent.findComponent(id);
- root = parent;
- parent = parent.getParent();
- }
-
- if (null == target) {
- target = findUIComponentBelow(root, id);
- }
-
- return target;
- }
-
- /**
- * If target component contains generated id and for doesn't, correct for id
- * @param forAttr
- * @param component
- *
- */
- public String correctForIdReference(String forAttr, UIComponent component) {
- int contains = forAttr.indexOf(UIViewRoot.UNIQUE_ID_PREFIX);
-
- if (contains <= 0) {
- String id = component.getId();
- int pos = id.indexOf(UIViewRoot.UNIQUE_ID_PREFIX);
-
- if (pos > 0) {
- return forAttr.concat(id.substring(pos));
- }
- }
-
- return forAttr;
- }
-
- private UIComponent findUIComponentBelow(UIComponent root, String id) {
- UIComponent target = null;
-
- for (Iterator<UIComponent> iter = root.getFacetsAndChildren(); iter.hasNext();) {
- UIComponent child = (UIComponent) iter.next();
-
- if (child instanceof NamingContainer) {
- try {
- target = child.findComponent(id);
- } catch (IllegalArgumentException iae) {
- continue;
- }
- }
-
- if (target == null) {
- if ((child.getChildCount() > 0) || (child.getFacetCount() > 0)) {
- target = findUIComponentBelow(child, id);
- }
- }
-
- if (target != null) {
- break;
- }
- }
-
- return target;
- }
-
- public static void writeEventHandlerFunction(FacesContext context, UIComponent component, String eventName)
- throws IOException {
-
- ResponseWriter writer = context.getResponseWriter();
- Object script = component.getAttributes().get(eventName);
-
- if ((script != null) && !script.equals("")) {
- JSFunctionDefinition onEventDefinition = new JSFunctionDefinition();
-
- onEventDefinition.addParameter("event");
- onEventDefinition.addToBody(script);
- writer.writeText(eventName + ": " + onEventDefinition.toScript(), null);
- } else {
- writer.writeText(eventName + ": ''", null);
- }
- }
-
- public JSFunctionDefinition getAsEventHandler(FacesContext context, UIComponent component, String attributeName,
- String append) {
- String event = (String) component.getAttributes().get(attributeName);
-
- if (event != null) {
- event = event.trim();
-
- if (event.length() != 0) {
- JSFunctionDefinition function = new JSFunctionDefinition();
-
- function.addParameter("event");
-
- if ((null != append) && (append.length() > 0)) {
- function.addToBody(event + append);
- } else {
- function.addToBody(event);
- }
-
- return function;
- }
- }
-
- return null;
- }
-
- public String escapeJavaScript(Object o) {
- if (o != null) {
- StringBuilder result = new StringBuilder();
- JSEncoder encoder = new JSEncoder();
- char[] chars = o.toString().toCharArray();
- int start = 0;
- int end = chars.length;
-
- for (int x = start; x < end; x++) {
- char c = chars[x];
-
- if (encoder.compile(c)) {
- continue;
- }
-
- if (start != x) {
- result.append(chars, start, x - start);
- }
-
- result.append(encoder.encode(c));
- start = x + 1;
-
- continue;
- }
-
- if (start != end) {
- result.append(chars, start, end - start);
- }
-
- return result.toString();
- } else {
- return null;
- }
- }
-
- public void encodeChildren(FacesContext context, UIComponent component) throws IOException {
- if (component.getChildCount() > 0) {
- for (UIComponent child : component.getChildren()) {
- child.encodeAll(context);
- }
- }
- }
-
- public boolean hasExplicitId(UIComponent component) {
- return component.getId() != null && !component.getId().startsWith(UIViewRoot.UNIQUE_ID_PREFIX);
- }
-
- /**
- * Common HTML elements and attributes names.
- *
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.6 $ $Date: 2007/02/08 19:07:16 $
- *
- */
- public interface HTML {
- // elements
- public static final String A_ELEMENT = "a";
- public static final String BODY_ELEMENT = "body";
- public static final String IMG_ELEMENT = "img";
- public static final String INPUT_ELEM = "input";
- public static final String INPUT_TYPE_HIDDEN = "hidden";
- public static final String BUTTON = "button";
- public static final String CAPTION_ELEMENT = "caption";
- public static final String CHARSET_ATTR = "charset";
- public static final String COORDS_ATTR = "coords";
- public static final String COLGROUP_ELEMENT = "colgroup";
- public static final String COL_ELEMENT = "col";
- public static final String DISABLED_ATTR = "disabled";
- public static final String DIV_ELEM = "div";
- public static final String DD_ELEMENT = "dd";
- public static final String DL_ELEMENT = "dl";
- public static final String DT_ELEMENT = "dt";
- public static final String FORM_ELEMENT = "form";
- public static final String HEAD_ELEMENT = "head";
- public static final String HEIGHT_ATTRIBUTE = "height";
- public static final String HREFLANG_ATTR = "hreflang";
- public static final String HREF_ATTR = "href";
- public static final String HTML_ELEMENT = "html";
- public static final String LINK_ELEMENT = "link";
- public static final String SCRIPT_ELEM = "script";
- public static final String SPAN_ELEM = "span";
- public static final String TFOOT_ELEMENT = "tfoot";
- public static final String THEAD_ELEMENT = "thead";
- public static final String TABLE_ELEMENT = "table";
- public static final String TBODY_ELEMENT = "tbody";
- public static final String TD_ELEM = "td";
- public static final String TR_ELEMENT = "tr";
- public static final String TH_ELEM = "th";
- public static final String TITLE_ELEM = "title";
- public static final String UL_ELEMENT = "ul";
- public static final String OL_ELEMENT = "ol";
- public static final String LI_ELEMENT = "li";
-
- // attributes
- public static final String FRAME_ATTRIBUTE = "frame";
- public static final String BORDER_ATTRIBUTE = "border";
- public static final String BGCOLOR_ATTRIBUTE = "bgcolor";
- public static final String ACCEPT_ATTRIBUTE = "accept";
- public static final String ACCEPT_CHARSET_ATTRIBUTE = "accept-charset";
- public static final String ACCESSKEY_ATTRIBUTE = "accesskey";
- public static final String ACTION_ATTRIBUTE = "action";
- public static final String ALIGN_ATTRIBUTE = "align";
- public static final String ALT_ATTRIBUTE = "alt";
- public static final String AUTOCOMPLETE_ATTRIBUTE = "autocomplete";
- public static final String CLASS_ATTRIBUTE = "class";
- public static final String COLS_ATTRIBUTE = "cols";
- public static final String COLSPAN_ATTRIBUTE = "colspan";
- public static final String CELLPADDING_ATTRIBUTE = "cellpadding";
- public static final String CELLSPACING_ATTRIBUTE = "cellspacing";
- public static final String DIR_ATTRIBUTE = "dir";
- public static final String ENCTYPE_ATTRIBUTE = "enctype";
-
- public static final String ID_ATTRIBUTE = "id";
- public static final String LANG_ATTRIBUTE = "lang";
- public static final String LONGDESC_ATTRIBUTE = "longdesc";
- public static final String MAXLENGTH_ATTRIBUTE = "maxlength";
- public static final String MEDIA_ATTRIBUTE = "media";
- public static final String METHOD_ATTRIBUTE = "method";
- public static final String NAME_ATTRIBUTE = "name";
- public static final String NOWRAP_ATTRIBUTE = "nowrap";
- public static final String ROWS_ATTRIBUTE = "rows";
- public static final String RULES_ATTRIBUTE = "rules";
- public static final String ROWSPAN_ATTRIBUTE = "rowspan";
- public static final String READONLY_ATTRIBUTE = "readonly";
- public static final String SIZE_ATTRIBUTE = "size";
- public static final String SRC_ATTRIBUTE = "src";
- public static final String STYLE_ATTRIBUTE = "style";
- public static final String SUMMARY_ATTRIBUTE = "summary";
- public static final String SCOPE_ATTRIBUTE = "scope";
- public static final String TABINDEX_ATTRIBUTE = "tabindex";
- public static final String TITLE_ATTRIBUTE = "title";
- public static final String TARGET_ATTRIBUTE = "target";
- public static final String TYPE_ATTR = "type";
-
- public static final String USEMAP_ATTRIBUTE = "usemap";
-
- public static final String VALIGN_ATTRIBUTE = "valign";
- public static final String VALUE_ATTRIBUTE = "value";
- public static final String WIDTH_ATTRIBUTE = "width";
-
-
- public static final String ONBLUR_ATTRIBUTE = "onblur";
- public static final String ONCHANGE_ATTRIBUTE = "onchange";
- public static final String ONCLICK_ATTRIBUTE = "onclick";
- public static final String ONDBLCLICK_ATTRIBUTE = "ondblclick";
- public static final String ONFOCUS_ATTRIBUTE = "onfocus";
- public static final String ONKEYDOWN_ATTRIBUTE = "onkeydown";
- public static final String ONKEYPRESS_ATTRIBUTE = "onkeypress";
- public static final String ONKEYUP_ATTRIBUTE = "onkeyup";
- public static final String ONLOAD_ATTRIBUTE = "onload";
- public static final String ONMOUSEDOWN_ATTRIBUTE = "onmousedown";
- public static final String ONMOUSEMOVE_ATTRIBUTE = "onmousemove";
- public static final String ONMOUSEOUT_ATTRIBUTE = "onmouseout";
- public static final String ONMOUSEOVER_ATTRIBUTE = "onmouseover";
- public static final String ONMOUSEUP_ATTRIBUTE = "onmouseup";
- public static final String ONRESET_ATTRIBUTE = "onreset";
- public static final String ONSELECT_ATTRIBUTE = "onselect";
- public static final String ONSUBMIT_ATTRIBUTE = "onsubmit";
- public static final String ONUNLOAD_ATTRIBUTE = "onunload";
-
- public static final String REL_ATTR = "rel";
- public static final String REV_ATTR = "rev";
- public static final String SHAPE_ATTR = "shape";
- public static final String STYLE_CLASS_ATTR = "styleClass";
-
-
-
- // public static final String ONRESET_ATTRIBUTE = "onreset";
- // attributes sets.
- public static final String[] PASS_THRU = {
-
- // DIR_ATTRIBUTE,
- // LANG_ATTRIBUTE,
- // STYLE_ATTRIBUTE,
- // TITLE_ATTRIBUTE
- "accesskey", "alt", "cols", "height", "lang", "longdesc", "maxlength", "rows", "size", "tabindex", "title",
- "width", "dir", "rules", "frame", "border", "cellspacing", "cellpadding", "summary", "bgcolor", "usemap",
- "enctype", "accept-charset", "accept", "target", "charset", "coords", "hreflang", "rel", "rev", "shape",
- "disabled", "readonly", "ismap", "align"
- };
-
- /**
- * HTML attributes allowed boolean-values only
- */
- public static final String[] PASS_THRU_BOOLEAN = {
- "disabled", "declare", "readonly", "compact", "ismap", "selected", "checked", "nowrap", "noresize",
- "nohref", "noshade", "multiple"
- };
- public static final String[] PASS_THRU_EVENTS = {
- "onblur", "onchange", "onclick", "ondblclick", "onfocus", "onkeydown", "onkeypress", "onkeyup", "onload",
- "onmousedown", "onmousemove", "onmouseout", "onmouseover", "onmouseup", "onreset", "onselect", "onsubmit",
- "onunload"
- };
- public static final String[] PASS_THRU_STYLES = {"style", "class", };
-
- /**
- * all HTML attributes with URI value.
- */
- public static final String[] PASS_THRU_URI = {
- "usemap", "background", "codebase", "cite", "data", "classid", "href", "longdesc", "profile", "src"
- };
-
-
- public static final String TEXT_JAVASCRIPT_TYPE = "text/javascript";
- public static final String REL_STYLESHEET = "stylesheet";
- public static final String CSS_TYPE = "text/css";
- public static final String JAVASCRIPT_TYPE = "text/javascript";
- }
-}
Deleted: branches/RF-7560/core/impl/src/main/java/org/richfaces/component/UIRangedNumberInput.java
===================================================================
--- branches/RF-7560/core/impl/src/main/java/org/richfaces/component/UIRangedNumberInput.java 2010-08-31 17:45:24 UTC (rev 19053)
+++ branches/RF-7560/core/impl/src/main/java/org/richfaces/component/UIRangedNumberInput.java 2010-08-31 18:46:44 UTC (rev 19054)
@@ -1,122 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces - Ajax4jsf Component Library
- *
- * 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.component;
-
-import org.richfaces.component.util.MessageUtil;
-
-import javax.faces.application.FacesMessage;
-import javax.faces.component.UIInput;
-import javax.faces.context.FacesContext;
-
-/**
- * @author Nick - mailto:nbelaevski@exadel.com
- * created 20.02.2007
- */
-public abstract class UIRangedNumberInput extends UIInput {
- public abstract String getMaxValue();
-
- public abstract void setMaxValue(String value);
-
- public abstract String getMinValue();
-
- public abstract void setMinValue(String value);
-
- public abstract boolean isDisabled();
-
- public abstract void setDisabled(boolean disabled);
-
- @Override
- public void decode(FacesContext arg0) {
- if (this.isDisabled()) {
- return;
- }
-
- super.decode(arg0);
- }
-
- @Override
- protected void validateValue(FacesContext context, Object newValue) {
- if (isValid() && !isEmpty(newValue)) {
- String label = MessageUtil.getLabel(context, this).toString();
- Double minValue = null;
- Double maxValue = null;
- Double value = null;
-
- try {
- minValue = convert(getMinValue());
- maxValue = convert(getMaxValue());
-
- // convert value and check if it is in range
- value = convert(newValue);
- } catch (Exception e) {
- setValid(false);
-
- FacesMessage mess = new FacesMessage(label + ": " + e.getLocalizedMessage());
-
- mess.setSeverity(FacesMessage.SEVERITY_ERROR);
- context.addMessage(this.getClientId(context), mess);
- }
-
- if (value != null) {
- if ((null == minValue) || (null == maxValue)) {
- setValid(false);
-
- FacesMessage mess = new FacesMessage(label + ": conversation error, maxValue or minValue is null!");
-
- mess.setSeverity(FacesMessage.SEVERITY_ERROR);
- context.addMessage(this.getClientId(context), mess);
- } else if (minValue.doubleValue() > value.doubleValue()) {
- setValid(false);
-
- FacesMessage mess = new FacesMessage(label + ": input value is less than minimal value!");
-
- mess.setSeverity(FacesMessage.SEVERITY_ERROR);
- context.addMessage(this.getClientId(context), mess);
- } else if (maxValue.doubleValue() < value.doubleValue()) {
- setValid(false);
-
- FacesMessage mess = new FacesMessage(label + ": input value is more than maximum value!");
-
- mess.setSeverity(FacesMessage.SEVERITY_ERROR);
- context.addMessage(this.getClientId(context), mess);
- }
- } else {
- setValid(false);
-
- FacesMessage mess = new FacesMessage(label + ": input value can't be null!");
-
- mess.setSeverity(FacesMessage.SEVERITY_ERROR);
- context.addMessage(this.getClientId(context), mess);
- }
- }
-
- super.validateValue(context, newValue);
- }
-
- private Double convert(Object object) {
- if (object == null) {
- return null;
- }
-
- return new Double(object.toString());
- }
-}
Deleted: branches/RF-7560/core/impl/src/main/java/org/richfaces/component/util/AbstractMessageUtil.java
===================================================================
--- branches/RF-7560/core/impl/src/main/java/org/richfaces/component/util/AbstractMessageUtil.java 2010-08-31 17:45:24 UTC (rev 19053)
+++ branches/RF-7560/core/impl/src/main/java/org/richfaces/component/util/AbstractMessageUtil.java 2010-08-31 18:46:44 UTC (rev 19054)
@@ -1,129 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces - Ajax4jsf Component Library
- *
- * 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.component.util;
-
-import javax.faces.application.Application;
-import javax.faces.application.FacesMessage;
-import javax.faces.component.UIViewRoot;
-import javax.faces.context.FacesContext;
-import java.text.MessageFormat;
-import java.util.Locale;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-/**
- * Created 19.06.2008
- *
- * @author Nick Belaevski
- * @since 3.2.2
- */
-public final class AbstractMessageUtil {
- private AbstractMessageUtil() {
- }
-
- private static ResourceBundle getResourceBundle(String baseName, Locale locale, ClassLoader loader) {
- if (loader != null) {
- return ResourceBundle.getBundle(baseName, locale, loader);
- } else {
- return ResourceBundle.getBundle(baseName, locale);
- }
- }
-
- private static FacesMessage getMessage(FacesContext context, String messageId, Object[] parameters, Locale locale,
- String baseBundleName) {
- String summary = null;
- String detail = null;
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
-
- if (context != null) {
- Application application = context.getApplication();
-
- if (application != null) {
- String messageBundleName = application.getMessageBundle();
-
- if (messageBundleName != null) {
- ResourceBundle bundle = getResourceBundle(messageBundleName, locale, loader);
-
- if (bundle != null) {
- try {
- summary = bundle.getString(messageId);
- detail = bundle.getString(messageId + "_detail");
- } catch (MissingResourceException e) {
-
- // do nothing
- }
- }
- }
- }
- }
-
- if (summary == null) {
- ResourceBundle bundle = getResourceBundle(baseBundleName, locale, loader);
-
- try {
- summary = bundle.getString(messageId);
-
- if (summary == null) {
- return null;
- }
-
- detail = bundle.getString(messageId + "_detail");
- } catch (MissingResourceException e) {
-
- // do nothing
- }
- }
-
- String formattedSummary = MessageFormat.format(summary, parameters);
- String formattedDetail = null;
-
- if (detail != null) {
- formattedDetail = MessageFormat.format(detail, parameters);
- }
-
- return new FacesMessage(formattedSummary, formattedDetail);
- }
-
- static FacesMessage getMessage(FacesContext context, String messageId, Object[] parameters, String baseBundleName) {
- Locale locale;
- FacesMessage result = null;
-
- if (context != null) {
- UIViewRoot viewRoot = context.getViewRoot();
-
- if (viewRoot != null) {
- locale = viewRoot.getLocale();
-
- if (locale != null) {
- result = getMessage(context, messageId, parameters, locale, baseBundleName);
- }
- }
- }
-
- if (result == null) {
- locale = Locale.getDefault();
- result = getMessage(context, messageId, parameters, locale, baseBundleName);
- }
-
- return result;
- }
-}
Deleted: branches/RF-7560/core/impl/src/main/java/org/richfaces/component/util/ComponentMessageUtil.java
===================================================================
--- branches/RF-7560/core/impl/src/main/java/org/richfaces/component/util/ComponentMessageUtil.java 2010-08-31 17:45:24 UTC (rev 19053)
+++ branches/RF-7560/core/impl/src/main/java/org/richfaces/component/util/ComponentMessageUtil.java 2010-08-31 18:46:44 UTC (rev 19054)
@@ -1,40 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces - Ajax4jsf Component Library
- *
- * 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.component.util;
-
-import javax.faces.application.FacesMessage;
-import javax.faces.context.FacesContext;
-
-/**
- * @author Nick Belaevski
- * @since 3.2.2
- */
-public final class ComponentMessageUtil {
- public static final String MESSAGE_BUNDLE_NAME = "org.richfaces.component.messages";
-
- private ComponentMessageUtil() {
- }
-
- public static FacesMessage getMessage(FacesContext context, String messageId, Object[] parameters) {
- return AbstractMessageUtil.getMessage(context, messageId, parameters, MESSAGE_BUNDLE_NAME);
- }
-}
Deleted: branches/RF-7560/core/impl/src/main/java/org/richfaces/component/util/HtmlUtil.java
===================================================================
--- branches/RF-7560/core/impl/src/main/java/org/richfaces/component/util/HtmlUtil.java 2010-08-31 17:45:24 UTC (rev 19053)
+++ branches/RF-7560/core/impl/src/main/java/org/richfaces/component/util/HtmlUtil.java 2010-08-31 18:46:44 UTC (rev 19054)
@@ -1,153 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces - Ajax4jsf Component Library
- *
- * 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.component.util;
-
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import javax.faces.component.UIComponent;
-import javax.faces.component.UIViewRoot;
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.javascript.ScriptUtils;
-import org.ajax4jsf.renderkit.RendererUtils;
-import org.ajax4jsf.util.HtmlDimensions;
-
-import com.google.common.base.Strings;
-
-/**
- * @author Nick Belaevski - nbelaevski(a)exadel.com created 09.02.2007
- */
-public final class HtmlUtil {
- public static final Pattern ID_SELECTOR_PATTERN =
- Pattern.compile(
- "#((?:-[A-Za-z_-]|[A-Za-z_]|\\\\[^A-F0-9U]|\\\\[A-F0-9]{1,6}\\s?|\\\\U[0-9A-F]{2}(?:A[1-9A-F]|[B-F][0-9A-F]))(?:\\\\[A-F0-9]{1,6}\\s?|[A-Za-z0-9_-]|\\\\:)*)");
- private static final String ORG_AJAX4JSF = "org.ajax4jsf.";
- private static final String ORG_RICHFACES = "org.richfaces.";
-
- private HtmlUtil() {
- }
-
- public static String qualifySize(String sizeDeclaration) {
- String trimmedValue = sizeDeclaration.trim();
-
- if (trimmedValue.length() != 0) {
- char lastChar = trimmedValue.charAt(trimmedValue.length() - 1);
-
- if (Character.isDigit(lastChar)) {
- return sizeDeclaration + "px";
- }
- }
-
- return sizeDeclaration;
- }
-
- public static String addToSize(String declaration, String delta) {
- Double doubleDelta = HtmlDimensions.decode(delta);
- Double decoded = HtmlDimensions.decode(declaration);
-
- return HtmlDimensions.formatPx(new Double(decoded.doubleValue() + doubleDelta.doubleValue()));
- }
-
- private static String escapeReplacement(String s) {
- return s.replaceAll("(\\\\|\\$)", "\\\\$1");
- }
-
- public static String expandIdSelector(String selector, UIComponent component, FacesContext context) {
- Matcher matcher = ID_SELECTOR_PATTERN.matcher(selector);
- StringBuffer sb = new StringBuffer();
-
- while (matcher.find()) {
-
- // make new id selector here using matcher.group(1)
- String unescaped = matcher.group(1).replaceAll("\\\\:", ":");
- UIComponent target = RendererUtils.getInstance().findComponentFor(context, component, unescaped);
-
- if (target != null) {
- matcher.appendReplacement(sb, escapeReplacement("#" + ScriptUtils.escapeCSSMetachars(target.getClientId(context))));
- }
- }
-
- matcher.appendTail(sb);
-
- return sb.toString();
- }
-
- public static String idsToIdSelector(String ids) {
- StringBuffer buffer = new StringBuffer();
-
- if (ids != null) {
- String[] idString = ids.split("\\s*,\\s*");
-
- for (int i = 0; i < idString.length; i++) {
- if (i > 0) {
- buffer.append(",");
- }
-
- idString[i] = idString[i].replaceAll(":", "\\\\:");
- buffer.append("#").append(idString[i]);
- }
- }
-
- return buffer.toString();
- }
-
- public static boolean shouldWriteId(UIComponent component) {
- String rendererType = component.getRendererType();
- String id = component.getId();
-
- if ((id != null) && !id.startsWith(UIViewRoot.UNIQUE_ID_PREFIX)) {
- return true;
- }
-
- if ((rendererType != null)
- && (rendererType.startsWith(ORG_AJAX4JSF) || rendererType.startsWith(ORG_RICHFACES))) {
- return true;
- }
-
- return false;
- }
-
- private static String concat(char separator, String... strings) {
- StringBuilder result = new StringBuilder();
-
- for (String s : strings) {
- if (!Strings.isNullOrEmpty(s)) {
- if (result.length() != 0) {
- result.append(separator);
- }
-
- result.append(s.trim());
- }
- }
-
- return result.toString();
- }
-
- public static String concatClasses(String... classes) {
- return concat(' ', classes);
- }
-
- public static String concatStyles(String... styles) {
- return concat(';', styles);
- }
-}
Deleted: branches/RF-7560/core/impl/src/main/java/org/richfaces/component/util/MessageUtil.java
===================================================================
--- branches/RF-7560/core/impl/src/main/java/org/richfaces/component/util/MessageUtil.java 2010-08-31 17:45:24 UTC (rev 19053)
+++ branches/RF-7560/core/impl/src/main/java/org/richfaces/component/util/MessageUtil.java 2010-08-31 18:46:44 UTC (rev 19054)
@@ -1,78 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces - Ajax4jsf Component Library
- *
- * 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.component.util;
-
-import javax.faces.application.Application;
-import javax.faces.application.FacesMessage;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.el.ValueBinding;
-
-/**
- * @author Nick - mailto:nbelaevski@exadel.com
- * created 06.02.2007
- */
-public final class MessageUtil {
- private static final boolean IS_12;
-
- static {
- boolean is12;
-
- try {
- Application.class.getMethod("getExpressionFactory", null);
- is12 = true;
- } catch (NoSuchMethodException e) {
- is12 = false;
- }
-
- IS_12 = is12;
- }
-
- private MessageUtil() {
- }
-
- public static Object getLabel(FacesContext context, UIComponent component) {
- Object o = null;
-
- if (IS_12) {
- o = component.getAttributes().get("label");
-
- if ((o == null) || ((o instanceof String) && ((String) o).length() == 0)) {
- ValueBinding ex = component.getValueBinding("label");
-
- if (ex != null) {
- o = ex.getValue(context);
- }
- }
- }
-
- if (o == null) {
- o = component.getClientId(context);
- }
-
- return o;
- }
-
- public static FacesMessage getMessage(FacesContext context, String messageId, Object[] parameters) {
- return AbstractMessageUtil.getMessage(context, messageId, parameters, FacesMessage.FACES_MESSAGES);
- }
-}
Modified: branches/RF-7560/core/impl/src/main/java/org/richfaces/context/ComponentCallback.java
===================================================================
--- branches/RF-7560/core/impl/src/main/java/org/richfaces/context/ComponentCallback.java 2010-08-31 17:45:24 UTC (rev 19053)
+++ branches/RF-7560/core/impl/src/main/java/org/richfaces/context/ComponentCallback.java 2010-08-31 18:46:44 UTC (rev 19054)
@@ -22,8 +22,8 @@
package org.richfaces.context;
import org.ajax4jsf.component.AjaxClientBehavior;
-import org.ajax4jsf.renderkit.AjaxRendererUtils;
-import org.ajax4jsf.renderkit.RendererUtils;
+import org.richfaces.renderkit.util.AjaxRendererUtils;
+import org.richfaces.renderkit.util.RendererUtils;
import javax.faces.component.UIComponent;
import javax.faces.component.behavior.ClientBehavior;
Modified: branches/RF-7560/core/impl/src/main/java/org/richfaces/context/ComponentIdResolver.java
===================================================================
--- branches/RF-7560/core/impl/src/main/java/org/richfaces/context/ComponentIdResolver.java 2010-08-31 17:45:24 UTC (rev 19053)
+++ branches/RF-7560/core/impl/src/main/java/org/richfaces/context/ComponentIdResolver.java 2010-08-31 18:46:44 UTC (rev 19054)
@@ -36,10 +36,10 @@
import javax.faces.component.UINamingContainer;
import javax.faces.context.FacesContext;
-import org.ajax4jsf.renderkit.AjaxRendererUtils;
-import org.ajax4jsf.renderkit.RendererUtils;
import org.richfaces.component.AjaxContainer;
import org.richfaces.component.MetaComponentResolver;
+import org.richfaces.renderkit.util.AjaxRendererUtils;
+import org.richfaces.renderkit.util.RendererUtils;
/**
* @author Nick Belaevski
Modified: branches/RF-7560/core/impl/src/main/java/org/richfaces/context/IdTreeNode.java
===================================================================
--- branches/RF-7560/core/impl/src/main/java/org/richfaces/context/IdTreeNode.java 2010-08-31 17:45:24 UTC (rev 19053)
+++ branches/RF-7560/core/impl/src/main/java/org/richfaces/context/IdTreeNode.java 2010-08-31 18:46:44 UTC (rev 19054)
@@ -26,7 +26,7 @@
import java.util.Collections;
import java.util.List;
-import org.ajax4jsf.renderkit.AjaxRendererUtils;
+import org.richfaces.renderkit.util.AjaxRendererUtils;
final class IdTreeNode {
Modified: branches/RF-7560/core/impl/src/main/java/org/richfaces/context/PartialViewContextImpl.java
===================================================================
--- branches/RF-7560/core/impl/src/main/java/org/richfaces/context/PartialViewContextImpl.java 2010-08-31 17:45:24 UTC (rev 19053)
+++ branches/RF-7560/core/impl/src/main/java/org/richfaces/context/PartialViewContextImpl.java 2010-08-31 18:46:44 UTC (rev 19054)
@@ -43,10 +43,10 @@
import javax.faces.event.PhaseId;
import org.ajax4jsf.context.AjaxContext;
-import org.ajax4jsf.renderkit.AjaxRendererUtils;
import org.richfaces.component.MetaComponentEncoder;
import org.richfaces.log.Logger;
import org.richfaces.log.RichfacesLogger;
+import org.richfaces.renderkit.util.AjaxRendererUtils;
/**
* @author Nick Belaevski
Modified: branches/RF-7560/core/impl/src/main/java/org/richfaces/context/RenderComponentCallback.java
===================================================================
--- branches/RF-7560/core/impl/src/main/java/org/richfaces/context/RenderComponentCallback.java 2010-08-31 17:45:24 UTC (rev 19053)
+++ branches/RF-7560/core/impl/src/main/java/org/richfaces/context/RenderComponentCallback.java 2010-08-31 18:46:44 UTC (rev 19054)
@@ -22,7 +22,7 @@
package org.richfaces.context;
import org.ajax4jsf.component.AjaxClientBehavior;
-import org.ajax4jsf.renderkit.AjaxRendererUtils;
+import org.richfaces.renderkit.util.AjaxRendererUtils;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
Copied: branches/RF-7560/core/impl/src/main/java/org/richfaces/renderkit/HandlersChain.java (from rev 19052, branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/renderkit/HandlersChain.java)
===================================================================
--- branches/RF-7560/core/impl/src/main/java/org/richfaces/renderkit/HandlersChain.java (rev 0)
+++ branches/RF-7560/core/impl/src/main/java/org/richfaces/renderkit/HandlersChain.java 2010-08-31 18:46:44 UTC (rev 19054)
@@ -0,0 +1,211 @@
+/**
+ * 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;
+
+import static org.richfaces.renderkit.util.AjaxRendererUtils.AJAX_FUNCTION_NAME;
+import static org.richfaces.renderkit.util.AjaxRendererUtils.buildAjaxFunction;
+import static org.richfaces.renderkit.util.AjaxRendererUtils.buildEventOptions;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import javax.faces.component.UIComponent;
+import javax.faces.component.behavior.ClientBehavior;
+import javax.faces.component.behavior.ClientBehaviorContext;
+import javax.faces.component.behavior.ClientBehaviorContext.Parameter;
+import javax.faces.component.behavior.ClientBehaviorHint;
+import javax.faces.component.behavior.ClientBehaviorHolder;
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.javascript.JSFunction;
+import org.ajax4jsf.javascript.JSReference;
+import org.ajax4jsf.renderkit.AjaxEventOptions;
+import org.richfaces.renderkit.util.RendererUtils;
+
+/**
+ * @author Nick Belaevski
+ * @since 4.0
+ */
+public final class HandlersChain {
+
+ // private static final Logger LOG = RichfacesLogger.RENDERKIT.getLogger();
+ private boolean hasSubmittingBehavior = false;
+ private boolean includeClientId = false;
+
+ // TODO: review for optimization
+ private List<String> handlers = new ArrayList<String>(2);
+
+ private FacesContext facesContext;
+ private UIComponent component;
+ private Collection<Parameter> parameters;
+
+ public HandlersChain(FacesContext facesContext, UIComponent component) {
+ this.facesContext = facesContext;
+ this.component = component;
+ }
+
+ public HandlersChain(FacesContext facesContext, UIComponent component, boolean includeClientId) {
+ this.facesContext = facesContext;
+ this.component = component;
+ this.includeClientId = includeClientId;
+ }
+
+ public HandlersChain(FacesContext facesContext, UIComponent component, Collection<Parameter> parameters) {
+ this.facesContext = facesContext;
+ this.component = component;
+ this.parameters = parameters;
+ }
+
+ public HandlersChain(FacesContext facesContext, UIComponent component, Collection<Parameter> parameters, boolean includeClientId) {
+ this.facesContext = facesContext;
+ this.component = component;
+ this.parameters = parameters;
+ this.includeClientId = includeClientId;
+ }
+
+ private static boolean isNotEmpty(String s) {
+ return (s != null) && (s.length() != 0);
+ }
+
+ private List<ClientBehavior> getBehaviorsList(String behaviorName) {
+ List<ClientBehavior> behaviors = null;
+
+ if (component instanceof ClientBehaviorHolder) {
+ ClientBehaviorHolder clientBehaviorHolder = (ClientBehaviorHolder) component;
+ Map<String, List<ClientBehavior>> clientBehaviorsMap = clientBehaviorHolder.getClientBehaviors();
+
+ if (clientBehaviorsMap != null) {
+ behaviors = clientBehaviorsMap.get(behaviorName);
+ }
+ }
+
+ return behaviors;
+ }
+
+ private Collection<Parameter> getParameters() {
+ if (parameters == null) {
+ RendererUtils rendererUtils = RendererUtils.getInstance();
+ Map<String, Object> parametersMap = rendererUtils.createParametersMap(facesContext, component);
+
+ parameters = createParametersList(parametersMap);
+ }
+
+ return parameters;
+ }
+
+ public boolean hasSubmittingBehavior() {
+ return hasSubmittingBehavior;
+ }
+
+ public void addInlineHandlerAsValue(String handlerValue) {
+ if (isNotEmpty(handlerValue)) {
+ handlers.add(handlerValue);
+ }
+ }
+
+ public void addInlineHandlerFromAttribute(String attributeName) {
+ addInlineHandlerAsValue((String) component.getAttributes().get(attributeName));
+ }
+
+ public void addBehaviors(String domEventName) {
+ addBehaviors(domEventName, null);
+ }
+
+ public void addBehaviors(String domEventName, String logicalEventName) {
+ String name = domEventName;
+ List<ClientBehavior> behaviorsList = getBehaviorsList(domEventName);
+
+ if ((behaviorsList == null) && (logicalEventName != null)) {
+ behaviorsList = getBehaviorsList(logicalEventName);
+ name = logicalEventName;
+ }
+
+ if (behaviorsList == null) {
+ return;
+ }
+
+ ClientBehaviorContext behaviorContext = ClientBehaviorContext.createClientBehaviorContext(facesContext, component,
+ name, includeClientId ? component.getClientId(facesContext) : null,
+ getParameters());
+
+ for (ClientBehavior clientBehavior : behaviorsList) {
+ String behaviorScript = clientBehavior.getScript(behaviorContext);
+
+ if (isNotEmpty(behaviorScript)) {
+ if (clientBehavior.getHints().contains(ClientBehaviorHint.SUBMITTING)) {
+ hasSubmittingBehavior = true;
+ }
+
+ handlers.add(behaviorScript);
+ }
+ }
+ }
+
+ public void addAjaxSubmitFunction() {
+ if (!this.hasSubmittingBehavior()) {
+ hasSubmittingBehavior = true;
+
+ JSFunction ajaxFunction = buildAjaxFunction(facesContext, component, AJAX_FUNCTION_NAME);
+ AjaxEventOptions eventOptions = buildEventOptions(facesContext, component);
+
+ if (!eventOptions.isEmpty()) {
+ ajaxFunction.addParameter(eventOptions);
+ }
+
+ this.addInlineHandlerAsValue(ajaxFunction.toScript());
+ }
+ }
+
+ public String toScript() {
+ String result = null;
+
+ if (!handlers.isEmpty()) {
+ if (handlers.size() == 1) {
+ result = handlers.get(0);
+ } else {
+ JSFunction jsFunction = new JSFunction("jsf.util.chain", JSReference.THIS, JSReference.EVENT);
+
+ for (String handler : handlers) {
+ jsFunction.addParameter(handler);
+ }
+
+ result = jsFunction.toScript();
+ }
+ }
+
+ return result;
+ }
+
+ public static List<Parameter> createParametersList(Map<String, Object> parametersMap) {
+ List<Parameter> parameters = new ArrayList<Parameter>(parametersMap.size());
+
+ for (Entry<String, Object> entry : parametersMap.entrySet()) {
+ parameters.add(new Parameter(entry.getKey(), entry.getValue()));
+ }
+
+ return parameters;
+ }
+
+}
Copied: branches/RF-7560/core/impl/src/main/java/org/richfaces/renderkit/util/AjaxRendererUtils.java (from rev 19052, branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/renderkit/AjaxRendererUtils.java)
===================================================================
--- branches/RF-7560/core/impl/src/main/java/org/richfaces/renderkit/util/AjaxRendererUtils.java (rev 0)
+++ branches/RF-7560/core/impl/src/main/java/org/richfaces/renderkit/util/AjaxRendererUtils.java 2010-08-31 18:46:44 UTC (rev 19054)
@@ -0,0 +1,1147 @@
+/**
+ * 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.HashSet;
+import java.util.LinkedHashSet;
+import java.util.Map;
+import java.util.Set;
+
+import javax.faces.component.NamingContainer;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIForm;
+import javax.faces.context.FacesContext;
+import javax.faces.context.PartialResponseWriter;
+
+import org.ajax4jsf.Messages;
+import org.ajax4jsf.component.AjaxClientBehavior;
+import org.ajax4jsf.component.AjaxComponent;
+import org.ajax4jsf.context.AjaxContext;
+import org.ajax4jsf.javascript.JSFunction;
+import org.ajax4jsf.javascript.JSFunctionDefinition;
+import org.ajax4jsf.javascript.JSReference;
+import org.ajax4jsf.renderkit.AJAXDataSerializer;
+import org.ajax4jsf.renderkit.AjaxEventOptions;
+import org.richfaces.application.ServiceTracker;
+import org.richfaces.log.Logger;
+import org.richfaces.log.RichfacesLogger;
+import org.richfaces.renderkit.HandlersChain;
+import org.richfaces.renderkit.util.RendererUtils.HTML;
+
+/**
+ * @author shura
+ * <p/>
+ * Some utilites for render AJAX components.
+ */
+public final class AjaxRendererUtils {
+
+ public static final String AJAX_ABORT_ATTR = "ignoreDupResponses";
+ public static final String AJAX_AREAS_RENDERED = "org.ajax4jsf.areas.rendered";
+ public static final String AJAX_DELAY_ATTR = "requestDelay";
+
+ /**
+ * Name Javasript function for submit AJAX request
+ */
+ public static final String AJAX_FUNCTION_NAME = "RichFaces.ajax";
+
+ /**
+ * @since 3.3.0
+ */
+ public static final String AJAX_PROCESS_ATTRIBUTE = "process";
+ public static final String AJAX_QUEUE_ATTR = "eventsQueue";
+ public static final String AJAX_REGIONS_ATTRIBUTE = "reRender";
+ public static final String AJAX_SINGLE_ATTR = "ajaxSingle";
+ public static final String AJAX_SINGLE_PARAMETER_NAME = "ajaxSingle";
+ public static final String ALL = "@all";
+ public static final String FORM = "@form";
+ public static final String THIS = "@this";
+ public static final String REGION = "@region";
+ public static final String NONE = "@none";
+
+ public static final Set<String> GLOBAL_META_COMPONENTS;
+
+ static {
+ GLOBAL_META_COMPONENTS = new HashSet<String>(2);
+
+ GLOBAL_META_COMPONENTS.add(ALL);
+ GLOBAL_META_COMPONENTS.add(NONE);
+ }
+
+ /**
+ * Attribute to keep
+ */
+ public static final String LIMITRENDER_ATTR_NAME = "limitRender";
+
+ /**
+ * Attribute for keep JavaScript function name for call before updating
+ * DOM tree.
+ */
+ public static final String ONBEFOREDOMUPDATE_ATTR_NAME = "onbeforedomupdate";
+ public static final String ONBEGIN_ATTR_NAME = "onbegin";
+
+ /**
+ * 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 for keep JavaScript function name for call after complete
+ * request.
+ */
+ public static final String ONCOMPLETE_CONTENT_ID = "org.ajax4jsf.oncomplete";
+ public static final String SIMILARITY_GROUPING_ID_ATTR = "similarityGroupingId";
+
+ /**
+ * Attribute for keep clientId of status component
+ */
+ public static final String STATUS_ATTR_NAME = "status";
+ public static final String VALUE_ATTR = "value";
+
+ public static final String EXTENSION_ID = "org.richfaces.extension";
+ public static final String AJAX_COMPONENT_ID_PARAMETER = "org.richfaces.ajax.component";
+ public static final String BEHAVIOR_EVENT_PARAMETER = "javax.faces.behavior.event";
+
+ public static final String QUEUE_ID_ATTRIBUTE = "queueId";
+
+ 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 RendererUtils RENDERER_UTILS = RendererUtils.getInstance();
+ private static final Class<?> OBJECT_ARRAY_CLASS = new Object[0].getClass();
+ private static final Logger LOG = RichfacesLogger.RENDERKIT.getLogger();
+
+ /**
+ * Static class - protect constructor
+ */
+ private AjaxRendererUtils() {
+ }
+
+ private static enum BehaviorEventOptionsData {
+ begin {
+ @Override
+ public String getAttributeValue(AjaxClientBehavior behavior) {
+ return behavior.getOnbegin();
+ }
+ },
+ error {
+ @Override
+ public String getAttributeValue(AjaxClientBehavior behavior) {
+ return behavior.getOnerror();
+ }
+ },
+ queueId {
+ @Override
+ public String getAttributeValue(AjaxClientBehavior behavior) {
+ return behavior.getQueueId();
+ }
+ },
+ event {
+ @Override
+ public String getAttributeValue(AjaxClientBehavior behavior) {
+ return behavior.getOnevent();
+ }
+ };
+
+ public abstract String getAttributeValue(AjaxClientBehavior behavior);
+ }
+
+ /**
+ * Build JavaScript onclick event for given component
+ *
+ * @param uiComponent -
+ * component for build event
+ * @param facesContext
+ * @return <code>StringBuffer</code> with Javascript code
+ */
+ public static StringBuffer buildOnClick(UIComponent uiComponent, FacesContext facesContext) {
+ return buildOnClick(uiComponent, facesContext, false);
+ }
+
+ /**
+ * Build JavaScript onclick event for given component
+ *
+ * @param uiComponent -
+ * component for build event
+ * @param facesContext
+ * @param omitDefaultActionUrl - default action URL is not encoded if parameter is true
+ * @return <code>StringBuffer</code> with Javascript code
+ */
+ public static StringBuffer buildOnClick(UIComponent uiComponent, FacesContext facesContext,
+ boolean omitDefaultActionUrl) {
+ return buildOnEvent(uiComponent, facesContext, HTML.ONCLICK_ATTRIBUTE, omitDefaultActionUrl);
+ }
+
+ /**
+ * Build JavaScript event for component
+ *
+ * @param uiComponent -
+ * component for build event
+ * @param facesContext
+ * @param eventName -
+ * name of event
+ * @return <code>StringBuffer</code> with Javascript code
+ */
+ public static StringBuffer buildOnEvent(UIComponent uiComponent, FacesContext facesContext, String eventName) {
+ return buildOnEvent(uiComponent, facesContext, eventName, false);
+ }
+
+ /**
+ * Build JavaScript event for component
+ *
+ * @param uiComponent -
+ * component for build event
+ * @param facesContext
+ * @param eventName -
+ * name of event
+ * @param omitDefaultActionUrl - default action URL is not encoded if parameter is true
+ * @return <code>StringBuffer</code> with Javascript code
+ */
+ public static StringBuffer buildOnEvent(UIComponent uiComponent, FacesContext facesContext, String eventName,
+ boolean omitDefaultActionUrl) {
+ StringBuffer onEvent = new StringBuffer();
+
+// if (null != eventName) {
+// String commandOnEvent = (String) uiComponent.getAttributes().get(
+// eventName);
+// if (commandOnEvent != null) {
+// onEvent.append(commandOnEvent);
+// onEvent.append(';');
+// }
+// }
+// JSFunction ajaxFunction = buildAjaxFunction(uiComponent, facesContext);
+// // Create formal parameter for non-input elements ???
+// // Link Control pseudo-object
+// // Options map. Possible options for function call :
+// // control - name of form control for submit.
+// // name - name for link control \
+// // value - value of control. - possible replace by parameters ?
+// // single true/false - submit all form or only one control.
+// // affected - array of element's ID for update on responce.
+// // oncomplete - function for call after complete request.
+// // status - id of request status component.
+// // parameters - map of parameters name/value for append on request.
+// // ..........
+// ajaxFunction.addParameter(buildEventOptions(facesContext, uiComponent, omitDefaultActionUrl));
+//
+// // appendAjaxSubmitParameters(facesContext, uiComponent, onEvent);
+// ajaxFunction.appendScript(onEvent);
+// if (uiComponent instanceof AjaxSupport) {
+// AjaxSupport support = (AjaxSupport) uiComponent;
+// if (support.isDisableDefault()) {
+// onEvent.append("; return false;");
+// }
+// }
+// LOG.debug(Messages.getMessage(Messages.BUILD_ONCLICK_INFO, uiComponent
+// .getId(), onEvent.toString()));
+ return onEvent;
+ }
+
+ public static AjaxEventOptions buildEventOptions(FacesContext facesContext, UIComponent component) {
+ return buildEventOptions(facesContext, component, null);
+ }
+
+ public static AjaxEventOptions buildEventOptions(FacesContext facesContext, UIComponent component,
+ AjaxClientBehavior ajaxBehavior) {
+ AjaxEventOptions ajaxEventOptions = new AjaxEventOptions();
+ Map<String, Object> parametersMap = RENDERER_UTILS.createParametersMap(facesContext, component);
+ String ajaxStatusName = getAjaxStatus(component);
+
+ if (ajaxBehavior != null) {
+ ajaxStatusName = (ajaxBehavior.getStatus() != null) ? ajaxBehavior.getStatus() : ajaxStatusName;
+ appenAjaxBehaviorOptions(ajaxBehavior, ajaxEventOptions);
+ } else {
+ appendComponentOptions(facesContext, component, ajaxEventOptions);
+ }
+
+ if ((ajaxStatusName != null) && (ajaxStatusName.length() != 0)) {
+ ajaxEventOptions.set(STATUS_ATTR_NAME, ajaxStatusName);
+ }
+
+ if (!parametersMap.isEmpty()) {
+ ajaxEventOptions.getParameters().putAll(parametersMap);
+ }
+
+ return ajaxEventOptions;
+ }
+
+ private static boolean isNotEmpty(String value) {
+ return (value != null) && (value.length() != 0);
+ }
+
+ private static void appenAjaxBehaviorOptions(AjaxClientBehavior behavior, AjaxEventOptions ajaxEventOptions) {
+ for (BehaviorEventOptionsData optionsData : BehaviorEventOptionsData.values()) {
+ String eventHandlerValue = optionsData.getAttributeValue(behavior);
+
+ if (isNotEmpty(eventHandlerValue)) {
+ ajaxEventOptions.set(optionsData.toString(), eventHandlerValue);
+ }
+ }
+ }
+
+ private static void appendComponentOptions(FacesContext facesContext, UIComponent component,
+ AjaxEventOptions ajaxEventOptions) {
+ String behaviorName = "begin";
+ HandlersChain handlersChain = new HandlersChain(facesContext, component);
+ String inlineHandler = getAjaxOnBegin(component);
+
+ handlersChain.addInlineHandlerAsValue(inlineHandler);
+ handlersChain.addBehaviors(behaviorName);
+
+ String handlerScript = handlersChain.toScript();
+
+ if (isNotEmpty(handlerScript)) {
+ ajaxEventOptions.set(behaviorName, handlerScript);
+ }
+
+ String queueId = getQueueId(component);
+ if (isNotEmpty(queueId)) {
+ ajaxEventOptions.set(QUEUE_ID_ATTRIBUTE, queueId);
+ }
+
+ ajaxEventOptions.set("incId", "1");
+ }
+
+// public static AjaxEventOptions buildEventOptions(FacesContext facesContext,
+// UIComponent uiComponent, Map<String, Object> params) {
+//
+// return buildEventOptions(facesContext, uiComponent, params, false);
+// }
+
+ /**
+ * @param facesContext
+ * @param uiComponent
+ * @return
+ */
+// public static Map<String, Object> buildEventOptions(FacesContext facesContext,
+// UIComponent uiComponent, Map<String, Object> params, boolean omitDefaultActionUrl) {
+// String clientId = uiComponent.getClientId(facesContext);
+// Map<String, Object> componentAttributes = uiComponent.getAttributes();
+// Map<String, Object> options = new HashMap<String, Object>();
+//
+// UIComponent nestingContainer = (UIComponent) findAjaxContainer(
+// facesContext, uiComponent);
+// String containerClientId = nestingContainer.getClientId(facesContext);
+// if (containerClientId != null && !AjaxViewRoot.ROOT_ID.equals(containerClientId)) {
+// options.put("containerId", containerClientId);
+// }
+//
+// Map<String, Object> parameters = new HashMap<String, Object>();
+// UIComponent targetComponent = (uiComponent instanceof AjaxSupport)?uiComponent.getParent():uiComponent;
+// // UIForm form = getNestingForm(uiComponent);
+// // "input" - if assigned to html input element.
+// boolean input = targetComponent instanceof EditableValueHolder;
+// // Action component - button etc.
+//// boolean action = targetComponent instanceof ActionSource;
+//
+// boolean ajaxSingle = Boolean.TRUE.equals(componentAttributes
+// .get(AJAX_SINGLE_ATTR));
+// // For input components in single mode or without form submit input
+// // control )
+// if (ajaxSingle ) {
+// parameters.put(AJAX_SINGLE_PARAMETER_NAME, targetComponent.getClientId(facesContext));
+// // options.put("single", JSReference.TRUE);
+// if (input) {
+// options.put("control", JSReference.THIS);
+// }
+// }
+// // Control value for submit
+// String controlName;
+// Object controlValue;
+// // TODO - make compatible with JSF RI/MyFaces ? use submittedValue ( if
+// // any ) for UIInput, converted value for ValueHolder.
+// controlName = clientId;
+// controlValue = clientId;
+// parameters.put(controlName, controlValue);
+// AjaxContext ajaxContext = AjaxContext.getCurrentInstance(facesContext);
+//
+// String ajaxActionURL = ajaxContext.getAjaxActionURL(facesContext);
+// if (omitDefaultActionUrl) {
+// UIComponent form = getNestingForm(uiComponent);
+// if (form != null && !RENDERER_UTILS.isBooleanAttribute(form, "ajaxSubmit")) {
+// if (RENDERER_UTILS.getActionUrl(facesContext).equals(ajaxActionURL)) {
+// ajaxActionURL = null;
+// }
+// }
+// }
+//
+// if (ajaxActionURL != null) {
+// // Setup action URL. For portlet environment, it will be different from
+// // page.
+// options.put("actionUrl", ajaxActionURL);
+// }
+//
+// // Add application-wide Ajax parameters
+// parameters.putAll(ajaxContext.getCommonAjaxParameters());
+// // add child parameters
+// appendParameters(facesContext, uiComponent, parameters);
+//
+// if (params != null) {
+// parameters.putAll(params);
+// }
+//
+// if (!parameters.isEmpty()) {
+// options.put("parameters", parameters);
+// }
+// // parameter to render only current list of areas.
+//// if (isAjaxLimitToList(uiComponent)) {
+//// Set<? extends Object> ajaxAreas = getAjaxAreas(uiComponent);
+//// Set<String> areasIds = new HashSet<String>();
+//// if (null != ajaxAreas) {
+//// for (Iterator<? extends Object> iter = ajaxAreas.iterator(); iter.hasNext();) {
+//// String id = (String) iter.next();
+//// UIComponent comp = RendererUtils.getInstance().
+//// findComponentFor(uiComponent, id);
+//// if (null != comp) {
+//// areasIds.add(comp.getClientId(facesContext));
+//// } else {
+//// areasIds.add(id);
+//// }
+//// }
+//// }
+//// options.put("affected", areasIds);
+//// }
+// String oncomplete = getAjaxOncomplete(uiComponent);
+// if (null != oncomplete) {
+// options.put(ONCOMPLETE_ATTR_NAME, buildAjaxOncomplete(oncomplete));
+// }
+//
+// String beforeupdate = getAjaxOnBeforeDomUpdate(uiComponent);
+// if (null != beforeupdate) {
+// options.put(ONBEFOREDOMUPDATE_ATTR_NAME, buildAjaxOnBeforeDomUpdate(beforeupdate));
+// }
+//
+//
+// String status = getAjaxStatus(uiComponent);
+// if (null != status) {
+// options.put("status", status);
+// }
+// String queue = (String) componentAttributes.get(AJAX_QUEUE_ATTR);
+// String implicitQueue = null;
+//
+// Integer requestDelay = (Integer) componentAttributes
+// .get(AJAX_DELAY_ATTR);
+// if (null != requestDelay && requestDelay.intValue() > 0) {
+// options.put(AJAX_DELAY_ATTR, requestDelay);
+// if (null == queue) {
+// implicitQueue = clientId;
+// }
+// }
+// Boolean ignoreDupResponses = (Boolean) componentAttributes
+// .get(AJAX_ABORT_ATTR);
+// if (null != ignoreDupResponses && ignoreDupResponses.booleanValue()) {
+// options.put(AJAX_ABORT_ATTR, JSReference.TRUE);
+// if (null == queue) {
+// implicitQueue = clientId;
+// }
+// }
+//
+// if (null != queue) {
+// options.put(AJAX_QUEUE_ATTR, queue);
+// } else if (implicitQueue != null) {
+// options.put("implicitEventsQueue", clientId);
+// }
+//
+// ExternalContext externalContext = facesContext.getExternalContext();
+// String namespace = externalContext.encodeNamespace("");
+// if (namespace != null && namespace.length() != 0) {
+// options.put("namespace", namespace);
+// }
+//
+// String similarityGroupingId = (String) componentAttributes.get(SIMILARITY_GROUPING_ID_ATTR);
+// if (similarityGroupingId == null || similarityGroupingId.length() == 0) {
+// similarityGroupingId = clientId;
+// } else {
+// similarityGroupingId = externalContext.encodeNamespace(similarityGroupingId);
+// }
+//
+// options.put(SIMILARITY_GROUPING_ID_ATTR, similarityGroupingId);
+//
+// // request timeout.
+// Integer timeout = (Integer) componentAttributes.get("timeout");
+// if (null != timeout && timeout.intValue() > 0) {
+// options.put("timeout", timeout);
+// }
+// // Encoding for requests
+// String encoding = (String) componentAttributes.get("encoding");
+// if (null != encoding) {
+// options.put("encoding", encoding);
+// }
+// return options;
+// }
+// /**
+// * Create call to Ajax Submit function with first two parameters
+// *
+// * @param uiComponent
+// * @param facesContext
+// * @param functionName
+// * @return
+// */
+// public static JSFunction buildAjaxFunction(UIComponent uiComponent,
+// FacesContext facesContext) {
+// JSFunction ajaxFunction = buildAjaxFunction(uiComponent, facesContext,
+// AJAX_FUNCTION_NAME);
+// // client-side script must have reference to event-enabled object.
+// ajaxFunction.addParameter(new JSReference("event"));
+// return ajaxFunction;
+// }
+
+ /**
+ * Create call to Ajax Submit function with first two parameters
+ *
+ * @param facesContext
+ * @param uiComponent
+ * @param functionName
+ * @return
+ */
+ public static JSFunction buildAjaxFunction(FacesContext facesContext, UIComponent uiComponent,
+ String functionName) {
+ JSFunction ajaxFunction = new JSFunction(functionName);
+
+ ajaxFunction.addParameter(uiComponent.getClientId(facesContext));
+ ajaxFunction.addParameter(JSReference.EVENT);
+
+ return ajaxFunction;
+ }
+
+ /**
+ * Append common parameters ( array of affected areas, status area id, on
+ * complete function ) to JavaScript event string.
+ *
+ * @param uiComponent
+ * @param onClick -
+ * buffer with JavaScript code eg... AJAX.Submit(form,this
+ */
+
+ // public static void appendAjaxSubmitParameters(FacesContext facesContext,
+ // UIComponent uiComponent, StringBuffer onClick)
+ // {
+ // Set ajaxAreas = getAjaxAreas(uiComponent);
+ // onClick.append(',');
+ // // parameter to render only current list of areas.
+ // if (isAjaxLimitToList(uiComponent) && ajaxAreas != null &&
+ // ajaxAreas.size() > 0)
+ // {
+ // onClick.append('[');
+ // Iterator areas = ajaxAreas.iterator();
+ // boolean first = true;
+ // while (areas.hasNext())
+ // {
+ // String element = (String) areas.next();
+ // UIComponent component = uiComponent.findComponent(element);
+ // if (null != component)
+ // {
+ // if (!first)
+ // {
+ // onClick.append(',');
+ // }
+ // else
+ // {
+ // first = false;
+ // }
+ // onClick.append('\'');
+ // onClick.append(component.getClientId(facesContext));
+ // onClick.append('\'');
+ // }
+ // }
+ // onClick.append("]");
+ // }
+ // else
+ // {
+ // onClick.append("null");
+ // }
+ // // insert id of request status element.
+ // onClick.append(',');
+ // String status = getAjaxStatus(uiComponent);
+ // if (null != status)
+ // {
+ // onClick.append('\'').append(status).append('\'');
+ // }
+ // else
+ // {
+ // onClick.append("null");
+ // }
+ // // insert function name for call after completed request
+ // onClick.append(',');
+ // String oncomplete = getAjaxOncomplete(uiComponent);
+ // if (null != oncomplete)
+ // {
+ // onClick.append(oncomplete);
+ // }
+ // else
+ // {
+ // onClick.append("null");
+ // }
+ //
+ // }
+
+ /**
+ * Get list of clientId's for given component
+ *
+ * @param uiComponent
+ * @return List of areas Id's , updated by this component.
+ */
+ public static Set<String> getAjaxAreas(UIComponent uiComponent) {
+ Object areas;
+
+ if (uiComponent instanceof AjaxComponent) {
+ areas = ((AjaxComponent) uiComponent).getReRender();
+ } else {
+ areas = uiComponent.getAttributes().get(AjaxRendererUtils.AJAX_REGIONS_ATTRIBUTE);
+ }
+
+ return asSet(areas);
+ }
+
+ /**
+ * Returns set of areas to be processed as a result of this component action invocation
+ *
+ * @param component
+ * @return set of IDs that should be processed as a
+ * @since 3.3.0
+ */
+ public static Set<String> getAjaxAreasToProcess(UIComponent component) {
+ Object areas;
+
+ if (component instanceof AjaxComponent) {
+ areas = ((AjaxComponent) component).getProcess();
+ } else {
+ areas = component.getAttributes().get(AjaxRendererUtils.AJAX_PROCESS_ATTRIBUTE);
+ }
+
+ return asSet(areas);
+ }
+
+ /**
+ * Split parameter string into array of strings.
+ * @param valuesSet
+ * @return
+ */
+ public static String[] asArray(String valuesSet) {
+ return IdSplitBuilder.split(valuesSet);
+ }
+
+ /**
+ * Convert parameter ( Collection, List, array, String, comma-separated
+ * String, whitespace-separate String) to set of strings.
+ *
+ * @param valueToSet -
+ * object for conversion to Set.
+ * @return - set of strings.
+ */
+ @SuppressWarnings("unchecked")
+ public static Set<String> asSet(Object valueToSet) {
+ 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_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 = asArray(areasString);
+ Set<String> result = new LinkedHashSet<String>(values.length);
+ for (String value : values) {
+ result.add(value);
+ }
+
+ return result;
+ } else {
+ Set<String> areasSet = new LinkedHashSet<String>(5);
+
+ areasSet.add(areasString);
+
+ return areasSet;
+ }
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * Get status area Id for given component.
+ *
+ * @param component
+ * @return clientId of status area, or <code>null</code>
+ */
+ public static String getAjaxStatus(UIComponent component) {
+ String statusId;
+
+ if (component instanceof AjaxComponent) {
+ statusId = ((AjaxComponent) component).getStatus();
+ } else {
+ statusId = (String) component.getAttributes().get(STATUS_ATTR_NAME);
+ }
+
+ return statusId;
+
+// if (null != statusId) {
+// UIComponent status = RendererUtils.getInstance().
+// findComponentFor(component, statusId);
+//
+// if (null != status) {
+// statusId = status
+// .getClientId(FacesContext.getCurrentInstance());
+// } else {
+// LOG.warn(Messages.getMessage(
+// Messages.AJAX_STATUS_COMPONENT_NOT_FOWND_WARNING,
+// component.getId()));
+// }
+// }
+// return statusId;
+ }
+
+ public static String getQueueId(UIComponent component) {
+ return (String) component.getAttributes().get(QUEUE_ID_ATTRIBUTE);
+ }
+
+ public static JSFunctionDefinition buildAjaxOncomplete(String body) {
+ JSFunctionDefinition function = new JSFunctionDefinition("request", "event", "data");
+
+ function.addToBody(body);
+
+ return function;
+ }
+
+ public static JSFunctionDefinition buildAjaxOnBeforeDomUpdate(String body) {
+ JSFunctionDefinition function = new JSFunctionDefinition("request", "event", "data");
+
+ function.addToBody(body);
+
+ return function;
+ }
+
+ /**
+ * Get function name for call on completed ajax request.
+ *
+ * @param component for wich calculate function name
+ * @return name of JavaScript function or <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);
+ }
+
+ //TODO nick - refactor - remove this method?
+ public static String getAjaxOnBegin(UIComponent component) {
+ if (component instanceof AjaxComponent) {
+ return ((AjaxComponent) component).getOnbegin();
+ }
+
+ return (String) component.getAttributes().get(ONBEGIN_ATTR_NAME);
+ }
+
+ /**
+ * @param component
+ * @return
+ * @since 4.0
+ */
+ public static Object getAjaxData(UIComponent component) {
+ if (component instanceof AjaxComponent) {
+ return ((AjaxComponent) component).getData();
+ }
+
+ return component.getAttributes().get(DATA_ATTR_NAME);
+ }
+
+ /**
+ * Calculate, must be component render only given areas, or all sended from
+ * server.
+ *
+ * @param component
+ * @return <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;
+ }
+
+ /**
+ * Replacement for buggy in MyFaces <code>RendererUtils</code>
+ *
+ * @param component
+ * @return
+ */
+ public static String getAbsoluteId(UIComponent component) {
+ if (component == null) {
+ throw new NullPointerException(Messages.getMessage(Messages.COMPONENT_NULL_ERROR_2));
+ }
+
+ StringBuffer idBuf = new StringBuffer();
+
+ idBuf.append(component.getId());
+
+ UIComponent parent = component;
+
+ while ((parent = parent.getParent()) != null) {
+ if (parent instanceof NamingContainer) {
+ idBuf.insert(0, NamingContainer.SEPARATOR_CHAR);
+ idBuf.insert(0, parent.getId());
+ }
+ }
+
+ idBuf.insert(0, NamingContainer.SEPARATOR_CHAR);
+ LOG.debug(Messages.getMessage(Messages.CALCULATE_COMPONENT_ID_INFO, component.getId(), idBuf.toString()));
+
+ return idBuf.toString();
+ }
+
+ /**
+ * Find nested form for given component
+ *
+ * @param component
+ * @return nested <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");
+// }
+
+ /**
+ * Write state saving markers to context, include MyFaces view sequence.
+ *
+ * @param context
+ * @throws IOException
+ */
+ public static void writeState(FacesContext context) throws IOException {
+ context.getApplication().getViewHandler().writeState(context);
+ }
+
+// /**
+// * Encode declaration for AJAX response. Render <html><body>
+// *
+// * @param context
+// * @param component
+// * @throws IOException
+// */
+// public static void encodeAjaxBegin(FacesContext context, UIComponent component) throws IOException {
+//
+// // AjaxContainer ajax = (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
+ */
+ public static boolean isAjaxRequest(FacesContext facesContext) {
+ return AjaxContext.getCurrentInstance(facesContext).isAjaxRequest();
+ }
+
+ /**
+ * TODO: add deprecation
+ *
+ * @param facesContext
+ * @param component
+ * @param id
+ */
+ public static void addRegionByName(FacesContext facesContext, UIComponent component, String id) {
+ AjaxContext.getCurrentInstance(facesContext).addComponentToAjaxRender(component, id);
+ }
+
+ /**
+ * @param facesContext
+ * @param component
+ */
+ public static void addRegionsFromComponent(UIComponent component, FacesContext facesContext) {
+ AjaxContext.getCurrentInstance(facesContext).addRegionsFromComponent(component);
+ }
+
+ 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(HTML.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);
+
+ }
+
+}
Copied: branches/RF-7560/core/impl/src/main/java/org/richfaces/renderkit/util/IdSplitBuilder.java (from rev 19052, branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/renderkit/IdSplitBuilder.java)
===================================================================
--- branches/RF-7560/core/impl/src/main/java/org/richfaces/renderkit/util/IdSplitBuilder.java (rev 0)
+++ branches/RF-7560/core/impl/src/main/java/org/richfaces/renderkit/util/IdSplitBuilder.java 2010-08-31 18:46:44 UTC (rev 19054)
@@ -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/impl/src/main/java/org/richfaces/renderkit/util/RendererUtils.java (from rev 19052, branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/renderkit/RendererUtils.java)
===================================================================
--- branches/RF-7560/core/impl/src/main/java/org/richfaces/renderkit/util/RendererUtils.java (rev 0)
+++ branches/RF-7560/core/impl/src/main/java/org/richfaces/renderkit/util/RendererUtils.java 2010-08-31 18:46:44 UTC (rev 19054)
@@ -0,0 +1,1314 @@
+/**
+ * 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.lang.reflect.Array;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
+import java.util.Map;
+import java.util.Set;
+
+import javax.faces.FacesException;
+import javax.faces.application.ViewHandler;
+import javax.faces.component.EditableValueHolder;
+import javax.faces.component.NamingContainer;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIForm;
+import javax.faces.component.UIParameter;
+import javax.faces.component.UIViewRoot;
+import javax.faces.component.ValueHolder;
+import javax.faces.component.behavior.ClientBehaviorContext.Parameter;
+import javax.faces.component.behavior.ClientBehaviorHolder;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+import javax.faces.convert.Converter;
+
+import org.ajax4jsf.Messages;
+import org.ajax4jsf.component.JavaScriptParameter;
+import org.ajax4jsf.javascript.JSEncoder;
+import org.ajax4jsf.javascript.JSFunctionDefinition;
+import org.ajax4jsf.javascript.JSReference;
+import org.ajax4jsf.util.HtmlDimensions;
+import org.richfaces.context.ComponentIdResolver;
+import org.richfaces.renderkit.HandlersChain;
+
+/**
+ * Util class for common render operations - render passthru html attributes,
+ * iterate over child components etc.
+ *
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.6 $ $Date: 2007/02/08 19:07:16 $
+ *
+ */
+public class RendererUtils {
+
+ public static final String DUMMY_FORM_ID = ":_form";
+
+ // we'd better use this instance multithreadly quickly
+ private static final RendererUtils INSTANCE = new RendererUtils();
+
+ /**
+ * Substitutions for components properies names and HTML attributes names.
+ */
+ private static final Map<String, String> SUBSTITUTIONS = new HashMap<String, String>();
+
+ private static final Set<String> REQUIRED_ATTRIBUTES = new HashSet<String>();
+
+ static {
+ SUBSTITUTIONS.put(HTML.CLASS_ATTRIBUTE, "styleClass");
+
+ REQUIRED_ATTRIBUTES.add(HTML.ALT_ATTRIBUTE);
+
+ Arrays.sort(HTML.PASS_THRU);
+ Arrays.sort(HTML.PASS_THRU_EVENTS);
+ Arrays.sort(HTML.PASS_THRU_BOOLEAN);
+ Arrays.sort(HTML.PASS_THRU_URI);
+ }
+
+ // can be created by subclasses;
+ // administratively restricted to be created by package members ;)
+ protected RendererUtils() {
+ super();
+ }
+
+ /**
+ * Wrapper class around object value used to transform values into particular JS objects
+ *
+ * @author Nick Belaevski
+ * @since 3.3.2
+ */
+ public static enum ScriptHashVariableWrapper {
+
+ /**
+ * No-op default wrapper
+ */
+ DEFAULT {
+ @Override
+ Object wrap(Object o) {
+ return o;
+ }
+ },
+
+ /**
+ * Event handler functions wrapper. Wraps <pre>functionCode</pre> object into:
+ * <pre>function(event) {
+ * functionCode
+ * }</pre>
+ */
+ EVENT_HANDLER {
+ @Override
+ Object wrap(Object o) {
+ return new JSFunctionDefinition("event").addToBody(o);
+ }
+ };
+
+ /**
+ * Method that does the wrapping
+ *
+ * @param o object to wrap
+ * @return wrapped object
+ */
+ abstract Object wrap(Object o);
+ }
+
+ /**
+ * Use this method to get singleton instance of RendererUtils
+ * @return singleton instance
+ */
+ public static RendererUtils getInstance() {
+ return INSTANCE;
+ }
+
+ /**
+ * Encode id attribute with clientId component property
+ *
+ * @param context
+ * @param component
+ * @throws IOException
+ */
+ public void encodeId(FacesContext context, UIComponent component) throws IOException {
+ encodeId(context, component, HTML.ID_ATTRIBUTE);
+ }
+
+ /**
+ * Encode clientId to custom attribute ( for example, to control name )
+ *
+ * @param context
+ * @param component
+ * @param attribute
+ * @throws IOException
+ */
+ public void encodeId(FacesContext context, UIComponent component, String attribute) throws IOException {
+ String clientId = null;
+
+ try {
+ clientId = component.getClientId(context);
+ } catch (Exception e) {
+
+ // just ignore if clientId wasn't inited yet
+ }
+
+ if (null != clientId) {
+ context.getResponseWriter().writeAttribute(attribute, clientId,
+ (String) getComponentAttributeName(attribute));
+ }
+ }
+
+ /**
+ * Encode id attribute with clientId component property. Encoded only if id
+ * not auto generated.
+ *
+ * @param context
+ * @param component
+ * @throws IOException
+ */
+ public void encodeCustomId(FacesContext context, UIComponent component) throws IOException {
+ if (hasExplicitId(component)) {
+ context.getResponseWriter().writeAttribute(HTML.ID_ATTRIBUTE, component.getClientId(context),
+ HTML.ID_ATTRIBUTE);
+ }
+ }
+
+ public Map<String, Object> createParametersMap(FacesContext context, UIComponent component) {
+ Map<String, Object> parameters = new LinkedHashMap<String, Object>();
+
+ if (component.getChildCount() > 0) {
+ for (UIComponent child : component.getChildren()) {
+ if (child instanceof UIParameter) {
+ UIParameter parameter = (UIParameter) child;
+ String name = parameter.getName();
+ Object value = parameter.getValue();
+
+ if (null == name) {
+ throw new IllegalArgumentException(Messages.getMessage(Messages.UNNAMED_PARAMETER_ERROR,
+ component.getClientId(context)));
+ }
+
+ boolean escape = true;
+
+ if (child instanceof JavaScriptParameter) {
+ JavaScriptParameter actionParam = (JavaScriptParameter) child;
+
+ escape = !actionParam.isNoEscape();
+ }
+
+ if (escape) {
+ if (value == null) {
+ value = "";
+ }
+ } else {
+ value = new JSReference(value.toString());
+
+ // if(it.hasNext()){onEvent.append(',');};
+ // renderAjaxLinkParameter( name,
+ // value, onClick, jsForm, nestingForm);
+ }
+
+ parameters.put(name, value);
+ }
+ }
+ }
+
+ return parameters;
+ }
+
+ private void encodeBehaviors(FacesContext context, ClientBehaviorHolder behaviorHolder,
+ String defaultHtmlEventName, String[] attributesExclusions)
+ throws IOException {
+
+// if (attributesExclusions != null && attributesExclusions.length != 0) {
+// assert false : "Not supported yet";
+// }
+ // TODO: disabled component check
+ String defaultEventName = behaviorHolder.getDefaultEventName();
+ Collection<String> eventNames = behaviorHolder.getEventNames();
+
+ if (eventNames != null) {
+ UIComponent component = (UIComponent) behaviorHolder;
+ ResponseWriter writer = context.getResponseWriter();
+ Collection<Parameter> parametersList = HandlersChain.createParametersList(createParametersMap(context,
+ component));
+
+ for (String behaviorEventName : eventNames) {
+ if (behaviorEventName.equals(defaultEventName)) {
+ continue;
+ }
+
+ String htmlEventName = "on" + behaviorEventName;
+
+ if ((attributesExclusions == null) || (Arrays.binarySearch(attributesExclusions, htmlEventName) < 0)) {
+ HandlersChain handlersChain = new HandlersChain(context, component, parametersList);
+
+ handlersChain.addInlineHandlerFromAttribute(htmlEventName);
+ handlersChain.addBehaviors(behaviorEventName);
+
+ String handlerScript = handlersChain.toScript();
+
+ if (!isEmpty(handlerScript)) {
+ writer.writeAttribute(htmlEventName, handlerScript, htmlEventName);
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Encode common pass-thru html attributes.
+ *
+ * @param context
+ * @param component
+ * @throws IOException
+ */
+ public void encodePassThru(FacesContext context, UIComponent component, String defaultHtmlEvent)
+ throws IOException {
+
+ encodeAttributesFromArray(context, component, HTML.PASS_THRU);
+
+ if (component instanceof ClientBehaviorHolder) {
+ ClientBehaviorHolder clientBehaviorHolder = (ClientBehaviorHolder) component;
+
+ encodeBehaviors(context, clientBehaviorHolder, defaultHtmlEvent, null);
+ } else {
+ encodeAttributesFromArray(context, component, HTML.PASS_THRU_EVENTS);
+ }
+ }
+
+ /**
+ * Encode pass-through attributes except specified ones
+ *
+ * @param context
+ * @param component
+ * @param exclusions
+ * @throws IOException
+ */
+ public void encodePassThruWithExclusions(FacesContext context, UIComponent component, String exclusions,
+ String defaultHtmlEvent) throws IOException {
+
+ if (null != exclusions) {
+ String[] exclusionsArray = exclusions.split(",");
+
+ encodePassThruWithExclusionsArray(context, component, exclusionsArray, defaultHtmlEvent);
+ }
+ }
+
+ public void encodePassThruWithExclusionsArray(FacesContext context, UIComponent component, String[] exclusions,
+ String defaultHtmlEvent) throws IOException {
+
+ ResponseWriter writer = context.getResponseWriter();
+ Map<String, Object> attributes = component.getAttributes();
+
+ Arrays.sort(exclusions);
+
+ for (int i = 0; i < HTML.PASS_THRU.length; i++) {
+ String attribute = HTML.PASS_THRU[i];
+
+ if (Arrays.binarySearch(exclusions, attribute) < 0) {
+ encodePassThruAttribute(context, attributes, writer, attribute);
+ }
+ }
+
+ if (component instanceof ClientBehaviorHolder) {
+ ClientBehaviorHolder clientBehaviorHolder = (ClientBehaviorHolder) component;
+
+ encodeBehaviors(context, clientBehaviorHolder, defaultHtmlEvent, exclusions);
+ } else {
+ for (int i = 0; i < HTML.PASS_THRU_EVENTS.length; i++) {
+ String attribute = HTML.PASS_THRU_EVENTS[i];
+
+ if (Arrays.binarySearch(exclusions, attribute) < 0) {
+ encodePassThruAttribute(context, attributes, writer, attribute);
+ }
+ }
+ }
+ }
+
+ /**
+ * Encode one pass-thru attribute, with plain/boolean/url value, got from
+ * properly component attribute.
+ *
+ * @param context
+ * @param writer
+ * @param attribute
+ * @throws IOException
+ */
+ public void encodePassThruAttribute(FacesContext context, Map<String, Object> attributes, ResponseWriter writer,
+ String attribute) throws IOException {
+
+ Object value = attributeValue(attribute, attributes.get(getComponentAttributeName(attribute)));
+
+ if ((null != value) && shouldRenderAttribute(attribute, value)) {
+ if (Arrays.binarySearch(HTML.PASS_THRU_URI, attribute) >= 0) {
+ String url = context.getApplication().getViewHandler().getResourceURL(context, value.toString());
+
+ url = context.getExternalContext().encodeResourceURL(url);
+ writer.writeURIAttribute(attribute, url, attribute);
+ } else {
+ writer.writeAttribute(attribute, value, attribute);
+ }
+ }
+ }
+
+ public void encodeAttributesFromArray(FacesContext context, UIComponent component, String[] attrs)
+ throws IOException {
+
+ ResponseWriter writer = context.getResponseWriter();
+ Map<String, Object> attributes = component.getAttributes();
+
+ for (int i = 0; i < attrs.length; i++) {
+ String attribute = attrs[i];
+
+ encodePassThruAttribute(context, attributes, writer, attribute);
+ }
+ }
+
+ /**
+ * Encode attributes given by comma-separated string list.
+ *
+ * @param context
+ * current JSF context
+ * @param component
+ * for with render attributes values
+ * @param attrs
+ * comma separated list of attributes
+ * @throws IOException
+ */
+ public void encodeAttributes(FacesContext context, UIComponent component, String attrs) throws IOException {
+ if (null != attrs) {
+ String[] attrsArray = attrs.split(",");
+
+ encodeAttributesFromArray(context, component, attrsArray);
+ }
+ }
+
+ /**
+ * @param context
+ * @param component
+ * @param property
+ * @param attributeName
+ *
+ * @throws IOException
+ */
+ public void encodeAttribute(FacesContext context, UIComponent component, Object property, String attributeName)
+ throws IOException {
+
+ ResponseWriter writer = context.getResponseWriter();
+ Object value = component.getAttributes().get(property);
+
+ if (shouldRenderAttribute(attributeName, value)) {
+ writer.writeAttribute(attributeName, value, property.toString());
+ }
+ }
+
+ public void encodeAttribute(FacesContext context, UIComponent component, String attribute) throws IOException {
+ encodeAttribute(context, component, getComponentAttributeName(attribute), attribute);
+ }
+
+ /**
+ * Write html-attribute
+ *
+ * @param writer
+ * @param attribute
+ * @param value
+ * @throws IOException
+ */
+ public void writeAttribute(ResponseWriter writer, String attribute, Object value) throws IOException {
+ if (shouldRenderAttribute(attribute, value)) {
+ writer.writeAttribute(attribute, value.toString(), attribute);
+ }
+ }
+
+ /**
+ * @return true if and only if the argument <code>attributeVal</code> is
+ * an instance of a wrapper for a primitive type and its value is
+ * equal to the default value for that type as given in the spec.
+ */
+ public boolean shouldRenderAttribute(Object attributeVal) {
+ if (null == attributeVal) {
+ return false;
+ } else if ((attributeVal instanceof Boolean)
+ && ((Boolean) attributeVal).booleanValue() == Boolean.FALSE.booleanValue()) {
+ return false;
+ } else if (attributeVal.toString().length() == 0) {
+ return false;
+ } else {
+ return isValidProperty(attributeVal);
+ }
+ }
+
+ public boolean shouldRenderAttribute(String attributeName, Object attributeVal) {
+ if (REQUIRED_ATTRIBUTES.contains(attributeName)) {
+ if (attributeVal == null) {
+ return false;
+ }
+ } else {
+ return shouldRenderAttribute(attributeVal);
+ }
+
+ return true;
+ }
+
+ /**
+ * Test for valid value of property. by default, for non-setted properties
+ * with Java primitive types of JSF component return appropriate MIN_VALUE .
+ *
+ * @param property -
+ * value of property returned from
+ * {@link UIComponent#getAttributes()}
+ * @return true for setted property, false otherthise.
+ */
+ public boolean isValidProperty(Object property) {
+ if (null == property) {
+ return false;
+ } else if ((property instanceof Integer) && ((Integer) property).intValue() == Integer.MIN_VALUE) {
+ return false;
+ } else if ((property instanceof Double) && ((Double) property).doubleValue() == Double.MIN_VALUE) {
+ return false;
+ } else if ((property instanceof Character) && ((Character) property).charValue() == Character.MIN_VALUE) {
+ return false;
+ } else if ((property instanceof Float) && ((Float) property).floatValue() == Float.MIN_VALUE) {
+ return false;
+ } else if ((property instanceof Short) && ((Short) property).shortValue() == Short.MIN_VALUE) {
+ return false;
+ } else if ((property instanceof Byte) && ((Byte) property).byteValue() == Byte.MIN_VALUE) {
+ return false;
+ } else if ((property instanceof Long) && ((Long) property).longValue() == Long.MIN_VALUE) {
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Checks if the argument passed in is empty or not.
+ * Object is empty if it is: <br />
+ * - <code>null</code><br />
+ * - zero-length string<br />
+ * - empty collection<br />
+ * - empty map<br />
+ * - zero-length array<br />
+ *
+ * @param o object to check for emptiness
+ * @since 3.3.2
+ * @return <code>true</code> if the argument is empty, <code>false</code> otherwise
+ */
+ public boolean isEmpty(Object o) {
+ if (null == o) {
+ return true;
+ }
+
+ if (o instanceof String) {
+ return 0 == ((String) o).length();
+ }
+
+ if (o instanceof Collection<?>) {
+ return ((Collection<?>) o).isEmpty();
+ }
+
+ if (o instanceof Map<?, ?>) {
+ return ((Map<?, ?>) o).isEmpty();
+ }
+
+ if (o.getClass().isArray()) {
+ return Array.getLength(o) == 0;
+ }
+
+ return false;
+ }
+
+ /**
+ * Puts value into map under specified key if the value is not empty and not default.
+ * Performs optional value wrapping.
+ *
+ * @param hash
+ * @param name
+ * @param value
+ * @param defaultValue
+ * @param wrapper
+ *
+ * @since 3.3.2
+ */
+ public void addToScriptHash(Map<String, Object> hash, String name, Object value, String defaultValue,
+ ScriptHashVariableWrapper wrapper) {
+ ScriptHashVariableWrapper wrapperOrDefault = (wrapper != null) ? wrapper : ScriptHashVariableWrapper.DEFAULT;
+
+ if (isValidProperty(value) && !isEmpty(value)) {
+ if (!isEmpty(defaultValue)) {
+ if (!defaultValue.equals(value.toString())) {
+ hash.put(name, wrapperOrDefault.wrap(value));
+ }
+ } else {
+ if (!(value instanceof Boolean) || ((Boolean) value).booleanValue()) {
+ hash.put(name, wrapperOrDefault.wrap(value));
+ }
+ }
+ }
+ }
+
+ /**
+ * Puts value into map under specified key if the value is not empty and not default.
+ * Performs optional value wrapping.
+ *
+ * @param hash
+ * @param name
+ * @param value
+ * @param defaultValue
+ *
+ * @since 3.3.2
+ */
+ public void addToScriptHash(Map<String, Object> hash, String name, Object value, String defaultValue) {
+ addToScriptHash(hash, name, value, defaultValue, null);
+ }
+
+ /**
+ * Puts value into map under specified key if the value is not empty and not default.
+ * Performs optional value wrapping.
+ *
+ * @param hash
+ * @param name
+ * @param value
+ *
+ * @since 3.3.2
+ */
+ public void addToScriptHash(Map<String, Object> hash, String name, Object value) {
+ addToScriptHash(hash, name, value, null, null);
+ }
+
+ /**
+ * Convert HTML attribute name to component property name.
+ *
+ * @param key
+ * @return
+ */
+ protected Object getComponentAttributeName(Object key) {
+ Object converted = SUBSTITUTIONS.get(key);
+
+ if (null == converted) {
+ return key;
+ } else {
+ return converted;
+ }
+ }
+
+ /**
+ * Convert attribute value to proper object. For known html boolean
+ * attributes return name for true value, otherthise - null. For non-boolean
+ * attributes return same value.
+ *
+ * @param name
+ * attribute name.
+ * @param value
+ * @return
+ */
+ protected Object attributeValue(String name, Object value) {
+ if (null == value || Arrays.binarySearch(HTML.PASS_THRU_BOOLEAN, name) < 0) {
+ return value;
+ }
+
+ boolean checked;
+
+ if (value instanceof Boolean) {
+ checked = ((Boolean) value).booleanValue();
+ } else {
+ checked = Boolean.parseBoolean(value.toString());
+ }
+
+ return checked ? name : null;
+ }
+
+ /**
+ * Get boolean value of logical attribute
+ *
+ * @param component
+ * @param name
+ * attribute name
+ * @return true if attribute is equals Boolean.TRUE or String "true" , false
+ * otherwise.
+ */
+ public boolean isBooleanAttribute(UIComponent component, String name) {
+ Object attrValue = component.getAttributes().get(name);
+ boolean result = false;
+
+ if (null != attrValue) {
+ if (attrValue instanceof String) {
+ result = "true".equalsIgnoreCase((String) attrValue);
+ } else {
+ result = Boolean.TRUE.equals(attrValue);
+ }
+ }
+
+ return result;
+ }
+
+ /**
+ * Return converted value for {@link javax.faces.component.ValueHolder} as
+ * String, perform nessesary convertions.
+ *
+ * @param context
+ * @param component
+ * @return
+ */
+ public String getValueAsString(FacesContext context, UIComponent component) {
+
+ // First - get submitted value for input components
+ if (component instanceof EditableValueHolder) {
+ EditableValueHolder input = (EditableValueHolder) component;
+ String submittedValue = (String) input.getSubmittedValue();
+
+ if (null != submittedValue) {
+ return submittedValue;
+ }
+ }
+
+ // If no submitted value presented - convert same for UIInput/UIOutput
+ if (component instanceof ValueHolder) {
+ return formatValue(context, component, ((ValueHolder) component).getValue());
+ } else {
+ throw new IllegalArgumentException(
+ Messages.getMessage(Messages.CONVERTING_NON_VALUE_HOLDER_COMPONENT_ERROR, component.getId()));
+ }
+ }
+
+ /**
+ * Convert any object value to string. If component instance of
+ * {@link ValueHolder } got {@link Converter} for formatting. If not,
+ * attempt to use converter based on value type.
+ *
+ * @param context
+ * @param component
+ * @return
+ */
+ public String formatValue(FacesContext context, UIComponent component, Object value) {
+ if (value instanceof String) {
+ return (String) value;
+ }
+
+ Converter converter = null;
+
+ if (component instanceof ValueHolder) {
+ ValueHolder holder = (ValueHolder) component;
+
+ converter = holder.getConverter();
+ }
+
+ if ((null == converter) && (null != value)) {
+ try {
+ converter = context.getApplication().createConverter(value.getClass());
+ } catch (FacesException e) {
+
+ // TODO - log converter exception.
+ }
+ }
+
+ if (null == converter) {
+ if (null != value) {
+ return value.toString();
+ }
+ } else {
+ return converter.getAsString(context, component, value);
+ }
+
+ return "";
+ }
+
+ public String encodePx(String value) {
+ return HtmlDimensions.formatPx(HtmlDimensions.decode(value));
+ }
+
+ /**
+ * formats given value to
+ *
+ * @param value
+ *
+ * @return
+ */
+ public String encodePctOrPx(String value) {
+ if (value.indexOf('%') > 0) {
+ return value;
+ } else {
+ return encodePx(value);
+ }
+ }
+
+ /**
+ * Find nested form for given component
+ *
+ * @param component
+ * @return nested <code>UIForm</code> component, or <code>null</code>
+ */
+ public UIForm getNestingForm(FacesContext context, UIComponent component) {
+ UIComponent parent = component.getParent();
+
+ while ((parent != null) && !(parent instanceof UIForm)) {
+ parent = parent.getParent();
+ }
+
+ UIForm nestingForm = null;
+
+ if (parent != null) {
+
+ // link is nested inside a form
+ nestingForm = (UIForm) parent;
+ }
+
+ return nestingForm;
+ }
+
+ /**
+ * @param context
+ * @param component
+ * @return
+ * @throws IOException
+ */
+ public void encodeBeginFormIfNessesary(FacesContext context, UIComponent component) throws IOException {
+ UIForm form = getNestingForm(context, component);
+
+ if (null == form) {
+ ResponseWriter writer = context.getResponseWriter();
+ String clientId = component.getClientId(context) + DUMMY_FORM_ID;
+
+ encodeBeginForm(context, component, writer, clientId);
+
+ // writer.writeAttribute(HTML.STYLE_ATTRIBUTE, "margin:0;
+ // padding:0;", null);
+ }
+ }
+
+ /**
+ * @param context
+ * @param component
+ * @param writer
+ * @param clientId
+ * @throws IOException
+ */
+ public void encodeBeginForm(FacesContext context, UIComponent component, ResponseWriter writer, String clientId)
+ throws IOException {
+
+ String actionURL = getActionUrl(context);
+ String encodeActionURL = context.getExternalContext().encodeActionURL(actionURL);
+
+ writer.startElement(HTML.FORM_ELEMENT, component);
+ writer.writeAttribute(HTML.ID_ATTRIBUTE, clientId, null);
+ writer.writeAttribute(HTML.NAME_ATTRIBUTE, clientId, null);
+ writer.writeAttribute(HTML.METHOD_ATTRIBUTE, "post", null);
+ writer.writeAttribute(HTML.STYLE_ATTRIBUTE, "margin:0; padding:0; display: inline;", null);
+ writer.writeURIAttribute(HTML.ACTION_ATTRIBUTE, encodeActionURL, "action");
+ }
+
+ /**
+ * @param context
+ * @param component
+ * @throws IOException
+ */
+ public void encodeEndFormIfNessesary(FacesContext context, UIComponent component) throws IOException {
+ UIForm form = getNestingForm(context, component);
+
+ if (null == form) {
+ ResponseWriter writer = context.getResponseWriter();
+
+ // TODO - hidden form parameters ?
+ encodeEndForm(context, writer);
+ }
+ }
+
+ /**
+ * @param context
+ * @param writer
+ * @throws IOException
+ */
+ public void encodeEndForm(FacesContext context, ResponseWriter writer) throws IOException {
+ AjaxRendererUtils.writeState(context);
+ writer.endElement(HTML.FORM_ELEMENT);
+ }
+
+ /**
+ * @param facesContext
+ * @return String A String representing the action URL
+ */
+ public String getActionUrl(FacesContext facesContext) {
+ ViewHandler viewHandler = facesContext.getApplication().getViewHandler();
+ String viewId = facesContext.getViewRoot().getViewId();
+
+ return viewHandler.getActionURL(facesContext, viewId);
+ }
+
+ /**
+ * Simplified version of {@link encodeId}
+ *
+ * @param context
+ * @param component
+ * @return client id of current component
+ */
+ public String clientId(FacesContext context, UIComponent component) {
+ String clientId = "";
+
+ try {
+ clientId = component.getClientId(context);
+ } catch (Exception e) {
+
+ // just ignore
+ }
+
+ return clientId;
+ }
+
+ /**
+ * Wtrie JavaScript with start/end elements and type.
+ *
+ * @param context
+ * @param component
+ * @param script
+ */
+ public void writeScript(FacesContext context, UIComponent component, Object script) throws IOException {
+ ResponseWriter writer = context.getResponseWriter();
+
+ writer.startElement(HTML.SCRIPT_ELEM, component);
+ writer.writeAttribute(HTML.TYPE_ATTR, "text/javascript", "type");
+ writer.writeText(script, null);
+ writer.endElement(HTML.SCRIPT_ELEM);
+ }
+
+ /**
+ * @param ids
+ * @param keyword
+ * @return
+ * @since 4.0
+ */
+ private static boolean checkKeyword(Collection<String> ids, String keyword) {
+ if (ids.contains(keyword)) {
+ if (ids.size() != 1) {
+ //TODO log
+ }
+
+ return true;
+ }
+
+ return false;
+ }
+
+ public String getPredefinedMetaComponentId(FacesContext facesContext, UIComponent component, String id) {
+
+ if (AjaxRendererUtils.ALL.equals(id)) {
+ return AjaxRendererUtils.ALL;
+ } else if (AjaxRendererUtils.NONE.equals(id)) {
+ return AjaxRendererUtils.NONE;
+ } else if (AjaxRendererUtils.THIS.equals(id)) {
+ return component.getClientId(facesContext);
+ } else if (AjaxRendererUtils.FORM.equals(id)) {
+ UIForm nestingForm = getNestingForm(facesContext, component);
+ if (nestingForm != null) {
+ return nestingForm.getClientId(facesContext);
+ } else {
+ //TODO nick - log warning for missing form
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * @param context
+ * @param component
+ * @param shortIds
+ * @since 4.0
+ * @return
+ */
+ public Collection<String> findComponentsFor(FacesContext context, UIComponent component,
+ Collection<String> shortIds) {
+
+ // TODO - implement
+ // TODO add support for @*
+ Set<String> result = new LinkedHashSet<String>(shortIds.size());
+
+ if (checkKeyword(shortIds, AjaxRendererUtils.ALL)) {
+ result.add(AjaxRendererUtils.ALL);
+ } else if (checkKeyword(shortIds, AjaxRendererUtils.NONE)) {
+ //do nothing, use empty set
+ } else {
+ ComponentIdResolver locator = new ComponentIdResolver(context);
+
+ for (String id : shortIds) {
+ String predefinedMetaComponentId = getPredefinedMetaComponentId(context, component, id);
+ if (predefinedMetaComponentId != null) {
+ if (AjaxRendererUtils.GLOBAL_META_COMPONENTS.contains(predefinedMetaComponentId)) {
+ result.clear();
+ result.add(predefinedMetaComponentId);
+ break;
+ } else {
+ result.add(predefinedMetaComponentId);
+ continue;
+ }
+ }
+
+ locator.addId(id);
+ }
+
+ locator.resolve(component);
+
+ result.addAll(locator.getResolvedIds());
+ }
+
+ return result;
+ }
+
+ public UIComponent findComponentFor(FacesContext context, UIComponent component, String id) {
+ return findComponentFor(component, id);
+ }
+
+ /**
+ * @param component
+ * @param id
+ * @return
+ */
+ public UIComponent findComponentFor(UIComponent component, String id) {
+ if (id == null) {
+ throw new NullPointerException("id is null!");
+ }
+
+ if (id.length() == 0) {
+ return null;
+ }
+
+ UIComponent target = null;
+ UIComponent parent = component;
+ UIComponent root = component;
+
+ while ((null == target) && (null != parent)) {
+ target = parent.findComponent(id);
+ root = parent;
+ parent = parent.getParent();
+ }
+
+ if (null == target) {
+ target = findUIComponentBelow(root, id);
+ }
+
+ return target;
+ }
+
+ /**
+ * If target component contains generated id and for doesn't, correct for id
+ * @param forAttr
+ * @param component
+ *
+ */
+ public String correctForIdReference(String forAttr, UIComponent component) {
+ int contains = forAttr.indexOf(UIViewRoot.UNIQUE_ID_PREFIX);
+
+ if (contains <= 0) {
+ String id = component.getId();
+ int pos = id.indexOf(UIViewRoot.UNIQUE_ID_PREFIX);
+
+ if (pos > 0) {
+ return forAttr.concat(id.substring(pos));
+ }
+ }
+
+ return forAttr;
+ }
+
+ private UIComponent findUIComponentBelow(UIComponent root, String id) {
+ UIComponent target = null;
+
+ for (Iterator<UIComponent> iter = root.getFacetsAndChildren(); iter.hasNext();) {
+ UIComponent child = (UIComponent) iter.next();
+
+ if (child instanceof NamingContainer) {
+ try {
+ target = child.findComponent(id);
+ } catch (IllegalArgumentException iae) {
+ continue;
+ }
+ }
+
+ if (target == null) {
+ if ((child.getChildCount() > 0) || (child.getFacetCount() > 0)) {
+ target = findUIComponentBelow(child, id);
+ }
+ }
+
+ if (target != null) {
+ break;
+ }
+ }
+
+ return target;
+ }
+
+ public static void writeEventHandlerFunction(FacesContext context, UIComponent component, String eventName)
+ throws IOException {
+
+ ResponseWriter writer = context.getResponseWriter();
+ Object script = component.getAttributes().get(eventName);
+
+ if ((script != null) && !script.equals("")) {
+ JSFunctionDefinition onEventDefinition = new JSFunctionDefinition();
+
+ onEventDefinition.addParameter("event");
+ onEventDefinition.addToBody(script);
+ writer.writeText(eventName + ": " + onEventDefinition.toScript(), null);
+ } else {
+ writer.writeText(eventName + ": ''", null);
+ }
+ }
+
+ public JSFunctionDefinition getAsEventHandler(FacesContext context, UIComponent component, String attributeName,
+ String append) {
+ String event = (String) component.getAttributes().get(attributeName);
+
+ if (event != null) {
+ event = event.trim();
+
+ if (event.length() != 0) {
+ JSFunctionDefinition function = new JSFunctionDefinition();
+
+ function.addParameter("event");
+
+ if ((null != append) && (append.length() > 0)) {
+ function.addToBody(event + append);
+ } else {
+ function.addToBody(event);
+ }
+
+ return function;
+ }
+ }
+
+ return null;
+ }
+
+ public String escapeJavaScript(Object o) {
+ if (o != null) {
+ StringBuilder result = new StringBuilder();
+ JSEncoder encoder = new JSEncoder();
+ char[] chars = o.toString().toCharArray();
+ int start = 0;
+ int end = chars.length;
+
+ for (int x = start; x < end; x++) {
+ char c = chars[x];
+
+ if (encoder.compile(c)) {
+ continue;
+ }
+
+ if (start != x) {
+ result.append(chars, start, x - start);
+ }
+
+ result.append(encoder.encode(c));
+ start = x + 1;
+
+ continue;
+ }
+
+ if (start != end) {
+ result.append(chars, start, end - start);
+ }
+
+ return result.toString();
+ } else {
+ return null;
+ }
+ }
+
+ public void encodeChildren(FacesContext context, UIComponent component) throws IOException {
+ if (component.getChildCount() > 0) {
+ for (UIComponent child : component.getChildren()) {
+ child.encodeAll(context);
+ }
+ }
+ }
+
+ public boolean hasExplicitId(UIComponent component) {
+ return component.getId() != null && !component.getId().startsWith(UIViewRoot.UNIQUE_ID_PREFIX);
+ }
+
+ /**
+ * Common HTML elements and attributes names.
+ *
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.6 $ $Date: 2007/02/08 19:07:16 $
+ *
+ */
+ public interface HTML {
+ // elements
+ public static final String A_ELEMENT = "a";
+ public static final String BODY_ELEMENT = "body";
+ public static final String IMG_ELEMENT = "img";
+ public static final String INPUT_ELEM = "input";
+ public static final String INPUT_TYPE_HIDDEN = "hidden";
+ public static final String BUTTON = "button";
+ public static final String CAPTION_ELEMENT = "caption";
+ public static final String CHARSET_ATTR = "charset";
+ public static final String COORDS_ATTR = "coords";
+ public static final String COLGROUP_ELEMENT = "colgroup";
+ public static final String COL_ELEMENT = "col";
+ public static final String DISABLED_ATTR = "disabled";
+ public static final String DIV_ELEM = "div";
+ public static final String DD_ELEMENT = "dd";
+ public static final String DL_ELEMENT = "dl";
+ public static final String DT_ELEMENT = "dt";
+ public static final String FORM_ELEMENT = "form";
+ public static final String HEAD_ELEMENT = "head";
+ public static final String HEIGHT_ATTRIBUTE = "height";
+ public static final String HREFLANG_ATTR = "hreflang";
+ public static final String HREF_ATTR = "href";
+ public static final String HTML_ELEMENT = "html";
+ public static final String LINK_ELEMENT = "link";
+ public static final String SCRIPT_ELEM = "script";
+ public static final String SPAN_ELEM = "span";
+ public static final String TFOOT_ELEMENT = "tfoot";
+ public static final String THEAD_ELEMENT = "thead";
+ public static final String TABLE_ELEMENT = "table";
+ public static final String TBODY_ELEMENT = "tbody";
+ public static final String TD_ELEM = "td";
+ public static final String TR_ELEMENT = "tr";
+ public static final String TH_ELEM = "th";
+ public static final String TITLE_ELEM = "title";
+ public static final String UL_ELEMENT = "ul";
+ public static final String OL_ELEMENT = "ol";
+ public static final String LI_ELEMENT = "li";
+
+ // attributes
+ public static final String FRAME_ATTRIBUTE = "frame";
+ public static final String BORDER_ATTRIBUTE = "border";
+ public static final String BGCOLOR_ATTRIBUTE = "bgcolor";
+ public static final String ACCEPT_ATTRIBUTE = "accept";
+ public static final String ACCEPT_CHARSET_ATTRIBUTE = "accept-charset";
+ public static final String ACCESSKEY_ATTRIBUTE = "accesskey";
+ public static final String ACTION_ATTRIBUTE = "action";
+ public static final String ALIGN_ATTRIBUTE = "align";
+ public static final String ALT_ATTRIBUTE = "alt";
+ public static final String AUTOCOMPLETE_ATTRIBUTE = "autocomplete";
+ public static final String CLASS_ATTRIBUTE = "class";
+ public static final String COLS_ATTRIBUTE = "cols";
+ public static final String COLSPAN_ATTRIBUTE = "colspan";
+ public static final String CELLPADDING_ATTRIBUTE = "cellpadding";
+ public static final String CELLSPACING_ATTRIBUTE = "cellspacing";
+ public static final String DIR_ATTRIBUTE = "dir";
+ public static final String ENCTYPE_ATTRIBUTE = "enctype";
+
+ public static final String ID_ATTRIBUTE = "id";
+ public static final String LANG_ATTRIBUTE = "lang";
+ public static final String LONGDESC_ATTRIBUTE = "longdesc";
+ public static final String MAXLENGTH_ATTRIBUTE = "maxlength";
+ public static final String MEDIA_ATTRIBUTE = "media";
+ public static final String METHOD_ATTRIBUTE = "method";
+ public static final String NAME_ATTRIBUTE = "name";
+ public static final String NOWRAP_ATTRIBUTE = "nowrap";
+ public static final String ROWS_ATTRIBUTE = "rows";
+ public static final String RULES_ATTRIBUTE = "rules";
+ public static final String ROWSPAN_ATTRIBUTE = "rowspan";
+ public static final String READONLY_ATTRIBUTE = "readonly";
+ public static final String SIZE_ATTRIBUTE = "size";
+ public static final String SRC_ATTRIBUTE = "src";
+ public static final String STYLE_ATTRIBUTE = "style";
+ public static final String SUMMARY_ATTRIBUTE = "summary";
+ public static final String SCOPE_ATTRIBUTE = "scope";
+ public static final String TABINDEX_ATTRIBUTE = "tabindex";
+ public static final String TITLE_ATTRIBUTE = "title";
+ public static final String TARGET_ATTRIBUTE = "target";
+ public static final String TYPE_ATTR = "type";
+
+ public static final String USEMAP_ATTRIBUTE = "usemap";
+
+ public static final String VALIGN_ATTRIBUTE = "valign";
+ public static final String VALUE_ATTRIBUTE = "value";
+ public static final String WIDTH_ATTRIBUTE = "width";
+
+
+ public static final String ONBLUR_ATTRIBUTE = "onblur";
+ public static final String ONCHANGE_ATTRIBUTE = "onchange";
+ public static final String ONCLICK_ATTRIBUTE = "onclick";
+ public static final String ONDBLCLICK_ATTRIBUTE = "ondblclick";
+ public static final String ONFOCUS_ATTRIBUTE = "onfocus";
+ public static final String ONKEYDOWN_ATTRIBUTE = "onkeydown";
+ public static final String ONKEYPRESS_ATTRIBUTE = "onkeypress";
+ public static final String ONKEYUP_ATTRIBUTE = "onkeyup";
+ public static final String ONLOAD_ATTRIBUTE = "onload";
+ public static final String ONMOUSEDOWN_ATTRIBUTE = "onmousedown";
+ public static final String ONMOUSEMOVE_ATTRIBUTE = "onmousemove";
+ public static final String ONMOUSEOUT_ATTRIBUTE = "onmouseout";
+ public static final String ONMOUSEOVER_ATTRIBUTE = "onmouseover";
+ public static final String ONMOUSEUP_ATTRIBUTE = "onmouseup";
+ public static final String ONRESET_ATTRIBUTE = "onreset";
+ public static final String ONSELECT_ATTRIBUTE = "onselect";
+ public static final String ONSUBMIT_ATTRIBUTE = "onsubmit";
+ public static final String ONUNLOAD_ATTRIBUTE = "onunload";
+
+ public static final String REL_ATTR = "rel";
+ public static final String REV_ATTR = "rev";
+ public static final String SHAPE_ATTR = "shape";
+ public static final String STYLE_CLASS_ATTR = "styleClass";
+
+
+
+ // public static final String ONRESET_ATTRIBUTE = "onreset";
+ // attributes sets.
+ public static final String[] PASS_THRU = {
+
+ // DIR_ATTRIBUTE,
+ // LANG_ATTRIBUTE,
+ // STYLE_ATTRIBUTE,
+ // TITLE_ATTRIBUTE
+ "accesskey", "alt", "cols", "height", "lang", "longdesc", "maxlength", "rows", "size", "tabindex", "title",
+ "width", "dir", "rules", "frame", "border", "cellspacing", "cellpadding", "summary", "bgcolor", "usemap",
+ "enctype", "accept-charset", "accept", "target", "charset", "coords", "hreflang", "rel", "rev", "shape",
+ "disabled", "readonly", "ismap", "align"
+ };
+
+ /**
+ * HTML attributes allowed boolean-values only
+ */
+ public static final String[] PASS_THRU_BOOLEAN = {
+ "disabled", "declare", "readonly", "compact", "ismap", "selected", "checked", "nowrap", "noresize",
+ "nohref", "noshade", "multiple"
+ };
+ public static final String[] PASS_THRU_EVENTS = {
+ "onblur", "onchange", "onclick", "ondblclick", "onfocus", "onkeydown", "onkeypress", "onkeyup", "onload",
+ "onmousedown", "onmousemove", "onmouseout", "onmouseover", "onmouseup", "onreset", "onselect", "onsubmit",
+ "onunload"
+ };
+ public static final String[] PASS_THRU_STYLES = {"style", "class", };
+
+ /**
+ * all HTML attributes with URI value.
+ */
+ public static final String[] PASS_THRU_URI = {
+ "usemap", "background", "codebase", "cite", "data", "classid", "href", "longdesc", "profile", "src"
+ };
+
+
+ public static final String TEXT_JAVASCRIPT_TYPE = "text/javascript";
+ public static final String REL_STYLESHEET = "stylesheet";
+ public static final String CSS_TYPE = "text/css";
+ public static final String JAVASCRIPT_TYPE = "text/javascript";
+ }
+}
Deleted: branches/RF-7560/core/impl/src/test/java/org/ajax4jsf/renderkit/IdSplitBuilderTest.java
===================================================================
--- branches/RF-7560/core/impl/src/test/java/org/ajax4jsf/renderkit/IdSplitBuilderTest.java 2010-08-31 17:45:24 UTC (rev 19053)
+++ branches/RF-7560/core/impl/src/test/java/org/ajax4jsf/renderkit/IdSplitBuilderTest.java 2010-08-31 18:46:44 UTC (rev 19054)
@@ -1,80 +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.ajax4jsf.renderkit;
-
-import static org.junit.Assert.assertArrayEquals;
-
-import org.junit.Test;
-
-
-/**
- * @author Nick Belaevski
- *
- */
-public class IdSplitBuilderTest {
-
- private static String[] asArray(String... strings) {
- return strings;
- }
-
- @Test
- public void testEmptyString() throws Exception {
- assertArrayEquals(asArray(), IdSplitBuilder.split(""));
- assertArrayEquals(asArray(), IdSplitBuilder.split(" \r\t\n "));
- }
-
- @Test
- public void testOneStrings() throws Exception {
- assertArrayEquals(asArray("test"), IdSplitBuilder.split("test"));
- assertArrayEquals(asArray("some:id"), IdSplitBuilder.split("some:id"));
- assertArrayEquals(asArray("table:[1]"), IdSplitBuilder.split("table:[1]"));
- assertArrayEquals(asArray("table:[1, 2]"), IdSplitBuilder.split("table:[1, 2]"));
- assertArrayEquals(asArray("table:[1, 2]:nestedTable:[*]"), IdSplitBuilder.split("table:[1, 2]:nestedTable:[*]"));
- assertArrayEquals(asArray("table:[1, 2]:[*]:group"), IdSplitBuilder.split("table:[1, 2]:[*]:group"));
- assertArrayEquals(asArray("table:[1 2]:nestedTable:[*]"), IdSplitBuilder.split("table:[1 2]:nestedTable:[*]"));
- assertArrayEquals(asArray("table:[1 2]:[*]:group"), IdSplitBuilder.split("table:[1 2]:[*]:group"));
- }
-
- @Test
- public void testTwoStrings() throws Exception {
- assertArrayEquals(asArray("test", "abc"), IdSplitBuilder.split("test abc"));
- assertArrayEquals(asArray("some:id", "form:table"), IdSplitBuilder.split("some:id form:table"));
- assertArrayEquals(asArray("test", "abc"), IdSplitBuilder.split("test, abc"));
- assertArrayEquals(asArray("some:id", "form:table"), IdSplitBuilder.split("some:id, form:table"));
-
- assertArrayEquals(asArray("test:[1 2 3]:abc", "form:[2]"), IdSplitBuilder.split("test:[1 2 3]:abc form:[2]"));
- assertArrayEquals(asArray("[1 2]:some", "[3\t4]:id"), IdSplitBuilder.split(" [1 2]:some [3\t4]:id "));
- }
-
- @Test
- public void testSeveralStrings() throws Exception {
- assertArrayEquals(asArray("test", "abc", "def", "ghi"), IdSplitBuilder.split("test abc def ghi"));
- assertArrayEquals(asArray("test:[1 2]abc", "def", "ghi"), IdSplitBuilder.split("test:[1 2]abc def ghi"));
- assertArrayEquals(asArray("[1 2]abc", "[3, 4]def", "ghi[5 6 7]"),
- IdSplitBuilder.split("[1 2]abc [3, 4]def ghi[5 6 7]"));
-
- assertArrayEquals(
- asArray("test:[1 2]:abc", "table", "form:table:[ * ]:child", "extTable:[ 0, 3 ]:child:[1 8]:@header"),
- IdSplitBuilder.split(" test:[1 2]:abc, table," +
- " form:table:[ * ]:child, extTable:[ 0, 3 ]:child:[1 8]:@header" ));
- }
-}
Deleted: branches/RF-7560/core/impl/src/test/java/org/ajax4jsf/renderkit/RendererUtilsTest.java
===================================================================
--- branches/RF-7560/core/impl/src/test/java/org/ajax4jsf/renderkit/RendererUtilsTest.java 2010-08-31 17:45:24 UTC (rev 19053)
+++ branches/RF-7560/core/impl/src/test/java/org/ajax4jsf/renderkit/RendererUtilsTest.java 2010-08-31 18:46:44 UTC (rev 19054)
@@ -1,146 +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 java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import junit.framework.TestCase;
-
-import org.ajax4jsf.javascript.JSFunctionDefinition;
-import org.ajax4jsf.renderkit.RendererUtils.ScriptHashVariableWrapper;
-
-/**
- * @author Nick Belaevski
- * @since 3.3.2
- */
-public class RendererUtilsTest extends TestCase {
- public void testIsEmpty() throws Exception {
- RendererUtils utils = RendererUtils.getInstance();
-
- assertTrue(utils.isEmpty(null));
- assertFalse(utils.isEmpty(new Object()));
- assertFalse(utils.isEmpty(Boolean.FALSE));
- assertFalse(utils.isEmpty(Long.valueOf(0)));
- assertFalse(utils.isEmpty(Integer.valueOf(0)));
- assertFalse(utils.isEmpty(Short.valueOf((short) 0)));
- assertFalse(utils.isEmpty(Byte.valueOf((byte) 0)));
- assertTrue(utils.isEmpty(""));
- assertFalse(utils.isEmpty("s"));
- assertTrue(utils.isEmpty(new ArrayList<Object>()));
- assertTrue(utils.isEmpty(Collections.EMPTY_LIST));
-
- List<Object> testList = new ArrayList<Object>();
-
- testList.add("x");
- assertFalse(utils.isEmpty(testList));
- assertTrue(utils.isEmpty(new HashMap<String, Object>()));
- assertTrue(utils.isEmpty(Collections.EMPTY_MAP));
-
- Map<String, Object> testMap = new HashMap<String, Object>();
-
- testMap.put("x", "y");
- assertFalse(utils.isEmpty(testMap));
- assertTrue(utils.isEmpty(new Object[0]));
- assertTrue(utils.isEmpty(new int[0]));
- assertFalse(utils.isEmpty(new Object[1]));
- assertFalse(utils.isEmpty(new int[1]));
- }
-
- public void testScriptHashVariableWrapper() throws Exception {
- assertEquals("abc", RendererUtils.ScriptHashVariableWrapper.DEFAULT.wrap("abc"));
-
- Object eventHandler = RendererUtils.ScriptHashVariableWrapper.EVENT_HANDLER.wrap("abc");
-
- assertTrue(eventHandler instanceof JSFunctionDefinition);
-
- JSFunctionDefinition handlerFunction = (JSFunctionDefinition) eventHandler;
-
- assertEquals("function(event){abc}", handlerFunction.toScript().replaceAll("\\s", ""));
- }
-
- public void testAddToScriptHash() throws Exception {
- Map<String, Object> hash = new HashMap<String, Object>();
- RendererUtils utils = RendererUtils.getInstance();
-
- utils.addToScriptHash(hash, "x", "y", null, null);
- assertEquals("y", hash.get("x"));
- utils.addToScriptHash(hash, "y", "", null, null);
- assertNull(hash.get("y"));
- assertFalse(hash.containsKey("y"));
- utils.addToScriptHash(hash, "y1", null, null, null);
- assertNull(hash.get("y1"));
- assertFalse(hash.containsKey("y1"));
- utils.addToScriptHash(hash, "st", "server", "", null);
- assertEquals("server", hash.get("st"));
- utils.addToScriptHash(hash, "st1", "ajax", "ajax", null);
- assertNull(hash.get("st1"));
- assertFalse(hash.containsKey("st1"));
- utils.addToScriptHash(hash, "st2", "", "ajax", null);
- assertNull(hash.get("st2"));
- assertFalse(hash.containsKey("st2"));
- utils.addToScriptHash(hash, "null", null, "server", null);
- assertNull(hash.get("null"));
- assertFalse(hash.containsKey("null"));
- utils.addToScriptHash(hash, "b", false, null, null);
- assertNull(hash.get("b"));
- assertFalse(hash.containsKey("b"));
- utils.addToScriptHash(hash, "b1", true, null, null);
- assertEquals(Boolean.TRUE, hash.get("b1"));
- utils.addToScriptHash(hash, "b2", true, "true", null);
- assertNull(hash.get("b2"));
- assertFalse(hash.containsKey("b2"));
- utils.addToScriptHash(hash, "b3", false, "true", null);
- assertEquals(Boolean.FALSE, hash.get("b3"));
- utils.addToScriptHash(hash, "b4", true, "false", null);
- assertEquals(Boolean.TRUE, hash.get("b4"));
- utils.addToScriptHash(hash, "b5", false, "false", null);
- assertNull(hash.get("b5"));
- assertFalse(hash.containsKey("b5"));
- utils.addToScriptHash(hash, "i", Integer.valueOf(0), null, null);
- assertEquals(Integer.valueOf(0), hash.get("i"));
- utils.addToScriptHash(hash, "i1", Integer.valueOf(0), "0", null);
- assertNull(hash.get("i1"));
- assertFalse(hash.containsKey("i1"));
- utils.addToScriptHash(hash, "i2", Integer.valueOf(0), "1", null);
- assertEquals(Integer.valueOf(0), hash.get("i2"));
- utils.addToScriptHash(hash, "i3", Integer.MIN_VALUE, null, null);
- assertNull(hash.get("i3"));
- assertFalse(hash.containsKey("i3"));
- utils.addToScriptHash(hash, "i4", Integer.MIN_VALUE, "0", null);
- assertNull(hash.get("i4"));
- assertFalse(hash.containsKey("i4"));
- utils.addToScriptHash(hash, "plain", "test", null, ScriptHashVariableWrapper.DEFAULT);
- assertEquals("test", hash.get("plain"));
- utils.addToScriptHash(hash, "plain1", "newtest", "blank", ScriptHashVariableWrapper.DEFAULT);
- assertEquals("newtest", hash.get("plain1"));
- utils.addToScriptHash(hash, "onclick", "alert(1)", null, ScriptHashVariableWrapper.EVENT_HANDLER);
- assertTrue(hash.get("onclick") instanceof JSFunctionDefinition);
- utils.addToScriptHash(hash, "onclick1", "alert(1)", "no-val", ScriptHashVariableWrapper.EVENT_HANDLER);
- assertTrue(hash.get("onclick1") instanceof JSFunctionDefinition);
- }
-}
Deleted: branches/RF-7560/core/impl/src/test/java/org/richfaces/application/FacesMessages.java
===================================================================
--- branches/RF-7560/core/impl/src/test/java/org/richfaces/application/FacesMessages.java 2010-08-31 17:45:24 UTC (rev 19053)
+++ branches/RF-7560/core/impl/src/test/java/org/richfaces/application/FacesMessages.java 2010-08-31 18:46:44 UTC (rev 19054)
@@ -1,47 +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.application;
-
-import org.richfaces.l10n.MessageBundle;
-
-/**
- * @author Nick Belaevski
- *
- */
-@MessageBundle(baseName = "org.richfaces.application.FacesMessages")
-public enum FacesMessages {
-
- UIINPUT_CONVERSION("javax.faces.component.UIInput.CONVERSION"),
- ENUM_CONVERTER_ENUM("javax.faces.converter.EnumConverter.ENUM"),
- CONVERTER_STRING("javax.faces.converter.STRING");
-
- private String key;
-
- private FacesMessages(String key) {
- this.key = key;
- }
-
- @Override
- public String toString() {
- return key;
- }
-}
Copied: branches/RF-7560/core/impl/src/test/java/org/richfaces/application/MessageFactoryImplTest1.java (from rev 19052, branches/RF-7560/core/impl/src/test/java/org/richfaces/application/MessageFactoryImpltest.java)
===================================================================
--- branches/RF-7560/core/impl/src/test/java/org/richfaces/application/MessageFactoryImplTest1.java (rev 0)
+++ branches/RF-7560/core/impl/src/test/java/org/richfaces/application/MessageFactoryImplTest1.java 2010-08-31 18:46:44 UTC (rev 19054)
@@ -0,0 +1,129 @@
+/*
+ * 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.application;
+
+import static org.easymock.EasyMock.expect;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.util.Locale;
+
+import javax.faces.application.FacesMessage;
+import javax.faces.component.UIViewRoot;
+
+import org.jboss.test.faces.mock.MockFacesEnvironment;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.richfaces.l10n.BundleLoader;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class MessageFactoryImplTest1 {
+
+ private MockFacesEnvironment facesEnvironment;
+
+ private MessageFactory messageFactory;
+
+ @Before
+ public void setUp() throws Exception {
+ Locale.setDefault(Locale.US);
+
+ facesEnvironment = MockFacesEnvironment.createEnvironment().withApplication();
+
+ messageFactory = new MessageFactoryImpl(new BundleLoader());
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ facesEnvironment.verify();
+ facesEnvironment.release();
+ facesEnvironment = null;
+
+ messageFactory = null;
+ }
+
+ @Test
+ public void testCreateMessageFromFacesBundle() throws Exception {
+ expect(facesEnvironment.getFacesContext().getViewRoot()).andStubReturn(null);
+ expect(facesEnvironment.getApplication().getMessageBundle()).andStubReturn(null);
+ facesEnvironment.replay();
+
+ // {1}: Could not convert ''{0}'' to a string.
+ FacesMessage stringConverterMessage = messageFactory.createMessage(facesEnvironment.getFacesContext(),
+ TestFacesMessages.CONVERTER_STRING, "something", "Message");
+
+ assertNotNull(stringConverterMessage);
+ assertEquals(FacesMessage.SEVERITY_INFO, stringConverterMessage.getSeverity());
+ assertEquals("Message: Could not convert 'something' to a string.", stringConverterMessage.getSummary());
+ assertEquals(stringConverterMessage.getSummary(), stringConverterMessage.getDetail());
+
+ // javax.faces.converter.EnumConverter.ENUM={2}: ''{0}'' must be convertible to an enum.
+ // javax.faces.converter.EnumConverter.ENUM_detail={2}: ''{0}'' must be convertible to an enum from the enum that contains the constant ''{1}''.
+ FacesMessage longConverterMessage = messageFactory.createMessage(facesEnvironment.getFacesContext(),
+ FacesMessage.SEVERITY_ERROR, TestFacesMessages.ENUM_CONVERTER_ENUM, "field", "anotherField", "Failed");
+ assertNotNull(longConverterMessage);
+ assertEquals(FacesMessage.SEVERITY_ERROR, longConverterMessage.getSeverity());
+ assertEquals("Failed: 'field' must be convertible to an enum.", longConverterMessage.getSummary());
+ assertEquals(
+ "Failed: 'field' must be convertible to an enum from the enum that contains the constant 'anotherField'.",
+ longConverterMessage.getDetail());
+ }
+
+ @Test
+ public void testCreateMessageFromApplicationBundle() throws Exception {
+ UIViewRoot mockViewRoot = facesEnvironment.createMock(UIViewRoot.class);
+ expect(mockViewRoot.getLocale()).andStubReturn(new Locale("ru", "RU"));
+ expect(facesEnvironment.getFacesContext().getViewRoot()).andStubReturn(mockViewRoot);
+ expect(facesEnvironment.getApplication().getMessageBundle()).andStubReturn("org.richfaces.application.MessageFactoryImplTest");
+ facesEnvironment.replay();
+
+ // {1}: ''{0}'' ne konvertiruyetsia v stroku.
+ FacesMessage stringConverterMessage = messageFactory.createMessage(facesEnvironment.getFacesContext(),
+ TestFacesMessages.CONVERTER_STRING, "something", "Message");
+
+ assertNotNull(stringConverterMessage);
+ assertEquals(FacesMessage.SEVERITY_INFO, stringConverterMessage.getSeverity());
+ assertEquals("Message: 'something' ne konvertiruyetsia v stroku.", stringConverterMessage.getSummary());
+ assertEquals(stringConverterMessage.getSummary(), stringConverterMessage.getDetail());
+
+ // javax.faces.converter.EnumConverter.ENUM={2}: ''{0}'' dolzhno konvertirovat''sia v enum.
+ // javax.faces.converter.EnumConverter.ENUM_detail={2}: ''{0}'' dolzhno konvertirovat''sia v enum iz enum s konstantoj ''{1}''.
+ FacesMessage longConverterMessage = messageFactory.createMessage(facesEnvironment.getFacesContext(),
+ FacesMessage.SEVERITY_ERROR, TestFacesMessages.ENUM_CONVERTER_ENUM, "field", "anotherField", "Failed");
+ assertNotNull(longConverterMessage);
+ assertEquals(FacesMessage.SEVERITY_ERROR, longConverterMessage.getSeverity());
+ assertEquals("Failed: 'field' dolzhno konvertirovat'sia v enum.", longConverterMessage.getSummary());
+ assertEquals(
+ "Failed: 'field' dolzhno konvertirovat'sia v enum iz enum s konstantoj 'anotherField'.",
+ longConverterMessage.getDetail());
+
+ // javax.faces.component.UIInput.CONVERSION={0}: Conversion error occurred.
+ FacesMessage inputConversionMessage = messageFactory.createMessage(facesEnvironment.getFacesContext(),
+ TestFacesMessages.UIINPUT_CONVERSION, "Failure message");
+ assertNotNull(inputConversionMessage);
+ assertEquals(FacesMessage.SEVERITY_INFO, inputConversionMessage.getSeverity());
+ assertEquals("Failure message: Conversion error occurred.", inputConversionMessage.getSummary());
+ }
+}
Deleted: branches/RF-7560/core/impl/src/test/java/org/richfaces/application/MessageFactoryImpltest.java
===================================================================
--- branches/RF-7560/core/impl/src/test/java/org/richfaces/application/MessageFactoryImpltest.java 2010-08-31 17:45:24 UTC (rev 19053)
+++ branches/RF-7560/core/impl/src/test/java/org/richfaces/application/MessageFactoryImpltest.java 2010-08-31 18:46:44 UTC (rev 19054)
@@ -1,129 +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.application;
-
-import static org.easymock.EasyMock.expect;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-import java.util.Locale;
-
-import javax.faces.application.FacesMessage;
-import javax.faces.component.UIViewRoot;
-
-import org.jboss.test.faces.mock.MockFacesEnvironment;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.richfaces.l10n.BundleLoader;
-
-/**
- * @author Nick Belaevski
- *
- */
-public class MessageFactoryImpltest {
-
- private MockFacesEnvironment facesEnvironment;
-
- private MessageFactory messageFactory;
-
- @Before
- public void setUp() throws Exception {
- Locale.setDefault(Locale.US);
-
- facesEnvironment = MockFacesEnvironment.createEnvironment().withApplication();
-
- messageFactory = new MessageFactoryImpl(new BundleLoader());
- }
-
- @After
- public void tearDown() throws Exception {
- facesEnvironment.verify();
- facesEnvironment.release();
- facesEnvironment = null;
-
- messageFactory = null;
- }
-
- @Test
- public void testCreateMessageFromFacesBundle() throws Exception {
- expect(facesEnvironment.getFacesContext().getViewRoot()).andStubReturn(null);
- expect(facesEnvironment.getApplication().getMessageBundle()).andStubReturn(null);
- facesEnvironment.replay();
-
- // {1}: Could not convert ''{0}'' to a string.
- FacesMessage stringConverterMessage = messageFactory.createMessage(facesEnvironment.getFacesContext(),
- FacesMessages.CONVERTER_STRING, "something", "Message");
-
- assertNotNull(stringConverterMessage);
- assertEquals(FacesMessage.SEVERITY_INFO, stringConverterMessage.getSeverity());
- assertEquals("Message: Could not convert 'something' to a string.", stringConverterMessage.getSummary());
- assertEquals(stringConverterMessage.getSummary(), stringConverterMessage.getDetail());
-
- // javax.faces.converter.EnumConverter.ENUM={2}: ''{0}'' must be convertible to an enum.
- // javax.faces.converter.EnumConverter.ENUM_detail={2}: ''{0}'' must be convertible to an enum from the enum that contains the constant ''{1}''.
- FacesMessage longConverterMessage = messageFactory.createMessage(facesEnvironment.getFacesContext(),
- FacesMessage.SEVERITY_ERROR, FacesMessages.ENUM_CONVERTER_ENUM, "field", "anotherField", "Failed");
- assertNotNull(longConverterMessage);
- assertEquals(FacesMessage.SEVERITY_ERROR, longConverterMessage.getSeverity());
- assertEquals("Failed: 'field' must be convertible to an enum.", longConverterMessage.getSummary());
- assertEquals(
- "Failed: 'field' must be convertible to an enum from the enum that contains the constant 'anotherField'.",
- longConverterMessage.getDetail());
- }
-
- @Test
- public void testCreateMessageFromApplicationBundle() throws Exception {
- UIViewRoot mockViewRoot = facesEnvironment.createMock(UIViewRoot.class);
- expect(mockViewRoot.getLocale()).andStubReturn(new Locale("ru", "RU"));
- expect(facesEnvironment.getFacesContext().getViewRoot()).andStubReturn(mockViewRoot);
- expect(facesEnvironment.getApplication().getMessageBundle()).andStubReturn("org.richfaces.application.MessageFactoryImplTest");
- facesEnvironment.replay();
-
- // {1}: ''{0}'' ne konvertiruyetsia v stroku.
- FacesMessage stringConverterMessage = messageFactory.createMessage(facesEnvironment.getFacesContext(),
- FacesMessages.CONVERTER_STRING, "something", "Message");
-
- assertNotNull(stringConverterMessage);
- assertEquals(FacesMessage.SEVERITY_INFO, stringConverterMessage.getSeverity());
- assertEquals("Message: 'something' ne konvertiruyetsia v stroku.", stringConverterMessage.getSummary());
- assertEquals(stringConverterMessage.getSummary(), stringConverterMessage.getDetail());
-
- // javax.faces.converter.EnumConverter.ENUM={2}: ''{0}'' dolzhno konvertirovat''sia v enum.
- // javax.faces.converter.EnumConverter.ENUM_detail={2}: ''{0}'' dolzhno konvertirovat''sia v enum iz enum s konstantoj ''{1}''.
- FacesMessage longConverterMessage = messageFactory.createMessage(facesEnvironment.getFacesContext(),
- FacesMessage.SEVERITY_ERROR, FacesMessages.ENUM_CONVERTER_ENUM, "field", "anotherField", "Failed");
- assertNotNull(longConverterMessage);
- assertEquals(FacesMessage.SEVERITY_ERROR, longConverterMessage.getSeverity());
- assertEquals("Failed: 'field' dolzhno konvertirovat'sia v enum.", longConverterMessage.getSummary());
- assertEquals(
- "Failed: 'field' dolzhno konvertirovat'sia v enum iz enum s konstantoj 'anotherField'.",
- longConverterMessage.getDetail());
-
- // javax.faces.component.UIInput.CONVERSION={0}: Conversion error occurred.
- FacesMessage inputConversionMessage = messageFactory.createMessage(facesEnvironment.getFacesContext(),
- FacesMessages.UIINPUT_CONVERSION, "Failure message");
- assertNotNull(inputConversionMessage);
- assertEquals(FacesMessage.SEVERITY_INFO, inputConversionMessage.getSeverity());
- assertEquals("Failure message: Conversion error occurred.", inputConversionMessage.getSummary());
- }
-}
Copied: branches/RF-7560/core/impl/src/test/java/org/richfaces/application/TestFacesMessages.java (from rev 19053, branches/RF-7560/core/impl/src/test/java/org/richfaces/application/FacesMessages.java)
===================================================================
--- branches/RF-7560/core/impl/src/test/java/org/richfaces/application/TestFacesMessages.java (rev 0)
+++ branches/RF-7560/core/impl/src/test/java/org/richfaces/application/TestFacesMessages.java 2010-08-31 18:46:44 UTC (rev 19054)
@@ -0,0 +1,47 @@
+/*
+ * 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.application;
+
+import org.richfaces.l10n.MessageBundle;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+@MessageBundle(baseName = "org.richfaces.application.FacesMessages")
+public enum TestFacesMessages {
+
+ UIINPUT_CONVERSION("javax.faces.component.UIInput.CONVERSION"),
+ ENUM_CONVERTER_ENUM("javax.faces.converter.EnumConverter.ENUM"),
+ CONVERTER_STRING("javax.faces.converter.STRING");
+
+ private String key;
+
+ private TestFacesMessages(String key) {
+ this.key = key;
+ }
+
+ @Override
+ public String toString() {
+ return key;
+ }
+}
Deleted: branches/RF-7560/core/impl/src/test/java/org/richfaces/component/UIRangedNumberInputTest.java
===================================================================
--- branches/RF-7560/core/impl/src/test/java/org/richfaces/component/UIRangedNumberInputTest.java 2010-08-31 17:45:24 UTC (rev 19053)
+++ branches/RF-7560/core/impl/src/test/java/org/richfaces/component/UIRangedNumberInputTest.java 2010-08-31 18:46:44 UTC (rev 19054)
@@ -1,120 +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.component;
-
-import org.jboss.test.faces.AbstractFacesTest;
-
-public class UIRangedNumberInputTest extends AbstractFacesTest {
- private UIRangedNumberInput input;
-
- public void setUp() throws Exception {
- super.setUp();
- setupFacesRequest();
- input = new UIRangedNumberInput() {
- private String minValue;
- private String maxValue;
- private boolean disabled;
- public String getMinValue() {
- return minValue;
- }
- public void setMinValue(String minValue) {
- this.minValue = minValue;
- }
- public String getMaxValue() {
- return maxValue;
- }
- public void setMaxValue(String maxValue) {
- this.maxValue = maxValue;
- }
- public boolean isDisabled() {
- return disabled;
- }
- public void setDisabled(boolean disabled) {
- this.disabled = disabled;
- }
- };
- input.setMaxValue("100");
- input.setMinValue("0");
- input.setValid(true);
- }
-
- public void tearDown() throws Exception {
- super.tearDown();
- this.input = null;
- }
-
- private void checkValid() {
- assertTrue(input.isValid());
- assertFalse(facesContext.getMessages().hasNext());
- }
-
- private void checkInvalid() {
- assertFalse(input.isValid());
- assertTrue(facesContext.getMessages().hasNext());
- }
-
- public void testValidateValueFacesContextObject() {
- checkValid();
- input.validateValue(facesContext, new Double(23.45));
- checkValid();
- }
-
- public void testValidateNullValue() throws Exception {
- checkValid();
- input.validateValue(facesContext, null);
- checkValid();
- }
-
- public void testValidateMinValue() throws Exception {
- checkValid();
- input.validateValue(facesContext, new Double(-23.45));
- checkInvalid();
- }
-
- public void testValidateMaxValue() throws Exception {
- checkValid();
- input.validateValue(facesContext, new Double(223.45));
- checkInvalid();
- }
-
- public void testValidateMinNullMinValue() throws Exception {
- input.setMinValue(null);
- checkValid();
- input.validateValue(facesContext, new Double(-23.45));
- checkInvalid();
- }
-
- public void testValidateMaxNullMaxValue() throws Exception {
- input.setMaxValue(null);
- checkValid();
- input.validateValue(facesContext, new Double(223.45));
- checkInvalid();
- }
-
- public void testValidateIllegalValue() throws Exception {
- checkValid();
- input.validateValue(facesContext, "string");
- checkInvalid();
- }
-}
Deleted: branches/RF-7560/core/impl/src/test/java/org/richfaces/component/util/HtmlUtilTest.java
===================================================================
--- branches/RF-7560/core/impl/src/test/java/org/richfaces/component/util/HtmlUtilTest.java 2010-08-31 17:45:24 UTC (rev 19053)
+++ branches/RF-7560/core/impl/src/test/java/org/richfaces/component/util/HtmlUtilTest.java 2010-08-31 18:46:44 UTC (rev 19054)
@@ -1,112 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces - Ajax4jsf Component Library
- *
- * 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.component.util;
-
-import javax.faces.component.UIComponent;
-import javax.faces.component.UIComponentBase;
-import javax.faces.context.FacesContext;
-
-import junit.framework.TestCase;
-
-/**
- * @author Nick Belaevski - nbelaevski(a)exadel.com
- * created 11.04.2007
- *
- */
-public class HtmlUtilTest extends TestCase {
- public HtmlUtilTest(String name) {
- super(name);
- }
-
- public void setUp() throws Exception {
- super.setUp();
- }
-
- public void tearDown() throws Exception {
- super.tearDown();
- }
-
- public void testQualifySize() throws Exception {
- assertEquals("", HtmlUtil.qualifySize(""));
- assertEquals("100px", HtmlUtil.qualifySize("100px"));
- assertEquals("100px", HtmlUtil.qualifySize("100"));
- assertEquals("100pt", HtmlUtil.qualifySize("100pt"));
- assertEquals("100in", HtmlUtil.qualifySize("100in"));
- assertEquals("100cm", HtmlUtil.qualifySize("100cm"));
- assertEquals("100em", HtmlUtil.qualifySize("100em"));
- assertEquals("100%", HtmlUtil.qualifySize("100%"));
- }
-
- public void testAddToSize() throws Exception {
- assertEquals("120px", HtmlUtil.addToSize("100", "20px"));
- assertEquals("120px", HtmlUtil.addToSize("100px", "20"));
- assertEquals("120px", HtmlUtil.addToSize("100", "20"));
- assertEquals("120px", HtmlUtil.addToSize("100px", "20px"));
- }
-
- public void testExpandIdSelector() {
- String selector = ".class_form+#-Test #form\\:element .class2 #_aaaa";
- UIComponent component = new UIComponentBase() {
- public String getFamily() {
-
- // TODO Auto-generated method stub
- return null;
- }
- public UIComponent findComponent(String expr) {
- if ("-Test".equals(expr)) {
- return new UIComponentBase() {
- public String getClientId(FacesContext context) {
- return "component$1";
- }
- public String getFamily() {
-
- // TODO Auto-generated method stub
- return null;
- }
- };
- } else if ("_aaaa".equals(expr)) {
- return new UIComponentBase() {
- public String getClientId(FacesContext context) {
- return "component2";
- }
- public String getFamily() {
-
- // TODO Auto-generated method stub
- return null;
- }
- };
- }
-
- return null;
- }
- };
- String string = HtmlUtil.expandIdSelector(selector, component, null);
-
- assertEquals(".class_form+#component\\$1 #form\\:element .class2 #component2", string);
-
- String s = ".class_form+.component1 .class2 #1component2";
-
- assertEquals(s, HtmlUtil.expandIdSelector(s, component, null));
- }
-}
Copied: branches/RF-7560/core/impl/src/test/java/org/richfaces/renderkit/util/IdSplitBuilderTest.java (from rev 19052, branches/RF-7560/core/impl/src/test/java/org/ajax4jsf/renderkit/IdSplitBuilderTest.java)
===================================================================
--- branches/RF-7560/core/impl/src/test/java/org/richfaces/renderkit/util/IdSplitBuilderTest.java (rev 0)
+++ branches/RF-7560/core/impl/src/test/java/org/richfaces/renderkit/util/IdSplitBuilderTest.java 2010-08-31 18:46:44 UTC (rev 19054)
@@ -0,0 +1,81 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.renderkit.util;
+
+import static org.junit.Assert.assertArrayEquals;
+
+import org.junit.Test;
+import org.richfaces.renderkit.util.IdSplitBuilder;
+
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class IdSplitBuilderTest {
+
+ private static String[] asArray(String... strings) {
+ return strings;
+ }
+
+ @Test
+ public void testEmptyString() throws Exception {
+ assertArrayEquals(asArray(), IdSplitBuilder.split(""));
+ assertArrayEquals(asArray(), IdSplitBuilder.split(" \r\t\n "));
+ }
+
+ @Test
+ public void testOneStrings() throws Exception {
+ assertArrayEquals(asArray("test"), IdSplitBuilder.split("test"));
+ assertArrayEquals(asArray("some:id"), IdSplitBuilder.split("some:id"));
+ assertArrayEquals(asArray("table:[1]"), IdSplitBuilder.split("table:[1]"));
+ assertArrayEquals(asArray("table:[1, 2]"), IdSplitBuilder.split("table:[1, 2]"));
+ assertArrayEquals(asArray("table:[1, 2]:nestedTable:[*]"), IdSplitBuilder.split("table:[1, 2]:nestedTable:[*]"));
+ assertArrayEquals(asArray("table:[1, 2]:[*]:group"), IdSplitBuilder.split("table:[1, 2]:[*]:group"));
+ assertArrayEquals(asArray("table:[1 2]:nestedTable:[*]"), IdSplitBuilder.split("table:[1 2]:nestedTable:[*]"));
+ assertArrayEquals(asArray("table:[1 2]:[*]:group"), IdSplitBuilder.split("table:[1 2]:[*]:group"));
+ }
+
+ @Test
+ public void testTwoStrings() throws Exception {
+ assertArrayEquals(asArray("test", "abc"), IdSplitBuilder.split("test abc"));
+ assertArrayEquals(asArray("some:id", "form:table"), IdSplitBuilder.split("some:id form:table"));
+ assertArrayEquals(asArray("test", "abc"), IdSplitBuilder.split("test, abc"));
+ assertArrayEquals(asArray("some:id", "form:table"), IdSplitBuilder.split("some:id, form:table"));
+
+ assertArrayEquals(asArray("test:[1 2 3]:abc", "form:[2]"), IdSplitBuilder.split("test:[1 2 3]:abc form:[2]"));
+ assertArrayEquals(asArray("[1 2]:some", "[3\t4]:id"), IdSplitBuilder.split(" [1 2]:some [3\t4]:id "));
+ }
+
+ @Test
+ public void testSeveralStrings() throws Exception {
+ assertArrayEquals(asArray("test", "abc", "def", "ghi"), IdSplitBuilder.split("test abc def ghi"));
+ assertArrayEquals(asArray("test:[1 2]abc", "def", "ghi"), IdSplitBuilder.split("test:[1 2]abc def ghi"));
+ assertArrayEquals(asArray("[1 2]abc", "[3, 4]def", "ghi[5 6 7]"),
+ IdSplitBuilder.split("[1 2]abc [3, 4]def ghi[5 6 7]"));
+
+ assertArrayEquals(
+ asArray("test:[1 2]:abc", "table", "form:table:[ * ]:child", "extTable:[ 0, 3 ]:child:[1 8]:@header"),
+ IdSplitBuilder.split(" test:[1 2]:abc, table," +
+ " form:table:[ * ]:child, extTable:[ 0, 3 ]:child:[1 8]:@header" ));
+ }
+}
Copied: branches/RF-7560/core/impl/src/test/java/org/richfaces/renderkit/util/RendererUtilsTest.java (from rev 19052, branches/RF-7560/core/impl/src/test/java/org/ajax4jsf/renderkit/RendererUtilsTest.java)
===================================================================
--- branches/RF-7560/core/impl/src/test/java/org/richfaces/renderkit/util/RendererUtilsTest.java (rev 0)
+++ branches/RF-7560/core/impl/src/test/java/org/richfaces/renderkit/util/RendererUtilsTest.java 2010-08-31 18:46:44 UTC (rev 19054)
@@ -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.renderkit.util;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.ajax4jsf.javascript.JSFunctionDefinition;
+import org.richfaces.renderkit.util.RendererUtils;
+import org.richfaces.renderkit.util.RendererUtils.ScriptHashVariableWrapper;
+
+/**
+ * @author Nick Belaevski
+ * @since 3.3.2
+ */
+public class RendererUtilsTest extends TestCase {
+ public void testIsEmpty() throws Exception {
+ RendererUtils utils = RendererUtils.getInstance();
+
+ assertTrue(utils.isEmpty(null));
+ assertFalse(utils.isEmpty(new Object()));
+ assertFalse(utils.isEmpty(Boolean.FALSE));
+ assertFalse(utils.isEmpty(Long.valueOf(0)));
+ assertFalse(utils.isEmpty(Integer.valueOf(0)));
+ assertFalse(utils.isEmpty(Short.valueOf((short) 0)));
+ assertFalse(utils.isEmpty(Byte.valueOf((byte) 0)));
+ assertTrue(utils.isEmpty(""));
+ assertFalse(utils.isEmpty("s"));
+ assertTrue(utils.isEmpty(new ArrayList<Object>()));
+ assertTrue(utils.isEmpty(Collections.EMPTY_LIST));
+
+ List<Object> testList = new ArrayList<Object>();
+
+ testList.add("x");
+ assertFalse(utils.isEmpty(testList));
+ assertTrue(utils.isEmpty(new HashMap<String, Object>()));
+ assertTrue(utils.isEmpty(Collections.EMPTY_MAP));
+
+ Map<String, Object> testMap = new HashMap<String, Object>();
+
+ testMap.put("x", "y");
+ assertFalse(utils.isEmpty(testMap));
+ assertTrue(utils.isEmpty(new Object[0]));
+ assertTrue(utils.isEmpty(new int[0]));
+ assertFalse(utils.isEmpty(new Object[1]));
+ assertFalse(utils.isEmpty(new int[1]));
+ }
+
+ public void testScriptHashVariableWrapper() throws Exception {
+ assertEquals("abc", RendererUtils.ScriptHashVariableWrapper.DEFAULT.wrap("abc"));
+
+ Object eventHandler = RendererUtils.ScriptHashVariableWrapper.EVENT_HANDLER.wrap("abc");
+
+ assertTrue(eventHandler instanceof JSFunctionDefinition);
+
+ JSFunctionDefinition handlerFunction = (JSFunctionDefinition) eventHandler;
+
+ assertEquals("function(event){abc}", handlerFunction.toScript().replaceAll("\\s", ""));
+ }
+
+ public void testAddToScriptHash() throws Exception {
+ Map<String, Object> hash = new HashMap<String, Object>();
+ RendererUtils utils = RendererUtils.getInstance();
+
+ utils.addToScriptHash(hash, "x", "y", null, null);
+ assertEquals("y", hash.get("x"));
+ utils.addToScriptHash(hash, "y", "", null, null);
+ assertNull(hash.get("y"));
+ assertFalse(hash.containsKey("y"));
+ utils.addToScriptHash(hash, "y1", null, null, null);
+ assertNull(hash.get("y1"));
+ assertFalse(hash.containsKey("y1"));
+ utils.addToScriptHash(hash, "st", "server", "", null);
+ assertEquals("server", hash.get("st"));
+ utils.addToScriptHash(hash, "st1", "ajax", "ajax", null);
+ assertNull(hash.get("st1"));
+ assertFalse(hash.containsKey("st1"));
+ utils.addToScriptHash(hash, "st2", "", "ajax", null);
+ assertNull(hash.get("st2"));
+ assertFalse(hash.containsKey("st2"));
+ utils.addToScriptHash(hash, "null", null, "server", null);
+ assertNull(hash.get("null"));
+ assertFalse(hash.containsKey("null"));
+ utils.addToScriptHash(hash, "b", false, null, null);
+ assertNull(hash.get("b"));
+ assertFalse(hash.containsKey("b"));
+ utils.addToScriptHash(hash, "b1", true, null, null);
+ assertEquals(Boolean.TRUE, hash.get("b1"));
+ utils.addToScriptHash(hash, "b2", true, "true", null);
+ assertNull(hash.get("b2"));
+ assertFalse(hash.containsKey("b2"));
+ utils.addToScriptHash(hash, "b3", false, "true", null);
+ assertEquals(Boolean.FALSE, hash.get("b3"));
+ utils.addToScriptHash(hash, "b4", true, "false", null);
+ assertEquals(Boolean.TRUE, hash.get("b4"));
+ utils.addToScriptHash(hash, "b5", false, "false", null);
+ assertNull(hash.get("b5"));
+ assertFalse(hash.containsKey("b5"));
+ utils.addToScriptHash(hash, "i", Integer.valueOf(0), null, null);
+ assertEquals(Integer.valueOf(0), hash.get("i"));
+ utils.addToScriptHash(hash, "i1", Integer.valueOf(0), "0", null);
+ assertNull(hash.get("i1"));
+ assertFalse(hash.containsKey("i1"));
+ utils.addToScriptHash(hash, "i2", Integer.valueOf(0), "1", null);
+ assertEquals(Integer.valueOf(0), hash.get("i2"));
+ utils.addToScriptHash(hash, "i3", Integer.MIN_VALUE, null, null);
+ assertNull(hash.get("i3"));
+ assertFalse(hash.containsKey("i3"));
+ utils.addToScriptHash(hash, "i4", Integer.MIN_VALUE, "0", null);
+ assertNull(hash.get("i4"));
+ assertFalse(hash.containsKey("i4"));
+ utils.addToScriptHash(hash, "plain", "test", null, ScriptHashVariableWrapper.DEFAULT);
+ assertEquals("test", hash.get("plain"));
+ utils.addToScriptHash(hash, "plain1", "newtest", "blank", ScriptHashVariableWrapper.DEFAULT);
+ assertEquals("newtest", hash.get("plain1"));
+ utils.addToScriptHash(hash, "onclick", "alert(1)", null, ScriptHashVariableWrapper.EVENT_HANDLER);
+ assertTrue(hash.get("onclick") instanceof JSFunctionDefinition);
+ utils.addToScriptHash(hash, "onclick1", "alert(1)", "no-val", ScriptHashVariableWrapper.EVENT_HANDLER);
+ assertTrue(hash.get("onclick1") instanceof JSFunctionDefinition);
+ }
+}
Modified: branches/RF-7560/examples/input-demo/src/main/webapp/META-INF/MANIFEST.MF
===================================================================
--- branches/RF-7560/examples/input-demo/src/main/webapp/META-INF/MANIFEST.MF 2010-08-31 17:45:24 UTC (rev 19053)
+++ branches/RF-7560/examples/input-demo/src/main/webapp/META-INF/MANIFEST.MF 2010-08-31 18:46:44 UTC (rev 19054)
@@ -1,3 +1,2 @@
Manifest-Version: 1.0
-Class-Path:
Modified: branches/RF-7560/examples/iteration-demo/src/main/webapp/META-INF/MANIFEST.MF
===================================================================
--- branches/RF-7560/examples/iteration-demo/src/main/webapp/META-INF/MANIFEST.MF 2010-08-31 17:45:24 UTC (rev 19053)
+++ branches/RF-7560/examples/iteration-demo/src/main/webapp/META-INF/MANIFEST.MF 2010-08-31 18:46:44 UTC (rev 19054)
@@ -1,3 +1,2 @@
Manifest-Version: 1.0
-Class-Path:
Modified: branches/RF-7560/examples/output-demo/src/main/webapp/META-INF/MANIFEST.MF
===================================================================
--- branches/RF-7560/examples/output-demo/src/main/webapp/META-INF/MANIFEST.MF 2010-08-31 17:45:24 UTC (rev 19053)
+++ branches/RF-7560/examples/output-demo/src/main/webapp/META-INF/MANIFEST.MF 2010-08-31 18:46:44 UTC (rev 19054)
@@ -1,3 +1,2 @@
Manifest-Version: 1.0
-Class-Path:
Modified: branches/RF-7560/ui/common/api/src/main/java/org/richfaces/appplication/FacesMessages.java
===================================================================
--- branches/RF-7560/ui/common/api/src/main/java/org/richfaces/appplication/FacesMessages.java 2010-08-31 17:45:24 UTC (rev 19053)
+++ branches/RF-7560/ui/common/api/src/main/java/org/richfaces/appplication/FacesMessages.java 2010-08-31 18:46:44 UTC (rev 19054)
@@ -22,6 +22,27 @@
package org.richfaces.appplication;
import javax.faces.application.FacesMessage;
+import javax.faces.component.UIInput;
+import javax.faces.component.UISelectMany;
+import javax.faces.component.UISelectOne;
+import javax.faces.convert.BigDecimalConverter;
+import javax.faces.convert.BigIntegerConverter;
+import javax.faces.convert.BooleanConverter;
+import javax.faces.convert.ByteConverter;
+import javax.faces.convert.CharacterConverter;
+import javax.faces.convert.DateTimeConverter;
+import javax.faces.convert.DoubleConverter;
+import javax.faces.convert.EnumConverter;
+import javax.faces.convert.FloatConverter;
+import javax.faces.convert.IntegerConverter;
+import javax.faces.convert.LongConverter;
+import javax.faces.convert.NumberConverter;
+import javax.faces.convert.ShortConverter;
+import javax.faces.validator.BeanValidator;
+import javax.faces.validator.DoubleRangeValidator;
+import javax.faces.validator.LengthValidator;
+import javax.faces.validator.LongRangeValidator;
+import javax.faces.validator.RegexValidator;
import org.richfaces.l10n.MessageBundle;
@@ -32,75 +53,81 @@
@MessageBundle(baseName = FacesMessage.FACES_MESSAGES)
public enum FacesMessages {
- UIINPUT_CONVERSION("javax.faces.component.UIInput.CONVERSION"),
- UIINPUT_REQUIRED("javax.faces.component.UIInput.REQUIRED"),
- UIINPUT_UPDATE("javax.faces.component.UIInput.UPDATE"),
- UISELECTONE_INVALID("javax.faces.component.UISelectOne.INVALID"),
- UISELECTMANY_INVALID("javax.faces.component.UISelectMany.INVALID"),
- BIG_DECIMAL_CONVERTER_DECIMAL("javax.faces.converter.BigDecimalConverter.DECIMAL"),
- BIG_DECIMAL_CONVERTER_DECIMAL_DETAIL("javax.faces.converter.BigDecimalConverter.DECIMAL_detail"),
- BIG_INTEGER_CONVERTER_BIGINTEGER("javax.faces.converter.BigIntegerConverter.BIGINTEGER"),
- BIG_INTEGER_CONVERTER_BIGINTEGER_DETAIL("javax.faces.converter.BigIntegerConverter.BIGINTEGER_detail"),
- BOOLEAN_CONVERTER_BOOLEAN("javax.faces.converter.BooleanConverter.BOOLEAN"),
- BOOLEAN_CONVERTER_BOOLEAN_DETAIL("javax.faces.converter.BooleanConverter.BOOLEAN_detail"),
- BYTE_CONVERTER_BYTE("javax.faces.converter.ByteConverter.BYTE"),
- BYTE_CONVERTER_BYTE_DETAIL("javax.faces.converter.ByteConverter.BYTE_detail"),
- CHARACTER_CONVERTER_CHARACTER("javax.faces.converter.CharacterConverter.CHARACTER"),
- CHARACTER_CONVERTER_CHARACTER_DETAIL("javax.faces.converter.CharacterConverter.CHARACTER_detail"),
- DATE_TIME_CONVERTER_DATE("javax.faces.converter.DateTimeConverter.DATE"),
- DATE_TIME_CONVERTER_DATE_DETAIL("javax.faces.converter.DateTimeConverter.DATE_detail"),
- DATE_TIME_CONVERTER_TIME("javax.faces.converter.DateTimeConverter.TIME"),
- DATE_TIME_CONVERTER_TIME_DETAIL("javax.faces.converter.DateTimeConverter.TIME_detail"),
- DATE_TIME_CONVERTER_DATETIME("javax.faces.converter.DateTimeConverter.DATETIME"),
- DATE_TIME_CONVERTER_DATETIME_DETAIL("javax.faces.converter.DateTimeConverter.DATETIME_detail"),
+ UIINPUT_CONVERSION(UIInput.CONVERSION_MESSAGE_ID),
+ UIINPUT_REQUIRED(UIInput.REQUIRED_MESSAGE_ID),
+ UIINPUT_UPDATE(UIInput.UPDATE_MESSAGE_ID),
+ UISELECTONE_INVALID(UISelectOne.INVALID_MESSAGE_ID),
+ UISELECTMANY_INVALID(UISelectMany.INVALID_MESSAGE_ID),
+ BIG_DECIMAL_CONVERTER_DECIMAL(BigDecimalConverter.DECIMAL_ID),
+ BIG_DECIMAL_CONVERTER_DECIMAL_DETAIL(BigDecimalConverter.DECIMAL_ID, true),
+ BIG_INTEGER_CONVERTER_BIGINTEGER(BigIntegerConverter.BIGINTEGER_ID),
+ BIG_INTEGER_CONVERTER_BIGINTEGER_DETAIL(BigIntegerConverter.BIGINTEGER_ID, true),
+ BOOLEAN_CONVERTER_BOOLEAN(BooleanConverter.BOOLEAN_ID),
+ BOOLEAN_CONVERTER_BOOLEAN_DETAIL(BooleanConverter.BOOLEAN_ID, true),
+ BYTE_CONVERTER_BYTE(ByteConverter.BYTE_ID),
+ BYTE_CONVERTER_BYTE_DETAIL(ByteConverter.BYTE_ID, true),
+ CHARACTER_CONVERTER_CHARACTER(CharacterConverter.CHARACTER_ID),
+ CHARACTER_CONVERTER_CHARACTER_DETAIL(CharacterConverter.CHARACTER_ID, true),
+ DATE_TIME_CONVERTER_DATE(DateTimeConverter.DATE_ID),
+ DATE_TIME_CONVERTER_DATE_DETAIL(DateTimeConverter.DATE_ID, true),
+ DATE_TIME_CONVERTER_TIME(DateTimeConverter.TIME_ID),
+ DATE_TIME_CONVERTER_TIME_DETAIL(DateTimeConverter.TIME_ID, true),
+ DATE_TIME_CONVERTER_DATETIME(DateTimeConverter.DATETIME_ID),
+ DATE_TIME_CONVERTER_DATETIME_DETAIL(DateTimeConverter.DATETIME_ID, true),
DATE_TIME_CONVERTER_PATTERN_TYPE("javax.faces.converter.DateTimeConverter.PATTERN_TYPE"),
- DOUBLE_CONVERTER_DOUBLE("javax.faces.converter.DoubleConverter.DOUBLE"),
- DOUBLE_CONVERTER_DOUBLE_DETAIL("javax.faces.converter.DoubleConverter.DOUBLE_detail"),
- ENUM_CONVERTER_ENUM("javax.faces.converter.EnumConverter.ENUM"),
- ENUM_CONVERTER_ENUM_DETAIL("javax.faces.converter.EnumConverter.ENUM_detail"),
- ENUM_CONVERTER_ENUM_NO_CLASS("javax.faces.converter.EnumConverter.ENUM_NO_CLASS"),
- ENUM_CONVERTER_ENUM_NO_CLASS_DETAIL("javax.faces.converter.EnumConverter.ENUM_NO_CLASS_detail"),
- FLOAT_CONVERTER_FLOAT("javax.faces.converter.FloatConverter.FLOAT"),
- FLOAT_CONVERTER_FLOAT_DETAIL("javax.faces.converter.FloatConverter.FLOAT_detail"),
- INTEGER_CONVERTER_INTEGER("javax.faces.converter.IntegerConverter.INTEGER"),
- INTEGER_CONVERTER_INTEGER_DETAIL("javax.faces.converter.IntegerConverter.INTEGER_detail"),
- LONG_CONVERTER_LONG("javax.faces.converter.LongConverter.LONG"),
- LONG_CONVERTER_LONG_DETAIL("javax.faces.converter.LongConverter.LONG_detail"),
- NUMBER_CONVERTER_CURRENCY("javax.faces.converter.NumberConverter.CURRENCY"),
- NUMBER_CONVERTER_CURRENCY_DETAIL("javax.faces.converter.NumberConverter.CURRENCY_detail"),
- NUMBER_CONVERTER_PERCENT("javax.faces.converter.NumberConverter.PERCENT"),
- NUMBER_CONVERTER_PERCENT_DETAIL("javax.faces.converter.NumberConverter.PERCENT_detail"),
- NUMBER_CONVERTER_NUMBER("javax.faces.converter.NumberConverter.NUMBER"),
- NUMBER_CONVERTER_NUMBER_DETAIL("javax.faces.converter.NumberConverter.NUMBER_detail"),
- NUMBER_CONVERTER_PATTERN("javax.faces.converter.NumberConverter.PATTERN"),
- NUMBER_CONVERTER_PATTERN_DETAIL("javax.faces.converter.NumberConverter.PATTERN_detail"),
- SHORT_CONVERTER_SHORT("javax.faces.converter.ShortConverter.SHORT"),
- SHORT_CONVERTER_SHORT_DETAIL("javax.faces.converter.ShortConverter.SHORT_detail"),
+ DOUBLE_CONVERTER_DOUBLE(DoubleConverter.DOUBLE_ID),
+ DOUBLE_CONVERTER_DOUBLE_DETAIL(DoubleConverter.DOUBLE_ID, true),
+ ENUM_CONVERTER_ENUM(EnumConverter.ENUM_ID),
+ ENUM_CONVERTER_ENUM_DETAIL(EnumConverter.ENUM_ID, true),
+ ENUM_CONVERTER_ENUM_NO_CLASS(EnumConverter.ENUM_NO_CLASS_ID),
+ ENUM_CONVERTER_ENUM_NO_CLASS_DETAIL(EnumConverter.ENUM_NO_CLASS_ID, true),
+ FLOAT_CONVERTER_FLOAT(FloatConverter.FLOAT_ID),
+ FLOAT_CONVERTER_FLOAT_DETAIL(FloatConverter.FLOAT_ID, true),
+ INTEGER_CONVERTER_INTEGER(IntegerConverter.INTEGER_ID),
+ INTEGER_CONVERTER_INTEGER_DETAIL(IntegerConverter.INTEGER_ID, true),
+ LONG_CONVERTER_LONG(LongConverter.LONG_ID),
+ LONG_CONVERTER_LONG_DETAIL(LongConverter.LONG_ID, true),
+ NUMBER_CONVERTER_CURRENCY(NumberConverter.CURRENCY_ID),
+ NUMBER_CONVERTER_CURRENCY_DETAIL(NumberConverter.CURRENCY_ID, true),
+ NUMBER_CONVERTER_PERCENT(NumberConverter.PERCENT_ID),
+ NUMBER_CONVERTER_PERCENT_DETAIL(NumberConverter.PERCENT_ID, true),
+ NUMBER_CONVERTER_NUMBER(NumberConverter.NUMBER_ID),
+ NUMBER_CONVERTER_NUMBER_DETAIL(NumberConverter.NUMBER_ID, true),
+ NUMBER_CONVERTER_PATTERN(NumberConverter.PATTERN_ID),
+ NUMBER_CONVERTER_PATTERN_DETAIL(NumberConverter.PATTERN_ID, true),
+ SHORT_CONVERTER_SHORT(ShortConverter.SHORT_ID),
+ SHORT_CONVERTER_SHORT_DETAIL(ShortConverter.SHORT_ID, true),
CONVERTER_STRING("javax.faces.converter.STRING"),
- DOUBLE_RANGE_VALIDATOR_MAXIMUM("javax.faces.validator.DoubleRangeValidator.MAXIMUM"),
- DOUBLE_RANGE_VALIDATOR_MINIMUM("javax.faces.validator.DoubleRangeValidator.MINIMUM"),
- DOUBLE_RANGE_VALIDATOR_NOT_IN_RANGE("javax.faces.validator.DoubleRangeValidator.NOT_IN_RANGE"),
- DOUBLE_RANGE_VALIDATOR_TYPE("javax.faces.validator.DoubleRangeValidator.TYPE"),
- LENGTH_VALIDATOR_MAXIMUM("javax.faces.validator.LengthValidator.MAXIMUM"),
- LENGTH_VALIDATOR_MINIMUM("javax.faces.validator.LengthValidator.MINIMUM"),
- LONG_RANGE_VALIDATOR_MAXIMUM("javax.faces.validator.LongRangeValidator.MAXIMUM"),
- LONG_RANGE_VALIDATOR_MINIMUM("javax.faces.validator.LongRangeValidator.MINIMUM"),
- LONG_RANGE_VALIDATOR_NOT_IN_RANGE("javax.faces.validator.LongRangeValidator.NOT_IN_RANGE"),
- LONG_RANGE_VALIDATOR_TYPE("javax.faces.validator.LongRangeValidator.TYPE"),
+ DOUBLE_RANGE_VALIDATOR_MAXIMUM(DoubleRangeValidator.MAXIMUM_MESSAGE_ID),
+ DOUBLE_RANGE_VALIDATOR_MINIMUM(DoubleRangeValidator.MINIMUM_MESSAGE_ID),
+ DOUBLE_RANGE_VALIDATOR_NOT_IN_RANGE(DoubleRangeValidator.NOT_IN_RANGE_MESSAGE_ID),
+ DOUBLE_RANGE_VALIDATOR_TYPE(DoubleRangeValidator.TYPE_MESSAGE_ID),
+ LENGTH_VALIDATOR_MAXIMUM(LengthValidator.MAXIMUM_MESSAGE_ID),
+ LENGTH_VALIDATOR_MINIMUM(LengthValidator.MINIMUM_MESSAGE_ID),
+ LONG_RANGE_VALIDATOR_MAXIMUM(LongRangeValidator.MAXIMUM_MESSAGE_ID),
+ LONG_RANGE_VALIDATOR_MINIMUM(LongRangeValidator.MINIMUM_MESSAGE_ID),
+ LONG_RANGE_VALIDATOR_NOT_IN_RANGE(LongRangeValidator.NOT_IN_RANGE_MESSAGE_ID),
+ LONG_RANGE_VALIDATOR_TYPE(LongRangeValidator.TYPE_MESSAGE_ID),
VALIDATOR_NOT_IN_RANGE("javax.faces.validator.NOT_IN_RANGE"),
- REGEX_VALIDATOR_PATTERN_NOT_SET("javax.faces.validator.RegexValidator.PATTERN_NOT_SET"),
- REGEX_VALIDATOR_PATTERN_NOT_SET_DETAIL("javax.faces.validator.RegexValidator.PATTERN_NOT_SET_detail"),
- REGEX_VALIDATOR_NOT_MATCHED("javax.faces.validator.RegexValidator.NOT_MATCHED"),
- REGEX_VALIDATOR_NOT_MATCHED_DETAIL("javax.faces.validator.RegexValidator.NOT_MATCHED_detail"),
- REGEX_VALIDATOR_MATCH_EXCEPTION("javax.faces.validator.RegexValidator.MATCH_EXCEPTION"),
- REGEX_VALIDATOR_MATCH_EXCEPTION_DETAIL("javax.faces.validator.RegexValidator.MATCH_EXCEPTION_detail"),
- BEAN_VALIDATOR_MESSAGE("javax.faces.validator.BeanValidator.MESSAGE");
+ REGEX_VALIDATOR_PATTERN_NOT_SET(RegexValidator.PATTERN_NOT_SET_MESSAGE_ID),
+ REGEX_VALIDATOR_PATTERN_NOT_SET_DETAIL(RegexValidator.PATTERN_NOT_SET_MESSAGE_ID, true),
+ REGEX_VALIDATOR_NOT_MATCHED(RegexValidator.NOT_MATCHED_MESSAGE_ID),
+ REGEX_VALIDATOR_NOT_MATCHED_DETAIL(RegexValidator.NOT_MATCHED_MESSAGE_ID, true),
+ REGEX_VALIDATOR_MATCH_EXCEPTION(RegexValidator.MATCH_EXCEPTION_MESSAGE_ID),
+ REGEX_VALIDATOR_MATCH_EXCEPTION_DETAIL(RegexValidator.MATCH_EXCEPTION_MESSAGE_ID, true),
+ BEAN_VALIDATOR_MESSAGE(BeanValidator.MESSAGE_ID);
+ private static final String DETAIL = "_detail";
+
private String key;
private FacesMessages(String key) {
- this.key = key;
+ this(key, false);
}
+
+ private FacesMessages(String key, boolean isDetail) {
+ this.key = isDetail ? key + DETAIL : key;
+ }
@Override
public String toString() {
Copied: branches/RF-7560/ui/common/ui/src/main/java/org/richfaces/component/UIRangedNumberInput.java (from rev 19052, branches/RF-7560/core/impl/src/main/java/org/richfaces/component/UIRangedNumberInput.java)
===================================================================
--- branches/RF-7560/ui/common/ui/src/main/java/org/richfaces/component/UIRangedNumberInput.java (rev 0)
+++ branches/RF-7560/ui/common/ui/src/main/java/org/richfaces/component/UIRangedNumberInput.java 2010-08-31 18:46:44 UTC (rev 19054)
@@ -0,0 +1,122 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * 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.component;
+
+import javax.faces.application.FacesMessage;
+import javax.faces.component.UIInput;
+import javax.faces.context.FacesContext;
+
+import org.richfaces.component.util.MessageUtil;
+
+/**
+ * @author Nick - mailto:nbelaevski@exadel.com
+ * created 20.02.2007
+ */
+public abstract class UIRangedNumberInput extends UIInput {
+ public abstract String getMaxValue();
+
+ public abstract void setMaxValue(String value);
+
+ public abstract String getMinValue();
+
+ public abstract void setMinValue(String value);
+
+ public abstract boolean isDisabled();
+
+ public abstract void setDisabled(boolean disabled);
+
+ @Override
+ public void decode(FacesContext arg0) {
+ if (this.isDisabled()) {
+ return;
+ }
+
+ super.decode(arg0);
+ }
+
+ @Override
+ protected void validateValue(FacesContext context, Object newValue) {
+ if (isValid() && !isEmpty(newValue)) {
+ String label = MessageUtil.getLabel(context, this).toString();
+ Double minValue = null;
+ Double maxValue = null;
+ Double value = null;
+
+ try {
+ minValue = convert(getMinValue());
+ maxValue = convert(getMaxValue());
+
+ // convert value and check if it is in range
+ value = convert(newValue);
+ } catch (Exception e) {
+ setValid(false);
+
+ FacesMessage mess = new FacesMessage(label + ": " + e.getLocalizedMessage());
+
+ mess.setSeverity(FacesMessage.SEVERITY_ERROR);
+ context.addMessage(this.getClientId(context), mess);
+ }
+
+ if (value != null) {
+ if ((null == minValue) || (null == maxValue)) {
+ setValid(false);
+
+ FacesMessage mess = new FacesMessage(label + ": conversation error, maxValue or minValue is null!");
+
+ mess.setSeverity(FacesMessage.SEVERITY_ERROR);
+ context.addMessage(this.getClientId(context), mess);
+ } else if (minValue.doubleValue() > value.doubleValue()) {
+ setValid(false);
+
+ FacesMessage mess = new FacesMessage(label + ": input value is less than minimal value!");
+
+ mess.setSeverity(FacesMessage.SEVERITY_ERROR);
+ context.addMessage(this.getClientId(context), mess);
+ } else if (maxValue.doubleValue() < value.doubleValue()) {
+ setValid(false);
+
+ FacesMessage mess = new FacesMessage(label + ": input value is more than maximum value!");
+
+ mess.setSeverity(FacesMessage.SEVERITY_ERROR);
+ context.addMessage(this.getClientId(context), mess);
+ }
+ } else {
+ setValid(false);
+
+ FacesMessage mess = new FacesMessage(label + ": input value can't be null!");
+
+ mess.setSeverity(FacesMessage.SEVERITY_ERROR);
+ context.addMessage(this.getClientId(context), mess);
+ }
+ }
+
+ super.validateValue(context, newValue);
+ }
+
+ private Double convert(Object object) {
+ if (object == null) {
+ return null;
+ }
+
+ return new Double(object.toString());
+ }
+}
Copied: branches/RF-7560/ui/common/ui/src/main/java/org/richfaces/component/util/HtmlUtil.java (from rev 19052, branches/RF-7560/core/impl/src/main/java/org/richfaces/component/util/HtmlUtil.java)
===================================================================
--- branches/RF-7560/ui/common/ui/src/main/java/org/richfaces/component/util/HtmlUtil.java (rev 0)
+++ branches/RF-7560/ui/common/ui/src/main/java/org/richfaces/component/util/HtmlUtil.java 2010-08-31 18:46:44 UTC (rev 19054)
@@ -0,0 +1,153 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * 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.component.util;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIViewRoot;
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.javascript.ScriptUtils;
+import org.ajax4jsf.util.HtmlDimensions;
+import org.richfaces.renderkit.util.RendererUtils;
+
+import com.google.common.base.Strings;
+
+/**
+ * @author Nick Belaevski - nbelaevski(a)exadel.com created 09.02.2007
+ */
+public final class HtmlUtil {
+ public static final Pattern ID_SELECTOR_PATTERN =
+ Pattern.compile(
+ "#((?:-[A-Za-z_-]|[A-Za-z_]|\\\\[^A-F0-9U]|\\\\[A-F0-9]{1,6}\\s?|\\\\U[0-9A-F]{2}(?:A[1-9A-F]|[B-F][0-9A-F]))(?:\\\\[A-F0-9]{1,6}\\s?|[A-Za-z0-9_-]|\\\\:)*)");
+ private static final String ORG_AJAX4JSF = "org.ajax4jsf.";
+ private static final String ORG_RICHFACES = "org.richfaces.";
+
+ private HtmlUtil() {
+ }
+
+ public static String qualifySize(String sizeDeclaration) {
+ String trimmedValue = sizeDeclaration.trim();
+
+ if (trimmedValue.length() != 0) {
+ char lastChar = trimmedValue.charAt(trimmedValue.length() - 1);
+
+ if (Character.isDigit(lastChar)) {
+ return sizeDeclaration + "px";
+ }
+ }
+
+ return sizeDeclaration;
+ }
+
+ public static String addToSize(String declaration, String delta) {
+ Double doubleDelta = HtmlDimensions.decode(delta);
+ Double decoded = HtmlDimensions.decode(declaration);
+
+ return HtmlDimensions.formatPx(new Double(decoded.doubleValue() + doubleDelta.doubleValue()));
+ }
+
+ private static String escapeReplacement(String s) {
+ return s.replaceAll("(\\\\|\\$)", "\\\\$1");
+ }
+
+ public static String expandIdSelector(String selector, UIComponent component, FacesContext context) {
+ Matcher matcher = ID_SELECTOR_PATTERN.matcher(selector);
+ StringBuffer sb = new StringBuffer();
+
+ while (matcher.find()) {
+
+ // make new id selector here using matcher.group(1)
+ String unescaped = matcher.group(1).replaceAll("\\\\:", ":");
+ UIComponent target = RendererUtils.getInstance().findComponentFor(context, component, unescaped);
+
+ if (target != null) {
+ matcher.appendReplacement(sb, escapeReplacement("#" + ScriptUtils.escapeCSSMetachars(target.getClientId(context))));
+ }
+ }
+
+ matcher.appendTail(sb);
+
+ return sb.toString();
+ }
+
+ public static String idsToIdSelector(String ids) {
+ StringBuffer buffer = new StringBuffer();
+
+ if (ids != null) {
+ String[] idString = ids.split("\\s*,\\s*");
+
+ for (int i = 0; i < idString.length; i++) {
+ if (i > 0) {
+ buffer.append(",");
+ }
+
+ idString[i] = idString[i].replaceAll(":", "\\\\:");
+ buffer.append("#").append(idString[i]);
+ }
+ }
+
+ return buffer.toString();
+ }
+
+ public static boolean shouldWriteId(UIComponent component) {
+ String rendererType = component.getRendererType();
+ String id = component.getId();
+
+ if ((id != null) && !id.startsWith(UIViewRoot.UNIQUE_ID_PREFIX)) {
+ return true;
+ }
+
+ if ((rendererType != null)
+ && (rendererType.startsWith(ORG_AJAX4JSF) || rendererType.startsWith(ORG_RICHFACES))) {
+ return true;
+ }
+
+ return false;
+ }
+
+ private static String concat(char separator, String... strings) {
+ StringBuilder result = new StringBuilder();
+
+ for (String s : strings) {
+ if (!Strings.isNullOrEmpty(s)) {
+ if (result.length() != 0) {
+ result.append(separator);
+ }
+
+ result.append(s.trim());
+ }
+ }
+
+ return result.toString();
+ }
+
+ public static String concatClasses(String... classes) {
+ return concat(' ', classes);
+ }
+
+ public static String concatStyles(String... styles) {
+ return concat(';', styles);
+ }
+}
Added: branches/RF-7560/ui/common/ui/src/main/java/org/richfaces/component/util/MessageUtil.java
===================================================================
--- branches/RF-7560/ui/common/ui/src/main/java/org/richfaces/component/util/MessageUtil.java (rev 0)
+++ branches/RF-7560/ui/common/ui/src/main/java/org/richfaces/component/util/MessageUtil.java 2010-08-31 18:46:44 UTC (rev 19054)
@@ -0,0 +1,46 @@
+/*
+ * 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.component.util;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+
+import com.google.common.base.Strings;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public final class MessageUtil {
+
+ private MessageUtil() {}
+
+ public static String getLabel(FacesContext context, UIComponent component) {
+ String label = (String) component.getAttributes().get("label");
+
+ if (Strings.isNullOrEmpty(label)) {
+ label = component.getClientId(context);
+ }
+
+ return label;
+ }
+}
Modified: branches/RF-7560/ui/common/ui/src/main/java/org/richfaces/renderkit/RendererBase.java
===================================================================
--- branches/RF-7560/ui/common/ui/src/main/java/org/richfaces/renderkit/RendererBase.java 2010-08-31 17:45:24 UTC (rev 19053)
+++ branches/RF-7560/ui/common/ui/src/main/java/org/richfaces/renderkit/RendererBase.java 2010-08-31 18:46:44 UTC (rev 19054)
@@ -29,9 +29,9 @@
import javax.faces.render.Renderer;
import org.ajax4jsf.Messages;
-import org.ajax4jsf.renderkit.RendererUtils;
import org.richfaces.log.Logger;
import org.richfaces.log.RichfacesLogger;
+import org.richfaces.renderkit.util.RendererUtils;
import org.richfaces.skin.Skin;
import org.richfaces.skin.SkinFactory;
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-08-31 17:45:24 UTC (rev 19053)
+++ branches/RF-7560/ui/common/ui/src/main/java/org/richfaces/renderkit/util/FormUtil.java 2010-08-31 18:46:44 UTC (rev 19054)
@@ -21,7 +21,6 @@
package org.richfaces.renderkit.util;
-import org.ajax4jsf.renderkit.RendererUtils;
import org.richfaces.component.SwitchType;
import javax.faces.component.UIComponent;
Copied: branches/RF-7560/ui/common/ui/src/test/java/org/richfaces/component/UIRangedNumberInputTest.java (from rev 19052, branches/RF-7560/core/impl/src/test/java/org/richfaces/component/UIRangedNumberInputTest.java)
===================================================================
--- branches/RF-7560/ui/common/ui/src/test/java/org/richfaces/component/UIRangedNumberInputTest.java (rev 0)
+++ branches/RF-7560/ui/common/ui/src/test/java/org/richfaces/component/UIRangedNumberInputTest.java 2010-08-31 18:46:44 UTC (rev 19054)
@@ -0,0 +1,120 @@
+/**
+ * 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.component;
+
+import org.jboss.test.faces.AbstractFacesTest;
+
+public class UIRangedNumberInputTest extends AbstractFacesTest {
+ private UIRangedNumberInput input;
+
+ public void setUp() throws Exception {
+ super.setUp();
+ setupFacesRequest();
+ input = new UIRangedNumberInput() {
+ private String minValue;
+ private String maxValue;
+ private boolean disabled;
+ public String getMinValue() {
+ return minValue;
+ }
+ public void setMinValue(String minValue) {
+ this.minValue = minValue;
+ }
+ public String getMaxValue() {
+ return maxValue;
+ }
+ public void setMaxValue(String maxValue) {
+ this.maxValue = maxValue;
+ }
+ public boolean isDisabled() {
+ return disabled;
+ }
+ public void setDisabled(boolean disabled) {
+ this.disabled = disabled;
+ }
+ };
+ input.setMaxValue("100");
+ input.setMinValue("0");
+ input.setValid(true);
+ }
+
+ public void tearDown() throws Exception {
+ super.tearDown();
+ this.input = null;
+ }
+
+ private void checkValid() {
+ assertTrue(input.isValid());
+ assertFalse(facesContext.getMessages().hasNext());
+ }
+
+ private void checkInvalid() {
+ assertFalse(input.isValid());
+ assertTrue(facesContext.getMessages().hasNext());
+ }
+
+ public void testValidateValueFacesContextObject() {
+ checkValid();
+ input.validateValue(facesContext, new Double(23.45));
+ checkValid();
+ }
+
+ public void testValidateNullValue() throws Exception {
+ checkValid();
+ input.validateValue(facesContext, null);
+ checkValid();
+ }
+
+ public void testValidateMinValue() throws Exception {
+ checkValid();
+ input.validateValue(facesContext, new Double(-23.45));
+ checkInvalid();
+ }
+
+ public void testValidateMaxValue() throws Exception {
+ checkValid();
+ input.validateValue(facesContext, new Double(223.45));
+ checkInvalid();
+ }
+
+ public void testValidateMinNullMinValue() throws Exception {
+ input.setMinValue(null);
+ checkValid();
+ input.validateValue(facesContext, new Double(-23.45));
+ checkInvalid();
+ }
+
+ public void testValidateMaxNullMaxValue() throws Exception {
+ input.setMaxValue(null);
+ checkValid();
+ input.validateValue(facesContext, new Double(223.45));
+ checkInvalid();
+ }
+
+ public void testValidateIllegalValue() throws Exception {
+ checkValid();
+ input.validateValue(facesContext, "string");
+ checkInvalid();
+ }
+}
Copied: branches/RF-7560/ui/common/ui/src/test/java/org/richfaces/component/util/HtmlUtilTest.java (from rev 19052, branches/RF-7560/core/impl/src/test/java/org/richfaces/component/util/HtmlUtilTest.java)
===================================================================
--- branches/RF-7560/ui/common/ui/src/test/java/org/richfaces/component/util/HtmlUtilTest.java (rev 0)
+++ branches/RF-7560/ui/common/ui/src/test/java/org/richfaces/component/util/HtmlUtilTest.java 2010-08-31 18:46:44 UTC (rev 19054)
@@ -0,0 +1,112 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * 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.component.util;
+
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIComponentBase;
+import javax.faces.context.FacesContext;
+
+import junit.framework.TestCase;
+
+/**
+ * @author Nick Belaevski - nbelaevski(a)exadel.com
+ * created 11.04.2007
+ *
+ */
+public class HtmlUtilTest extends TestCase {
+ public HtmlUtilTest(String name) {
+ super(name);
+ }
+
+ public void setUp() throws Exception {
+ super.setUp();
+ }
+
+ public void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ public void testQualifySize() throws Exception {
+ assertEquals("", HtmlUtil.qualifySize(""));
+ assertEquals("100px", HtmlUtil.qualifySize("100px"));
+ assertEquals("100px", HtmlUtil.qualifySize("100"));
+ assertEquals("100pt", HtmlUtil.qualifySize("100pt"));
+ assertEquals("100in", HtmlUtil.qualifySize("100in"));
+ assertEquals("100cm", HtmlUtil.qualifySize("100cm"));
+ assertEquals("100em", HtmlUtil.qualifySize("100em"));
+ assertEquals("100%", HtmlUtil.qualifySize("100%"));
+ }
+
+ public void testAddToSize() throws Exception {
+ assertEquals("120px", HtmlUtil.addToSize("100", "20px"));
+ assertEquals("120px", HtmlUtil.addToSize("100px", "20"));
+ assertEquals("120px", HtmlUtil.addToSize("100", "20"));
+ assertEquals("120px", HtmlUtil.addToSize("100px", "20px"));
+ }
+
+ public void testExpandIdSelector() {
+ String selector = ".class_form+#-Test #form\\:element .class2 #_aaaa";
+ UIComponent component = new UIComponentBase() {
+ public String getFamily() {
+
+ // TODO Auto-generated method stub
+ return null;
+ }
+ public UIComponent findComponent(String expr) {
+ if ("-Test".equals(expr)) {
+ return new UIComponentBase() {
+ public String getClientId(FacesContext context) {
+ return "component$1";
+ }
+ public String getFamily() {
+
+ // TODO Auto-generated method stub
+ return null;
+ }
+ };
+ } else if ("_aaaa".equals(expr)) {
+ return new UIComponentBase() {
+ public String getClientId(FacesContext context) {
+ return "component2";
+ }
+ public String getFamily() {
+
+ // TODO Auto-generated method stub
+ return null;
+ }
+ };
+ }
+
+ return null;
+ }
+ };
+ String string = HtmlUtil.expandIdSelector(selector, component, null);
+
+ assertEquals(".class_form+#component\\$1 #form\\:element .class2 #component2", string);
+
+ String s = ".class_form+.component1 .class2 #1component2";
+
+ assertEquals(s, HtmlUtil.expandIdSelector(s, component, null));
+ }
+}
Modified: branches/RF-7560/ui/core/ui/pom.xml
===================================================================
--- branches/RF-7560/ui/core/ui/pom.xml 2010-08-31 17:45:24 UTC (rev 19053)
+++ branches/RF-7560/ui/core/ui/pom.xml 2010-08-31 18:46:44 UTC (rev 19054)
@@ -39,11 +39,6 @@
<artifactId>richfaces-core-api</artifactId>
</dependency>
<dependency>
- <!-- todo remove this dependency or move to test scope -->
- <groupId>org.richfaces.core</groupId>
- <artifactId>richfaces-core-impl</artifactId>
- </dependency>
- <dependency>
<groupId>org.richfaces.ui.common</groupId>
<artifactId>richfaces-ui-common-ui</artifactId>
</dependency>
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-08-31 17:45:24 UTC (rev 19053)
+++ branches/RF-7560/ui/core/ui/src/main/java/org/ajax4jsf/component/behavior/AjaxBehavior.java 2010-08-31 18:46:44 UTC (rev 19054)
@@ -38,10 +38,10 @@
import javax.faces.event.BehaviorEvent;
import org.ajax4jsf.component.AjaxClientBehavior;
-import org.ajax4jsf.renderkit.AjaxRendererUtils;
import org.richfaces.cdk.annotations.JsfBehavior;
import org.richfaces.cdk.annotations.Tag;
import org.richfaces.cdk.annotations.TagType;
+import org.richfaces.renderkit.util.AjaxRendererUtils;
/**
* @author Anton Belevich
Modified: branches/RF-7560/ui/core/ui/src/main/java/org/ajax4jsf/renderkit/AjaxBehaviorRenderer.java
===================================================================
--- branches/RF-7560/ui/core/ui/src/main/java/org/ajax4jsf/renderkit/AjaxBehaviorRenderer.java 2010-08-31 17:45:24 UTC (rev 19053)
+++ branches/RF-7560/ui/core/ui/src/main/java/org/ajax4jsf/renderkit/AjaxBehaviorRenderer.java 2010-08-31 18:46:44 UTC (rev 19054)
@@ -39,6 +39,8 @@
import org.ajax4jsf.component.AjaxClientBehavior;
import org.ajax4jsf.component.behavior.AjaxBehavior;
import org.ajax4jsf.javascript.JSFunction;
+import org.richfaces.renderkit.util.AjaxRendererUtils;
+import org.richfaces.renderkit.util.RendererUtils;
/**
* @author Anton Belevich
Modified: branches/RF-7560/ui/core/ui/src/main/java/org/richfaces/component/AbstractAttachQueue.java
===================================================================
--- branches/RF-7560/ui/core/ui/src/main/java/org/richfaces/component/AbstractAttachQueue.java 2010-08-31 17:45:24 UTC (rev 19053)
+++ branches/RF-7560/ui/core/ui/src/main/java/org/richfaces/component/AbstractAttachQueue.java 2010-08-31 18:46:44 UTC (rev 19054)
@@ -33,12 +33,12 @@
import javax.faces.event.PostAddToViewEvent;
import org.ajax4jsf.component.behavior.AjaxBehavior;
-import org.ajax4jsf.renderkit.AjaxRendererUtils;
import org.richfaces.cdk.annotations.Attribute;
import org.richfaces.cdk.annotations.JsfComponent;
import org.richfaces.cdk.annotations.JsfRenderer;
import org.richfaces.cdk.annotations.Tag;
import org.richfaces.cdk.annotations.TagType;
+import org.richfaces.renderkit.util.AjaxRendererUtils;
/**
* @author Nick Belaevski
Modified: branches/RF-7560/ui/core/ui/src/main/java/org/richfaces/renderkit/AjaxCommandRendererBase.java
===================================================================
--- branches/RF-7560/ui/core/ui/src/main/java/org/richfaces/renderkit/AjaxCommandRendererBase.java 2010-08-31 17:45:24 UTC (rev 19053)
+++ branches/RF-7560/ui/core/ui/src/main/java/org/richfaces/renderkit/AjaxCommandRendererBase.java 2010-08-31 18:46:44 UTC (rev 19054)
@@ -31,7 +31,6 @@
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
-import org.ajax4jsf.renderkit.HandlersChain;
import org.richfaces.log.RichfacesLogger;
import org.richfaces.log.Logger;
Modified: branches/RF-7560/ui/core/ui/src/main/java/org/richfaces/renderkit/AjaxFunctionRendererBase.java
===================================================================
--- branches/RF-7560/ui/core/ui/src/main/java/org/richfaces/renderkit/AjaxFunctionRendererBase.java 2010-08-31 17:45:24 UTC (rev 19053)
+++ branches/RF-7560/ui/core/ui/src/main/java/org/richfaces/renderkit/AjaxFunctionRendererBase.java 2010-08-31 18:46:44 UTC (rev 19054)
@@ -28,7 +28,7 @@
import org.ajax4jsf.javascript.JSReference;
import org.ajax4jsf.javascript.ScriptUtils;
import org.ajax4jsf.renderkit.AjaxEventOptions;
-import org.ajax4jsf.renderkit.AjaxRendererUtils;
+import org.richfaces.renderkit.util.AjaxRendererUtils;
import javax.faces.FacesException;
import javax.faces.component.UIComponent;
Modified: branches/RF-7560/ui/core/ui/src/main/java/org/richfaces/renderkit/html/AjaxOutputPanelRenderer.java
===================================================================
--- branches/RF-7560/ui/core/ui/src/main/java/org/richfaces/renderkit/html/AjaxOutputPanelRenderer.java 2010-08-31 17:45:24 UTC (rev 19053)
+++ branches/RF-7560/ui/core/ui/src/main/java/org/richfaces/renderkit/html/AjaxOutputPanelRenderer.java 2010-08-31 18:46:44 UTC (rev 19054)
@@ -30,10 +30,10 @@
import javax.faces.context.ResponseWriter;
import org.ajax4jsf.context.AjaxContext;
-import org.ajax4jsf.renderkit.RendererUtils.HTML;
import org.richfaces.cdk.annotations.JsfRenderer;
import org.richfaces.component.AbstractOutputPanel;
import org.richfaces.renderkit.RendererBase;
+import org.richfaces.renderkit.util.RendererUtils.HTML;
/**
* @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
Modified: branches/RF-7560/ui/core/ui/src/main/java/org/richfaces/renderkit/html/AjaxPollRenderer.java
===================================================================
--- branches/RF-7560/ui/core/ui/src/main/java/org/richfaces/renderkit/html/AjaxPollRenderer.java 2010-08-31 17:45:24 UTC (rev 19053)
+++ branches/RF-7560/ui/core/ui/src/main/java/org/richfaces/renderkit/html/AjaxPollRenderer.java 2010-08-31 18:46:44 UTC (rev 19054)
@@ -36,11 +36,11 @@
import org.ajax4jsf.javascript.JSFunction;
import org.ajax4jsf.javascript.JSFunctionDefinition;
import org.ajax4jsf.javascript.JSReference;
-import org.ajax4jsf.renderkit.HandlersChain;
-import org.ajax4jsf.renderkit.RendererUtils.HTML;
import org.richfaces.cdk.annotations.JsfRenderer;
import org.richfaces.component.AbstractPoll;
+import org.richfaces.renderkit.HandlersChain;
import org.richfaces.renderkit.RendererBase;
+import org.richfaces.renderkit.util.RendererUtils.HTML;
/**
* @author shura
Modified: branches/RF-7560/ui/core/ui/src/main/java/org/richfaces/renderkit/html/AjaxPushRenderer.java
===================================================================
--- branches/RF-7560/ui/core/ui/src/main/java/org/richfaces/renderkit/html/AjaxPushRenderer.java 2010-08-31 17:45:24 UTC (rev 19053)
+++ branches/RF-7560/ui/core/ui/src/main/java/org/richfaces/renderkit/html/AjaxPushRenderer.java 2010-08-31 18:46:44 UTC (rev 19054)
@@ -35,11 +35,11 @@
import org.ajax4jsf.javascript.JSFunction;
import org.ajax4jsf.javascript.JSFunctionDefinition;
import org.ajax4jsf.javascript.JSReference;
-import org.ajax4jsf.renderkit.HandlersChain;
-import org.ajax4jsf.renderkit.RendererUtils.HTML;
import org.richfaces.cdk.annotations.JsfRenderer;
import org.richfaces.component.AbstractPush;
+import org.richfaces.renderkit.HandlersChain;
import org.richfaces.renderkit.RendererBase;
+import org.richfaces.renderkit.util.RendererUtils.HTML;
import org.richfaces.resource.PushResource;
/**
Modified: branches/RF-7560/ui/core/ui/src/main/java/org/richfaces/renderkit/html/AjaxStatusRenderer.java
===================================================================
--- branches/RF-7560/ui/core/ui/src/main/java/org/richfaces/renderkit/html/AjaxStatusRenderer.java 2010-08-31 17:45:24 UTC (rev 19053)
+++ branches/RF-7560/ui/core/ui/src/main/java/org/richfaces/renderkit/html/AjaxStatusRenderer.java 2010-08-31 18:46:44 UTC (rev 19054)
@@ -32,14 +32,14 @@
import javax.faces.context.ResponseWriter;
import org.ajax4jsf.javascript.JSFunction;
-import org.ajax4jsf.renderkit.HandlersChain;
-import org.ajax4jsf.renderkit.RendererUtils;
-import org.ajax4jsf.renderkit.RendererUtils.HTML;
-import org.ajax4jsf.renderkit.RendererUtils.ScriptHashVariableWrapper;
import org.richfaces.cdk.annotations.JsfRenderer;
import org.richfaces.component.AbstractAjaxStatus;
import org.richfaces.component.util.HtmlUtil;
+import org.richfaces.renderkit.HandlersChain;
import org.richfaces.renderkit.RendererBase;
+import org.richfaces.renderkit.util.RendererUtils;
+import org.richfaces.renderkit.util.RendererUtils.HTML;
+import org.richfaces.renderkit.util.RendererUtils.ScriptHashVariableWrapper;
/**
* @author Nick Belaevski
Modified: branches/RF-7560/ui/core/ui/src/main/java/org/richfaces/renderkit/html/MediaOutputRenderer.java
===================================================================
--- branches/RF-7560/ui/core/ui/src/main/java/org/richfaces/renderkit/html/MediaOutputRenderer.java 2010-08-31 17:45:24 UTC (rev 19053)
+++ branches/RF-7560/ui/core/ui/src/main/java/org/richfaces/renderkit/html/MediaOutputRenderer.java 2010-08-31 18:46:44 UTC (rev 19054)
@@ -34,10 +34,10 @@
import javax.faces.context.ResponseWriter;
import org.ajax4jsf.Messages;
-import org.ajax4jsf.renderkit.RendererUtils.HTML;
import org.richfaces.cdk.annotations.JsfRenderer;
import org.richfaces.component.AbstractMediaOutput;
import org.richfaces.renderkit.RendererBase;
+import org.richfaces.renderkit.util.RendererUtils.HTML;
/**
* @author shura
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-08-31 17:45:24 UTC (rev 19053)
+++ branches/RF-7560/ui/core/ui/src/main/java/org/richfaces/renderkit/html/QueueRenderer.java 2010-08-31 18:46:44 UTC (rev 19054)
@@ -25,9 +25,9 @@
import javax.faces.component.UIForm;
import javax.faces.context.FacesContext;
-import org.ajax4jsf.renderkit.RendererUtils;
import org.richfaces.cdk.annotations.JsfRenderer;
import org.richfaces.component.AbstractQueue;
+import org.richfaces.renderkit.util.RendererUtils;
/**
* @author Nick Belaevski Renderer for queue component
Modified: branches/RF-7560/ui/core/ui/src/main/java/org/richfaces/renderkit/html/QueueResourceComponentRenderer.java
===================================================================
--- branches/RF-7560/ui/core/ui/src/main/java/org/richfaces/renderkit/html/QueueResourceComponentRenderer.java 2010-08-31 17:45:24 UTC (rev 19053)
+++ branches/RF-7560/ui/core/ui/src/main/java/org/richfaces/renderkit/html/QueueResourceComponentRenderer.java 2010-08-31 18:46:44 UTC (rev 19054)
@@ -35,10 +35,10 @@
import javax.faces.render.Renderer;
import org.ajax4jsf.javascript.ScriptUtils;
-import org.ajax4jsf.renderkit.RendererUtils;
-import org.ajax4jsf.renderkit.RendererUtils.HTML;
import org.richfaces.cdk.annotations.JsfRenderer;
import org.richfaces.component.QueueRegistry;
+import org.richfaces.renderkit.util.RendererUtils;
+import org.richfaces.renderkit.util.RendererUtils.HTML;
/**
* @author Nick Belaevski
Modified: branches/RF-7560/ui/core/ui/src/test/java/org/richfaces/component/RegionTest.java
===================================================================
--- branches/RF-7560/ui/core/ui/src/test/java/org/richfaces/component/RegionTest.java 2010-08-31 17:45:24 UTC (rev 19053)
+++ branches/RF-7560/ui/core/ui/src/test/java/org/richfaces/component/RegionTest.java 2010-08-31 18:46:44 UTC (rev 19054)
@@ -36,12 +36,12 @@
import javax.faces.component.UIViewRoot;
import javax.faces.context.FacesContext;
-import org.ajax4jsf.renderkit.AjaxRendererUtils;
import org.jboss.test.faces.FacesEnvironment;
import org.jboss.test.faces.FacesEnvironment.FacesRequest;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+import org.richfaces.renderkit.util.AjaxRendererUtils;
Modified: branches/RF-7560/ui/core/ui/src/test/java/org/richfaces/view/facelets/html/AttachQueueHandlerTest.java
===================================================================
--- branches/RF-7560/ui/core/ui/src/test/java/org/richfaces/view/facelets/html/AttachQueueHandlerTest.java 2010-08-31 17:45:24 UTC (rev 19053)
+++ branches/RF-7560/ui/core/ui/src/test/java/org/richfaces/view/facelets/html/AttachQueueHandlerTest.java 2010-08-31 18:46:44 UTC (rev 19054)
@@ -38,13 +38,13 @@
import javax.faces.view.ViewDeclarationLanguage;
import org.ajax4jsf.component.behavior.AjaxBehavior;
-import org.ajax4jsf.renderkit.AjaxRendererUtils;
import org.jboss.test.faces.FacesEnvironment;
import org.jboss.test.faces.FacesEnvironment.FacesRequest;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.richfaces.component.AbstractAttachQueue;
+import org.richfaces.renderkit.util.AjaxRendererUtils;
/**
Modified: branches/RF-7560/ui/dist/richfaces-components-api/pom.xml
===================================================================
--- branches/RF-7560/ui/dist/richfaces-components-api/pom.xml 2010-08-31 17:45:24 UTC (rev 19053)
+++ branches/RF-7560/ui/dist/richfaces-components-api/pom.xml 2010-08-31 18:46:44 UTC (rev 19054)
@@ -67,10 +67,6 @@
<artifactId>richfaces-core-api</artifactId>
</dependency>
<dependency>
- <groupId>org.richfaces.core</groupId>
- <artifactId>richfaces-core-impl</artifactId>
- </dependency>
- <dependency>
<groupId>javax.el</groupId>
<artifactId>el-api</artifactId>
</dependency>
Modified: branches/RF-7560/ui/dist/richfaces-components-ui/pom.xml
===================================================================
--- branches/RF-7560/ui/dist/richfaces-components-ui/pom.xml 2010-08-31 17:45:24 UTC (rev 19053)
+++ branches/RF-7560/ui/dist/richfaces-components-ui/pom.xml 2010-08-31 18:46:44 UTC (rev 19054)
@@ -76,10 +76,6 @@
<artifactId>richfaces-core-api</artifactId>
</dependency>
<dependency>
- <groupId>org.richfaces.core</groupId>
- <artifactId>richfaces-core-impl</artifactId>
- </dependency>
- <dependency>
<groupId>javax.el</groupId>
<artifactId>el-api</artifactId>
</dependency>
Modified: branches/RF-7560/ui/input/ui/pom.xml
===================================================================
--- branches/RF-7560/ui/input/ui/pom.xml 2010-08-31 17:45:24 UTC (rev 19053)
+++ branches/RF-7560/ui/input/ui/pom.xml 2010-08-31 18:46:44 UTC (rev 19054)
@@ -50,11 +50,6 @@
<artifactId>richfaces-core-api</artifactId>
</dependency>
<dependency>
- <!-- todo remove this dependency or move to test scope -->
- <groupId>org.richfaces.core</groupId>
- <artifactId>richfaces-core-impl</artifactId>
- </dependency>
- <dependency>
<groupId>org.richfaces.ui.common</groupId>
<artifactId>richfaces-ui-common-ui</artifactId>
</dependency>
Modified: branches/RF-7560/ui/input/ui/src/main/java/org/richfaces/renderkit/AutocompleteDivLayoutStrategy.java
===================================================================
--- branches/RF-7560/ui/input/ui/src/main/java/org/richfaces/renderkit/AutocompleteDivLayoutStrategy.java 2010-08-31 17:45:24 UTC (rev 19053)
+++ branches/RF-7560/ui/input/ui/src/main/java/org/richfaces/renderkit/AutocompleteDivLayoutStrategy.java 2010-08-31 18:46:44 UTC (rev 19054)
@@ -28,7 +28,7 @@
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
-import org.ajax4jsf.renderkit.RendererUtils.HTML;
+import org.richfaces.renderkit.util.RendererUtils.HTML;
public class AutocompleteDivLayoutStrategy extends AbstractAutocompleteLayoutStrategy implements
AutocompleteEncodeStrategy {
Modified: branches/RF-7560/ui/input/ui/src/main/java/org/richfaces/renderkit/AutocompleteListLayoutStrategy.java
===================================================================
--- branches/RF-7560/ui/input/ui/src/main/java/org/richfaces/renderkit/AutocompleteListLayoutStrategy.java 2010-08-31 17:45:24 UTC (rev 19053)
+++ branches/RF-7560/ui/input/ui/src/main/java/org/richfaces/renderkit/AutocompleteListLayoutStrategy.java 2010-08-31 18:46:44 UTC (rev 19054)
@@ -6,7 +6,7 @@
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
-import org.ajax4jsf.renderkit.RendererUtils.HTML;
+import org.richfaces.renderkit.util.RendererUtils.HTML;
public class AutocompleteListLayoutStrategy extends AbstractAutocompleteLayoutStrategy implements
AutocompleteEncodeStrategy {
Modified: branches/RF-7560/ui/input/ui/src/main/java/org/richfaces/renderkit/AutocompleteRendererBase.java
===================================================================
--- branches/RF-7560/ui/input/ui/src/main/java/org/richfaces/renderkit/AutocompleteRendererBase.java 2010-08-31 17:45:24 UTC (rev 19053)
+++ branches/RF-7560/ui/input/ui/src/main/java/org/richfaces/renderkit/AutocompleteRendererBase.java 2010-08-31 18:46:44 UTC (rev 19054)
@@ -47,12 +47,12 @@
import org.ajax4jsf.context.AjaxContext;
import org.ajax4jsf.javascript.ScriptUtils;
-import org.ajax4jsf.renderkit.RendererUtils;
-import org.ajax4jsf.renderkit.RendererUtils.HTML;
import org.ajax4jsf.util.InputUtils;
import org.richfaces.component.AbstractAutocomplete;
import org.richfaces.component.AutocompleteLayout;
import org.richfaces.component.MetaComponentResolver;
+import org.richfaces.renderkit.util.RendererUtils;
+import org.richfaces.renderkit.util.RendererUtils.HTML;
import com.google.common.base.Predicates;
import com.google.common.collect.Iterators;
Modified: branches/RF-7560/ui/input/ui/src/main/java/org/richfaces/renderkit/AutocompleteTableLayoutStrategy.java
===================================================================
--- branches/RF-7560/ui/input/ui/src/main/java/org/richfaces/renderkit/AutocompleteTableLayoutStrategy.java 2010-08-31 17:45:24 UTC (rev 19053)
+++ branches/RF-7560/ui/input/ui/src/main/java/org/richfaces/renderkit/AutocompleteTableLayoutStrategy.java 2010-08-31 18:46:44 UTC (rev 19054)
@@ -6,7 +6,7 @@
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
-import org.ajax4jsf.renderkit.RendererUtils.HTML;
+import org.richfaces.renderkit.util.RendererUtils.HTML;
public class AutocompleteTableLayoutStrategy extends AbstractAutocompleteLayoutStrategy implements
AutocompleteEncodeStrategy {
Modified: branches/RF-7560/ui/input/ui/src/main/java/org/richfaces/renderkit/InplaceInputBaseRenderer.java
===================================================================
--- branches/RF-7560/ui/input/ui/src/main/java/org/richfaces/renderkit/InplaceInputBaseRenderer.java 2010-08-31 17:45:24 UTC (rev 19053)
+++ branches/RF-7560/ui/input/ui/src/main/java/org/richfaces/renderkit/InplaceInputBaseRenderer.java 2010-08-31 18:46:44 UTC (rev 19054)
@@ -35,10 +35,10 @@
import javax.faces.context.ResponseWriter;
import org.ajax4jsf.javascript.JSFunction;
-import org.ajax4jsf.renderkit.RendererUtils.HTML;
import org.richfaces.component.AbstractInplaceInput;
import org.richfaces.component.InplaceState;
import org.richfaces.component.util.HtmlUtil;
+import org.richfaces.renderkit.util.RendererUtils.HTML;
/**
* @author Anton Belevich
Modified: branches/RF-7560/ui/input/ui/src/test/java/org/richfaces/renderkit/InplaceInputRendererTest.java
===================================================================
--- branches/RF-7560/ui/input/ui/src/test/java/org/richfaces/renderkit/InplaceInputRendererTest.java 2010-08-31 17:45:24 UTC (rev 19053)
+++ branches/RF-7560/ui/input/ui/src/test/java/org/richfaces/renderkit/InplaceInputRendererTest.java 2010-08-31 18:46:44 UTC (rev 19054)
@@ -27,11 +27,11 @@
import java.io.File;
import java.util.List;
-import org.ajax4jsf.renderkit.RendererUtils.HTML;
import org.jboss.test.faces.htmlunit.HtmlUnitEnvironment;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+import org.richfaces.renderkit.util.RendererUtils.HTML;
import com.gargoylesoftware.htmlunit.html.DomNode;
import com.gargoylesoftware.htmlunit.html.DomText;
Modified: branches/RF-7560/ui/iteration/ui/src/main/java/org/richfaces/DataScrollerUtils.java
===================================================================
--- branches/RF-7560/ui/iteration/ui/src/main/java/org/richfaces/DataScrollerUtils.java 2010-08-31 17:45:24 UTC (rev 19053)
+++ branches/RF-7560/ui/iteration/ui/src/main/java/org/richfaces/DataScrollerUtils.java 2010-08-31 18:46:44 UTC (rev 19054)
@@ -34,9 +34,9 @@
import javax.faces.component.UIComponent;
import javax.faces.component.UIData;
-import org.ajax4jsf.renderkit.RendererUtils;
import org.richfaces.component.AbstractDataScroller;
import org.richfaces.component.UIDataAdaptor;
+import org.richfaces.renderkit.util.RendererUtils;
public final class DataScrollerUtils {
Modified: branches/RF-7560/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractDataScroller.java
===================================================================
--- branches/RF-7560/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractDataScroller.java 2010-08-31 17:45:24 UTC (rev 19053)
+++ branches/RF-7560/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractDataScroller.java 2010-08-31 18:46:44 UTC (rev 19054)
@@ -31,13 +31,15 @@
import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
import javax.faces.component.UIComponentBase;
-import javax.faces.component.UIInput;
import javax.faces.context.FacesContext;
import javax.faces.event.AbortProcessingException;
import javax.faces.event.FacesEvent;
import org.ajax4jsf.component.IterationStateHolder;
import org.richfaces.DataScrollerUtils;
+import org.richfaces.application.MessageFactory;
+import org.richfaces.application.ServiceTracker;
+import org.richfaces.appplication.FacesMessages;
import org.richfaces.cdk.annotations.Attribute;
import org.richfaces.cdk.annotations.JsfComponent;
import org.richfaces.cdk.annotations.JsfRenderer;
@@ -295,6 +297,10 @@
return 1;
}
+ private MessageFactory getMessageFactory(FacesContext context) {
+ return ServiceTracker.getService(MessageFactory.class);
+ }
+
private void updateModel(int newPage) {
FacesContext facesContext = getFacesContext();
@@ -321,8 +327,9 @@
}
FacesMessage message;
if (null == messageStr) {
- message = MessageUtil.getMessage(facesContext, UIInput.UPDATE_MESSAGE_ID,
- new Object[] {MessageUtil.getLabel(facesContext, this) });
+ message = ServiceTracker.getService(MessageFactory.class).createMessage(facesContext,
+ FacesMessages.UIINPUT_UPDATE,
+ MessageUtil.getLabel(facesContext, this));
} else {
message = new FacesMessage(FacesMessage.SEVERITY_ERROR, messageStr, messageStr);
}
@@ -330,14 +337,16 @@
facesContext.addMessage(getClientId(facesContext), message);
facesContext.renderResponse();
} catch (IllegalArgumentException e) {
- FacesMessage message = MessageUtil.getMessage(facesContext, UIInput.UPDATE_MESSAGE_ID,
- new Object[] {MessageUtil.getLabel(facesContext, this) });
+ FacesMessage message = ServiceTracker.getService(MessageFactory.class).createMessage(facesContext,
+ FacesMessages.UIINPUT_UPDATE,
+ MessageUtil.getLabel(facesContext, this));
facesContext.getExternalContext().log(message.getSummary(), e);
facesContext.addMessage(getClientId(facesContext), message);
facesContext.renderResponse();
} catch (Exception e) {
- FacesMessage message = MessageUtil.getMessage(facesContext, UIInput.UPDATE_MESSAGE_ID,
- new Object[] {MessageUtil.getLabel(facesContext, this) });
+ FacesMessage message = ServiceTracker.getService(MessageFactory.class).createMessage(facesContext,
+ FacesMessages.UIINPUT_UPDATE,
+ MessageUtil.getLabel(facesContext, this));
facesContext.getExternalContext().log(message.getSummary(), e);
facesContext.addMessage(getClientId(facesContext), message);
facesContext.renderResponse();
Modified: branches/RF-7560/ui/iteration/ui/src/main/java/org/richfaces/renderkit/AbstractTableBaseRenderer.java
===================================================================
--- branches/RF-7560/ui/iteration/ui/src/main/java/org/richfaces/renderkit/AbstractTableBaseRenderer.java 2010-08-31 17:45:24 UTC (rev 19053)
+++ branches/RF-7560/ui/iteration/ui/src/main/java/org/richfaces/renderkit/AbstractTableBaseRenderer.java 2010-08-31 18:46:44 UTC (rev 19054)
@@ -31,8 +31,8 @@
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
-import org.ajax4jsf.renderkit.RendererUtils.HTML;
import org.richfaces.component.Row;
+import org.richfaces.renderkit.util.RendererUtils.HTML;
/**
Modified: branches/RF-7560/ui/iteration/ui/src/main/java/org/richfaces/renderkit/AbstractTableRenderer.java
===================================================================
--- branches/RF-7560/ui/iteration/ui/src/main/java/org/richfaces/renderkit/AbstractTableRenderer.java 2010-08-31 17:45:24 UTC (rev 19053)
+++ branches/RF-7560/ui/iteration/ui/src/main/java/org/richfaces/renderkit/AbstractTableRenderer.java 2010-08-31 18:46:44 UTC (rev 19054)
@@ -31,10 +31,10 @@
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
-import org.ajax4jsf.renderkit.RendererUtils.HTML;
import org.richfaces.component.Row;
import org.richfaces.component.UIDataTableBase;
import org.richfaces.component.util.HtmlUtil;
+import org.richfaces.renderkit.util.RendererUtils.HTML;
/**
* @author Anton Belevich
Modified: branches/RF-7560/ui/iteration/ui/src/main/java/org/richfaces/renderkit/DataGridRenderer.java
===================================================================
--- branches/RF-7560/ui/iteration/ui/src/main/java/org/richfaces/renderkit/DataGridRenderer.java 2010-08-31 17:45:24 UTC (rev 19053)
+++ branches/RF-7560/ui/iteration/ui/src/main/java/org/richfaces/renderkit/DataGridRenderer.java 2010-08-31 18:46:44 UTC (rev 19054)
@@ -32,11 +32,11 @@
import javax.faces.context.ResponseWriter;
import org.ajax4jsf.model.DataVisitResult;
-import org.ajax4jsf.renderkit.RendererUtils.HTML;
import org.richfaces.cdk.annotations.JsfRenderer;
import org.richfaces.component.AbstractDataGrid;
import org.richfaces.component.Row;
import org.richfaces.component.UIDataTableBase;
+import org.richfaces.renderkit.util.RendererUtils.HTML;
/**
* @author Anton Belevich
Modified: branches/RF-7560/ui/iteration/ui/src/main/java/org/richfaces/renderkit/DataScrollerBaseRenderer.java
===================================================================
--- branches/RF-7560/ui/iteration/ui/src/main/java/org/richfaces/renderkit/DataScrollerBaseRenderer.java 2010-08-31 17:45:24 UTC (rev 19053)
+++ branches/RF-7560/ui/iteration/ui/src/main/java/org/richfaces/renderkit/DataScrollerBaseRenderer.java 2010-08-31 18:46:44 UTC (rev 19054)
@@ -38,10 +38,10 @@
import org.ajax4jsf.javascript.JSLiteral;
import org.ajax4jsf.javascript.JSReference;
import org.ajax4jsf.renderkit.AjaxEventOptions;
-import org.ajax4jsf.renderkit.AjaxRendererUtils;
-import org.ajax4jsf.renderkit.RendererUtils.HTML;
import org.richfaces.component.AbstractDataScroller;
import org.richfaces.event.DataScrollerEvent;
+import org.richfaces.renderkit.util.AjaxRendererUtils;
+import org.richfaces.renderkit.util.RendererUtils.HTML;
@ResourceDependencies( { @ResourceDependency(library = "javax.faces", name = "jsf-uncompressed.js"),
@ResourceDependency(name = "jquery.js"), @ResourceDependency(name = "richfaces.js"),
Modified: branches/RF-7560/ui/iteration/ui/src/main/java/org/richfaces/renderkit/DataTableRenderer.java
===================================================================
--- branches/RF-7560/ui/iteration/ui/src/main/java/org/richfaces/renderkit/DataTableRenderer.java 2010-08-31 17:45:24 UTC (rev 19053)
+++ branches/RF-7560/ui/iteration/ui/src/main/java/org/richfaces/renderkit/DataTableRenderer.java 2010-08-31 18:46:44 UTC (rev 19054)
@@ -36,14 +36,14 @@
import org.ajax4jsf.javascript.JSFunction;
import org.ajax4jsf.renderkit.AjaxEventOptions;
-import org.ajax4jsf.renderkit.AjaxRendererUtils;
-import org.ajax4jsf.renderkit.RendererUtils.HTML;
import org.richfaces.cdk.annotations.JsfRenderer;
import org.richfaces.component.AbstractDataTable;
import org.richfaces.component.AbstractSubTable;
import org.richfaces.component.Row;
import org.richfaces.component.UIDataTableBase;
import org.richfaces.component.util.HtmlUtil;
+import org.richfaces.renderkit.util.AjaxRendererUtils;
+import org.richfaces.renderkit.util.RendererUtils.HTML;
/**
* @author Anton Belevich
Modified: branches/RF-7560/ui/iteration/ui/src/main/java/org/richfaces/renderkit/ExtendedDataTableRenderer.java
===================================================================
--- branches/RF-7560/ui/iteration/ui/src/main/java/org/richfaces/renderkit/ExtendedDataTableRenderer.java 2010-08-31 17:45:24 UTC (rev 19053)
+++ branches/RF-7560/ui/iteration/ui/src/main/java/org/richfaces/renderkit/ExtendedDataTableRenderer.java 2010-08-31 18:46:44 UTC (rev 19054)
@@ -21,9 +21,9 @@
*/
package org.richfaces.renderkit;
-import static org.ajax4jsf.renderkit.AjaxRendererUtils.AJAX_FUNCTION_NAME;
-import static org.ajax4jsf.renderkit.AjaxRendererUtils.buildAjaxFunction;
-import static org.ajax4jsf.renderkit.AjaxRendererUtils.buildEventOptions;
+import static org.richfaces.renderkit.util.AjaxRendererUtils.AJAX_FUNCTION_NAME;
+import static org.richfaces.renderkit.util.AjaxRendererUtils.buildAjaxFunction;
+import static org.richfaces.renderkit.util.AjaxRendererUtils.buildEventOptions;
import java.io.IOException;
import java.util.ArrayList;
@@ -51,15 +51,15 @@
import org.ajax4jsf.model.DataVisitor;
import org.ajax4jsf.model.SequenceRange;
import org.ajax4jsf.renderkit.AjaxEventOptions;
-import org.ajax4jsf.renderkit.RendererUtils;
-import org.ajax4jsf.renderkit.RendererUtils.HTML;
-import org.ajax4jsf.renderkit.RendererUtils.ScriptHashVariableWrapper;
import org.richfaces.cdk.annotations.JsfRenderer;
import org.richfaces.component.AbstractExtendedDataTable;
import org.richfaces.component.UIDataTableBase;
import org.richfaces.component.util.HtmlUtil;
import org.richfaces.context.OnOffResponseWriter;
import org.richfaces.model.SelectionMode;
+import org.richfaces.renderkit.util.RendererUtils;
+import org.richfaces.renderkit.util.RendererUtils.HTML;
+import org.richfaces.renderkit.util.RendererUtils.ScriptHashVariableWrapper;
/**
* @author Konstantin Mishin
Modified: branches/RF-7560/ui/iteration/ui/src/main/java/org/richfaces/renderkit/ListRendererBase.java
===================================================================
--- branches/RF-7560/ui/iteration/ui/src/main/java/org/richfaces/renderkit/ListRendererBase.java 2010-08-31 17:45:24 UTC (rev 19053)
+++ branches/RF-7560/ui/iteration/ui/src/main/java/org/richfaces/renderkit/ListRendererBase.java 2010-08-31 18:46:44 UTC (rev 19054)
@@ -35,13 +35,13 @@
import org.ajax4jsf.model.DataVisitResult;
import org.ajax4jsf.model.DataVisitor;
-import org.ajax4jsf.renderkit.RendererUtils;
-import org.ajax4jsf.renderkit.RendererUtils.HTML;
import org.richfaces.component.AbstractList;
import org.richfaces.component.ListType;
import org.richfaces.component.UISequence;
import org.richfaces.component.util.HtmlUtil;
import org.richfaces.log.RichfacesLogger;
+import org.richfaces.renderkit.util.RendererUtils;
+import org.richfaces.renderkit.util.RendererUtils.HTML;
/**
* @author Nick Belaevski
Modified: branches/RF-7560/ui/iteration/ui/src/main/java/org/richfaces/renderkit/SelectionRenderer.java
===================================================================
--- branches/RF-7560/ui/iteration/ui/src/main/java/org/richfaces/renderkit/SelectionRenderer.java 2010-08-31 17:45:24 UTC (rev 19053)
+++ branches/RF-7560/ui/iteration/ui/src/main/java/org/richfaces/renderkit/SelectionRenderer.java 2010-08-31 18:46:44 UTC (rev 19054)
@@ -33,8 +33,8 @@
import org.ajax4jsf.model.DataVisitResult;
import org.ajax4jsf.model.DataVisitor;
import org.ajax4jsf.model.SequenceRange;
-import org.ajax4jsf.renderkit.RendererUtils.HTML;
import org.richfaces.component.UIDataTableBase;
+import org.richfaces.renderkit.util.RendererUtils.HTML;
/**
* @author Konstantin Mishin
Modified: branches/RF-7560/ui/iteration/ui/src/main/java/org/richfaces/renderkit/SubTableRenderer.java
===================================================================
--- branches/RF-7560/ui/iteration/ui/src/main/java/org/richfaces/renderkit/SubTableRenderer.java 2010-08-31 17:45:24 UTC (rev 19053)
+++ branches/RF-7560/ui/iteration/ui/src/main/java/org/richfaces/renderkit/SubTableRenderer.java 2010-08-31 18:46:44 UTC (rev 19054)
@@ -37,14 +37,14 @@
import javax.faces.event.AbortProcessingException;
import org.ajax4jsf.javascript.JSFunction;
-import org.ajax4jsf.renderkit.AjaxRendererUtils;
-import org.ajax4jsf.renderkit.RendererUtils.HTML;
import org.richfaces.cdk.annotations.JsfRenderer;
import org.richfaces.component.AbstractDataTable;
import org.richfaces.component.AbstractSubTable;
import org.richfaces.component.Row;
import org.richfaces.component.UIDataTableBase;
import org.richfaces.event.ToggleEvent;
+import org.richfaces.renderkit.util.AjaxRendererUtils;
+import org.richfaces.renderkit.util.RendererUtils.HTML;
/**
* @author Anton Belevich
Modified: branches/RF-7560/ui/iteration/ui/src/main/java/org/richfaces/renderkit/SubTableToggleControlRendererBase.java
===================================================================
--- branches/RF-7560/ui/iteration/ui/src/main/java/org/richfaces/renderkit/SubTableToggleControlRendererBase.java 2010-08-31 17:45:24 UTC (rev 19053)
+++ branches/RF-7560/ui/iteration/ui/src/main/java/org/richfaces/renderkit/SubTableToggleControlRendererBase.java 2010-08-31 18:46:44 UTC (rev 19054)
@@ -33,10 +33,10 @@
import javax.faces.context.ResponseWriter;
import org.ajax4jsf.javascript.JSFunction;
-import org.ajax4jsf.renderkit.RendererUtils.HTML;
import org.richfaces.cdk.annotations.JsfRenderer;
import org.richfaces.component.AbstractSubTable;
import org.richfaces.component.AbstractSubTableToggleControl;
+import org.richfaces.renderkit.util.RendererUtils.HTML;
/**
* @author Anton Belevich
Modified: branches/RF-7560/ui/iteration/ui/src/test/java/org/richfaces/renderkit/DataScrollerRenderTest.java
===================================================================
--- branches/RF-7560/ui/iteration/ui/src/test/java/org/richfaces/renderkit/DataScrollerRenderTest.java 2010-08-31 17:45:24 UTC (rev 19053)
+++ branches/RF-7560/ui/iteration/ui/src/test/java/org/richfaces/renderkit/DataScrollerRenderTest.java 2010-08-31 18:46:44 UTC (rev 19054)
@@ -5,11 +5,11 @@
import java.io.File;
import java.util.List;
-import org.ajax4jsf.renderkit.RendererUtils.HTML;
import org.jboss.test.faces.htmlunit.HtmlUnitEnvironment;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+import org.richfaces.renderkit.util.RendererUtils.HTML;
import com.gargoylesoftware.htmlunit.html.DomNode;
import com.gargoylesoftware.htmlunit.html.HtmlElement;
Modified: branches/RF-7560/ui/iteration/ui/src/test/java/org/richfaces/renderkit/ListRendererTest.java
===================================================================
--- branches/RF-7560/ui/iteration/ui/src/test/java/org/richfaces/renderkit/ListRendererTest.java 2010-08-31 17:45:24 UTC (rev 19053)
+++ branches/RF-7560/ui/iteration/ui/src/test/java/org/richfaces/renderkit/ListRendererTest.java 2010-08-31 18:46:44 UTC (rev 19054)
@@ -26,11 +26,11 @@
import java.util.List;
-import org.ajax4jsf.renderkit.RendererUtils.HTML;
import org.jboss.test.faces.htmlunit.HtmlUnitEnvironment;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+import org.richfaces.renderkit.util.RendererUtils.HTML;
import com.gargoylesoftware.htmlunit.html.HtmlElement;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
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-08-31 17:45:24 UTC (rev 19053)
+++ branches/RF-7560/ui/misc/ui/src/main/java/org/richfaces/function/RichFunction.java 2010-08-31 18:46:44 UTC (rev 19054)
@@ -27,9 +27,9 @@
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
-import org.ajax4jsf.renderkit.AjaxRendererUtils;
-import org.ajax4jsf.renderkit.RendererUtils;
import org.richfaces.cdk.annotations.Function;
+import org.richfaces.renderkit.util.AjaxRendererUtils;
+import org.richfaces.renderkit.util.RendererUtils;
/**
* Created 20.03.2008
Modified: branches/RF-7560/ui/misc/ui/src/main/java/org/richfaces/renderkit/ComponentControlBehaviorRenderer.java
===================================================================
--- branches/RF-7560/ui/misc/ui/src/main/java/org/richfaces/renderkit/ComponentControlBehaviorRenderer.java 2010-08-31 17:45:24 UTC (rev 19053)
+++ branches/RF-7560/ui/misc/ui/src/main/java/org/richfaces/renderkit/ComponentControlBehaviorRenderer.java 2010-08-31 18:46:44 UTC (rev 19054)
@@ -43,9 +43,9 @@
import org.ajax4jsf.javascript.JSFunctionDefinition;
import org.ajax4jsf.javascript.JSReference;
import org.ajax4jsf.javascript.ScriptUtils;
-import org.ajax4jsf.renderkit.RendererUtils;
import org.richfaces.component.UIHashParameter;
import org.richfaces.component.behavior.ComponentControlBehavior;
+import org.richfaces.renderkit.util.RendererUtils;
/**
* @author Anton Belevich
Modified: branches/RF-7560/ui/misc/ui/src/main/java/org/richfaces/renderkit/JQueryRendererBase.java
===================================================================
--- branches/RF-7560/ui/misc/ui/src/main/java/org/richfaces/renderkit/JQueryRendererBase.java 2010-08-31 17:45:24 UTC (rev 19053)
+++ branches/RF-7560/ui/misc/ui/src/main/java/org/richfaces/renderkit/JQueryRendererBase.java 2010-08-31 18:46:44 UTC (rev 19054)
@@ -32,11 +32,11 @@
import javax.faces.render.Renderer;
import org.ajax4jsf.javascript.ScriptUtils;
-import org.ajax4jsf.renderkit.RendererUtils;
import org.richfaces.component.AbstractJQuery;
import org.richfaces.component.JQueryAttachType;
import org.richfaces.component.JQueryTiming;
import org.richfaces.component.util.HtmlUtil;
+import org.richfaces.renderkit.util.RendererUtils;
/**
* @author nick
Modified: branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/component/AbstractTogglePanel.java
===================================================================
--- branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/component/AbstractTogglePanel.java 2010-08-31 17:45:24 UTC (rev 19053)
+++ branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/component/AbstractTogglePanel.java 2010-08-31 18:46:44 UTC (rev 19054)
@@ -22,10 +22,9 @@
package org.richfaces.component;
-import org.richfaces.component.util.MessageUtil;
-import org.richfaces.event.ItemChangeEvent;
-import org.richfaces.event.ItemChangeListener;
-import org.richfaces.event.ItemChangeSource;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
import javax.el.ELException;
import javax.el.MethodExpression;
@@ -42,10 +41,15 @@
import javax.faces.event.PhaseId;
import javax.faces.event.PostValidateEvent;
import javax.faces.event.PreValidateEvent;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
+import org.richfaces.application.MessageFactory;
+import org.richfaces.application.ServiceTracker;
+import org.richfaces.appplication.FacesMessages;
+import org.richfaces.component.util.MessageUtil;
+import org.richfaces.event.ItemChangeEvent;
+import org.richfaces.event.ItemChangeListener;
+import org.richfaces.event.ItemChangeSource;
+
/**
* @author akolonitsky
* @version 1.0
@@ -56,9 +60,6 @@
public static final String COMPONENT_FAMILY = "org.richfaces.TogglePanel";
- // TODO What is MessageId ?
- public static final String UPDATE_MESSAGE_ID = "javax.faces.component.UIInput.UPDATE";
-
private String submittedActiveItem = null;
private enum PropertyKeys {
@@ -318,8 +319,9 @@
}
if (messageStr == null) {
- message = MessageUtil.getMessage(context, UPDATE_MESSAGE_ID,
- new Object[] {MessageUtil.getLabel(context, this)});
+ message = ServiceTracker.getService(MessageFactory.class).createMessage(context,
+ FacesMessage.SEVERITY_ERROR,
+ FacesMessages.UIINPUT_UPDATE, MessageUtil.getLabel(context, this));
} else {
message = new FacesMessage(FacesMessage.SEVERITY_ERROR, messageStr, messageStr);
}
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-08-31 17:45:24 UTC (rev 19053)
+++ branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/component/AbstractTogglePanelItem.java 2010-08-31 18:46:44 UTC (rev 19054)
@@ -22,7 +22,7 @@
package org.richfaces.component;
-import org.ajax4jsf.renderkit.RendererUtils;
+import org.richfaces.renderkit.util.RendererUtils;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
Modified: branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/component/behavior/ToggleControl.java
===================================================================
--- branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/component/behavior/ToggleControl.java 2010-08-31 17:45:24 UTC (rev 19053)
+++ branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/component/behavior/ToggleControl.java 2010-08-31 18:46:44 UTC (rev 19054)
@@ -27,8 +27,8 @@
import javax.faces.component.behavior.ClientBehaviorContext;
import org.ajax4jsf.component.behavior.ClientBehavior;
-import org.ajax4jsf.renderkit.RendererUtils;
import org.richfaces.component.AbstractTogglePanel;
+import org.richfaces.renderkit.util.RendererUtils;
/**
* @author akolonitsky
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-08-31 17:45:24 UTC (rev 19053)
+++ branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/renderkit/html/AccordionItemRenderer.java 2010-08-31 18:46:44 UTC (rev 19054)
@@ -23,9 +23,9 @@
package org.richfaces.renderkit.html;
import org.ajax4jsf.javascript.JSObject;
-import org.ajax4jsf.renderkit.RendererUtils;
import org.richfaces.component.AbstractTogglePanelItem;
import org.richfaces.component.AbstractTogglePanelTitledItem;
+import org.richfaces.renderkit.util.RendererUtils;
import javax.faces.application.ResourceDependencies;
import javax.faces.application.ResourceDependency;
Modified: branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/renderkit/html/AccordionRenderer.java
===================================================================
--- branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/renderkit/html/AccordionRenderer.java 2010-08-31 17:45:24 UTC (rev 19053)
+++ branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/renderkit/html/AccordionRenderer.java 2010-08-31 18:46:44 UTC (rev 19054)
@@ -23,9 +23,9 @@
package org.richfaces.renderkit.html;
import org.ajax4jsf.javascript.JSObject;
-import org.ajax4jsf.renderkit.RendererUtils;
import org.richfaces.component.AbstractAccordion;
import org.richfaces.component.util.HtmlUtil;
+import org.richfaces.renderkit.util.RendererUtils;
import javax.faces.application.ResourceDependencies;
import javax.faces.application.ResourceDependency;
Modified: branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/renderkit/html/DivPanelRenderer.java
===================================================================
--- branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/renderkit/html/DivPanelRenderer.java 2010-08-31 17:45:24 UTC (rev 19053)
+++ branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/renderkit/html/DivPanelRenderer.java 2010-08-31 18:46:44 UTC (rev 19054)
@@ -22,10 +22,10 @@
package org.richfaces.renderkit.html;
-import org.ajax4jsf.renderkit.RendererUtils.HTML;
import org.richfaces.component.AbstractDivPanel;
import org.richfaces.renderkit.RenderKitUtils;
import org.richfaces.renderkit.RendererBase;
+import org.richfaces.renderkit.util.RendererUtils.HTML;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
Modified: branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/renderkit/html/PopupPanelBaseRenderer.java
===================================================================
--- branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/renderkit/html/PopupPanelBaseRenderer.java 2010-08-31 17:45:24 UTC (rev 19053)
+++ branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/renderkit/html/PopupPanelBaseRenderer.java 2010-08-31 18:46:44 UTC (rev 19054)
@@ -16,11 +16,11 @@
import javax.faces.context.FacesContext;
import org.ajax4jsf.javascript.ScriptUtils;
-import org.ajax4jsf.renderkit.RendererUtils;
import org.richfaces.component.AbstractPopupPanel;
import org.richfaces.json.JSONException;
import org.richfaces.json.JSONMap;
import org.richfaces.renderkit.RendererBase;
+import org.richfaces.renderkit.util.RendererUtils;
//TODO nick - JSF have concept of library, it should be used instead of '/' in resource names
@ResourceDependencies( { @ResourceDependency(name = "jquery.js"), @ResourceDependency(name = "richfaces.js"),
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-08-31 17:45:24 UTC (rev 19053)
+++ branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/renderkit/html/TogglePanelRenderer.java 2010-08-31 18:46:44 UTC (rev 19054)
@@ -39,13 +39,13 @@
import org.ajax4jsf.javascript.JSObject;
import org.ajax4jsf.javascript.JSReference;
import org.ajax4jsf.renderkit.AjaxEventOptions;
-import org.ajax4jsf.renderkit.AjaxRendererUtils;
-import org.ajax4jsf.renderkit.HandlersChain;
-import org.ajax4jsf.renderkit.RendererUtils.HTML;
import org.richfaces.component.AbstractTogglePanel;
import org.richfaces.component.AbstractTogglePanelItem;
import org.richfaces.component.util.HtmlUtil;
+import org.richfaces.renderkit.HandlersChain;
+import org.richfaces.renderkit.util.AjaxRendererUtils;
import org.richfaces.renderkit.util.FormUtil;
+import org.richfaces.renderkit.util.RendererUtils.HTML;
/**
* @author akolonitsky
14 years, 3 months
JBoss Rich Faces SVN: r19053 - in branches/RF-7560: core and 18 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-08-31 13:45:24 -0400 (Tue, 31 Aug 2010)
New Revision: 19053
Added:
branches/RF-7560/core/api/src/main/java/org/richfaces/application/CoreMessages.java
branches/RF-7560/core/api/src/main/java/org/richfaces/l10n/
branches/RF-7560/core/api/src/main/java/org/richfaces/log/JavaLogger.java
branches/RF-7560/core/api/src/main/java/org/richfaces/log/LogFactory.java
branches/RF-7560/core/api/src/main/java/org/richfaces/log/Logger.java
branches/RF-7560/core/api/src/test/java/org/richfaces/l10n/
branches/RF-7560/core/api/src/test/java/org/richfaces/log/
branches/RF-7560/core/api/src/test/resources/
branches/RF-7560/core/api/src/test/resources/org/
branches/RF-7560/core/api/src/test/resources/org/richfaces/
branches/RF-7560/core/api/src/test/resources/org/richfaces/l10n/
branches/RF-7560/core/api/src/test/resources/org/richfaces/log/
branches/RF-7560/core/impl/src/test/java/org/richfaces/application/FacesMessages.java
branches/RF-7560/core/impl/src/test/resources/org/richfaces/application/FacesMessages.properties
branches/RF-7560/ui/common/api/src/main/java/org/richfaces/appplication/
branches/RF-7560/ui/common/api/src/main/java/org/richfaces/appplication/FacesMessages.java
Removed:
branches/RF-7560/core/commons/
Modified:
branches/RF-7560/bom/pom.xml
branches/RF-7560/core/api/pom.xml
branches/RF-7560/core/impl/pom.xml
branches/RF-7560/core/pom.xml
branches/RF-7560/dist/pom.xml
branches/RF-7560/dist/readme-ui.txt
branches/RF-7560/ui/dist/richfaces-components-api/pom.xml
branches/RF-7560/ui/dist/richfaces-components-ui/pom.xml
branches/RF-7560/ui/output/ui/pom.xml
Log:
RF-7560
Modified: branches/RF-7560/bom/pom.xml
===================================================================
--- branches/RF-7560/bom/pom.xml 2010-08-31 17:20:11 UTC (rev 19052)
+++ branches/RF-7560/bom/pom.xml 2010-08-31 17:45:24 UTC (rev 19053)
@@ -46,11 +46,6 @@
<dependencies>
<!-- Project Versions -->
<dependency>
- <groupId>org.richfaces.commons</groupId>
- <artifactId>richfaces-commons-api</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
<groupId>org.richfaces.core</groupId>
<artifactId>richfaces-core-api</artifactId>
<version>${project.version}</version>
Modified: branches/RF-7560/core/api/pom.xml
===================================================================
--- branches/RF-7560/core/api/pom.xml 2010-08-31 17:20:11 UTC (rev 19052)
+++ branches/RF-7560/core/api/pom.xml 2010-08-31 17:45:24 UTC (rev 19053)
@@ -36,12 +36,6 @@
</description>
<dependencies>
- <!-- Runtime dependencies -->
- <dependency>
- <groupId>org.richfaces.commons</groupId>
- <artifactId>richfaces-commons-api</artifactId>
- </dependency>
-
<!-- Provided dependencies -->
<dependency>
<groupId>javax.el</groupId>
Copied: branches/RF-7560/core/api/src/main/java/org/richfaces/application/CoreMessages.java (from rev 19051, branches/RF-7560/core/commons/src/main/java/org/richfaces/application/CoreMessages.java)
===================================================================
--- branches/RF-7560/core/api/src/main/java/org/richfaces/application/CoreMessages.java (rev 0)
+++ branches/RF-7560/core/api/src/main/java/org/richfaces/application/CoreMessages.java 2010-08-31 17:45:24 UTC (rev 19053)
@@ -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.application;
+
+import org.richfaces.l10n.MessageBundle;
+
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+@MessageBundle(baseName = "org.richfaces.Messages")
+public final class CoreMessages {
+
+ private CoreMessages() {}
+
+}
Copied: branches/RF-7560/core/api/src/main/java/org/richfaces/l10n (from rev 19051, branches/RF-7560/core/commons/src/main/java/org/richfaces/l10n)
Copied: branches/RF-7560/core/api/src/main/java/org/richfaces/log/JavaLogger.java (from rev 19051, branches/RF-7560/core/commons/src/main/java/org/richfaces/log/JavaLogger.java)
===================================================================
--- branches/RF-7560/core/api/src/main/java/org/richfaces/log/JavaLogger.java (rev 0)
+++ branches/RF-7560/core/api/src/main/java/org/richfaces/log/JavaLogger.java 2010-08-31 17:45:24 UTC (rev 19053)
@@ -0,0 +1,253 @@
+/*
+ * $Id: JavaLogger.java 16812 2010-04-26 20:43:19Z alexsmirnov $
+ *
+ * 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.log;
+
+import java.util.EnumMap;
+import java.util.Locale;
+import java.util.Map;
+import java.util.logging.LogRecord;
+
+import org.richfaces.l10n.BundleLoader;
+import org.richfaces.l10n.InterpolationException;
+import org.richfaces.l10n.MessageInterpolator;
+
+
+
+
+/**
+ * <p class="changed_added_4_0">That logger delegates all calls to the JDK {@link java.util.logging.Logger}</p>
+ *
+ * @author asmirnov(a)exadel.com
+ * @author nick
+ */
+public class JavaLogger implements Logger {
+
+ public static final String RICHFACES_LOG = "org.richfaces";
+
+ static final Map<Level, java.util.logging.Level> LEVELS_MAP =
+ new EnumMap<Level, java.util.logging.Level>(Level.class);
+
+ static {
+ LEVELS_MAP.put(Level.ERROR, java.util.logging.Level.SEVERE);
+ LEVELS_MAP.put(Level.INFO, java.util.logging.Level.INFO);
+ LEVELS_MAP.put(Level.WARNING, java.util.logging.Level.WARNING);
+ LEVELS_MAP.put(Level.DEBUG, java.util.logging.Level.FINE);
+ }
+
+ private static final String CLASS_NAME = JavaLogger.class.getName();
+
+ private final java.util.logging.Logger jdkLogger;
+
+ private MessageInterpolator messageInterpolator;
+
+ JavaLogger(String category) {
+ jdkLogger = java.util.logging.Logger.getLogger(category);
+ messageInterpolator = new MessageInterpolator(new BundleLoader());
+ }
+
+ JavaLogger() {
+ this(RICHFACES_LOG);
+ }
+
+ private void fillCallerData(String fqn, LogRecord record) {
+ StackTraceElement[] stackTrace = new Exception().getStackTrace();
+
+ int i = 0;
+
+ for (; i < stackTrace.length; i++) {
+ if (fqn.equals(stackTrace[i].getClassName())) {
+ break;
+ }
+ }
+
+ int idx = i + 1;
+
+ for (; idx < stackTrace.length; idx++) {
+ if (!fqn.equals(stackTrace[idx].getClassName())) {
+ break;
+ }
+ }
+
+ if (idx < stackTrace.length) {
+ record.setSourceMethodName(stackTrace[idx].getMethodName());
+ record.setSourceClassName(stackTrace[idx].getClassName());
+ }
+ }
+
+ private String interpolate(Enum<?> messageKey, Object... args) {
+ try {
+ return messageInterpolator.interpolate(Locale.getDefault(), messageKey, args);
+ } catch (InterpolationException e) {
+ return "???" + e.getMessageKey() + "???";
+ }
+ }
+
+ private LogRecord createRecord(java.util.logging.Level level, CharSequence message, Throwable thrown) {
+ // millis and thread are filled by the constructor
+ LogRecord record = new LogRecord(level, message != null ? message.toString() : null);
+
+ //TODO resource bundle?
+ record.setLoggerName(jdkLogger.getName());
+ record.setThrown(thrown);
+ fillCallerData(CLASS_NAME, record);
+
+ return record;
+ }
+
+ public boolean isDebugEnabled() {
+ return isLogEnabled(Level.DEBUG);
+ }
+
+ public void debug(CharSequence content) {
+ log(Level.DEBUG, content);
+ }
+
+ public void debug(Enum<?> messageKey, Object... args) {
+ log(Level.DEBUG, messageKey, args);
+ }
+
+ public void debug(CharSequence content, Throwable thrown) {
+ log(Level.DEBUG, content, thrown);
+ }
+
+ public void debug(Throwable error, Enum<?> messageKey, Object... args) {
+ log(Level.DEBUG, error, messageKey, args);
+ }
+
+ public void debug(Throwable thrown) {
+ log(Level.DEBUG, thrown);
+ }
+
+ public boolean isInfoEnabled() {
+ return isLogEnabled(Level.INFO);
+ }
+
+ public void info(CharSequence content) {
+ log(Level.INFO, content);
+ }
+
+ public void info(Enum<?> messageKey, Object... args) {
+ log(Level.INFO, messageKey, args);
+ }
+
+ public void info(CharSequence content, Throwable thrown) {
+ log(Level.INFO, content, thrown);
+ }
+
+ public void info(Throwable error, Enum<?> messageKey, Object... args) {
+ log(Level.INFO, error, messageKey, args);
+ }
+
+ public void info(Throwable thrown) {
+ log(Level.INFO, thrown);
+ }
+
+ public boolean isWarnEnabled() {
+ return isLogEnabled(Level.WARNING);
+ }
+
+ public void warn(CharSequence content) {
+ log(Level.WARNING, content);
+ }
+
+ public void warn(Enum<?> messageKey, Object... args) {
+ log(Level.WARNING, messageKey, args);
+ }
+
+ public void warn(CharSequence content, Throwable thrown) {
+ log(Level.WARNING, content, thrown);
+ }
+
+ public void warn(Throwable error, Enum<?> messageKey, Object... args) {
+ log(Level.WARNING, error, messageKey, args);
+ }
+
+ public void warn(Throwable thrown) {
+ log(Level.WARNING, thrown);
+ }
+
+ public boolean isErrorEnabled() {
+ return isLogEnabled(Level.ERROR);
+ }
+
+ public void error(CharSequence content) {
+ log(Level.ERROR, content);
+ }
+
+ public void error(Enum<?> messageKey, Object... args) {
+ log(Level.ERROR, messageKey, args);
+ }
+
+ public void error(CharSequence content, Throwable thrown) {
+ log(Level.ERROR, content, thrown);
+ }
+
+ public void error(Throwable error, Enum<?> messageKey, Object... args) {
+ log(Level.ERROR, error, messageKey, args);
+ }
+
+ public void error(Throwable thrown) {
+ log(Level.ERROR, thrown);
+ }
+
+ public boolean isLogEnabled(Level level) {
+ return jdkLogger.isLoggable(LEVELS_MAP.get(level));
+ }
+
+ public void log(Level level, CharSequence content) {
+ java.util.logging.Level julLevel = LEVELS_MAP.get(level);
+ if (jdkLogger.isLoggable(julLevel)) {
+ jdkLogger.log(createRecord(julLevel, content, null));
+ }
+ }
+
+ public void log(Level level, Enum<?> messageKey, Object... args) {
+ java.util.logging.Level julLevel = LEVELS_MAP.get(level);
+ if (jdkLogger.isLoggable(julLevel)) {
+ jdkLogger.log(createRecord(julLevel, interpolate(messageKey, args), null));
+ }
+ }
+
+ public void log(Level level, CharSequence content, Throwable thrown) {
+ java.util.logging.Level julLevel = LEVELS_MAP.get(level);
+ if (jdkLogger.isLoggable(julLevel)) {
+ jdkLogger.log(createRecord(julLevel, content, thrown));
+ }
+ }
+
+ public void log(Level level, Throwable thrown, Enum<?> messageKey, Object... args) {
+ java.util.logging.Level julLevel = LEVELS_MAP.get(level);
+ if (jdkLogger.isLoggable(julLevel)) {
+ jdkLogger.log(createRecord(julLevel, interpolate(messageKey, args), thrown));
+ }
+ }
+
+ public void log(Level level, Throwable thrown) {
+ java.util.logging.Level julLevel = LEVELS_MAP.get(level);
+ if (jdkLogger.isLoggable(julLevel)) {
+ jdkLogger.log(createRecord(julLevel, null, thrown));
+ }
+ }
+
+}
Copied: branches/RF-7560/core/api/src/main/java/org/richfaces/log/LogFactory.java (from rev 19051, branches/RF-7560/core/commons/src/main/java/org/richfaces/log/LogFactory.java)
===================================================================
--- branches/RF-7560/core/api/src/main/java/org/richfaces/log/LogFactory.java (rev 0)
+++ branches/RF-7560/core/api/src/main/java/org/richfaces/log/LogFactory.java 2010-08-31 17:45:24 UTC (rev 19053)
@@ -0,0 +1,62 @@
+/*
+ * $Id$
+ *
+ * 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.log;
+
+
+/**
+ * <p class="changed_added_4_0">This class produces loggers used by whole RichFaces library.</p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public final class LogFactory {
+
+ private static final Logger DEFAULT_LOGGER = new JavaLogger();
+
+ private LogFactory(){
+ // This class is not instantiable.
+ }
+
+
+ /**
+ * <p class="changed_added_4_0">This method creates default logger.</p>
+ * @return
+ */
+ public static Logger getLogger(){
+ return DEFAULT_LOGGER;
+ }
+
+ /**
+ * <p class="changed_added_4_0">This method produces logger instance for given category.</p>
+ * @param category
+ * @return
+ */
+ public static Logger getLogger(String category){
+ return new JavaLogger(category);
+ }
+
+ public static Logger getLogger(Class<?> clazz){
+ return getLogger(clazz.getName());
+ }
+
+}
Copied: branches/RF-7560/core/api/src/main/java/org/richfaces/log/Logger.java (from rev 19051, branches/RF-7560/core/commons/src/main/java/org/richfaces/log/Logger.java)
===================================================================
--- branches/RF-7560/core/api/src/main/java/org/richfaces/log/Logger.java (rev 0)
+++ branches/RF-7560/core/api/src/main/java/org/richfaces/log/Logger.java 2010-08-31 17:45:24 UTC (rev 19053)
@@ -0,0 +1,311 @@
+/**
+ * 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.log;
+
+/**
+ * That interface hides current logging system from classes. Concrete implementation should provide appropriate logger
+ * instance that delegates messages to the current log system.
+ *
+ * @author shura
+ */
+public interface Logger {
+
+ public enum Level {
+ DEBUG,
+ INFO,
+ WARNING,
+ ERROR
+ }
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @return
+ */
+ public boolean isDebugEnabled();
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param content
+ */
+ public void debug(CharSequence content);
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param messageKey
+ * @param args
+ */
+ public void debug(Enum<?> messageKey, Object... args);
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param content
+ * @param error
+ */
+ public void debug(CharSequence content, Throwable error);
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param error
+ * @param messageKey
+ * @param args
+ */
+ public void debug(Throwable error, Enum<?> messageKey, Object... args);
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param error
+ */
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param error
+ */
+ public void debug(Throwable error);
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @return
+ */
+ public boolean isInfoEnabled();
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param content
+ */
+ public void info(CharSequence content);
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param messageKey
+ * @param args
+ */
+ public void info(Enum<?> messageKey, Object... args);
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param content
+ * @param error
+ */
+ public void info(CharSequence content, Throwable error);
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param error
+ * @param messageKey
+ * @param args
+ */
+ public void info(Throwable error, Enum<?> messageKey, Object... args);
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param error
+ */
+ public void info(Throwable error);
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @return
+ */
+ public boolean isWarnEnabled();
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param content
+ */
+ public void warn(CharSequence content);
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param messageKey
+ * @param args
+ */
+ public void warn(Enum<?> messageKey, Object... args);
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param content
+ * @param error
+ */
+ public void warn(CharSequence content, Throwable error);
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param error
+ * @param messageKey
+ * @param args
+ */
+ public void warn(Throwable error, Enum<?> messageKey, Object... args);
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param error
+ */
+ public void warn(Throwable error);
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @return
+ */
+ public boolean isErrorEnabled();
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param content
+ */
+ public void error(CharSequence content);
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param messageKey
+ * @param args
+ */
+ public void error(Enum<?> messageKey, Object... args);
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param content
+ * @param error
+ */
+ public void error(CharSequence content, Throwable error);
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param error
+ * @param messageKey
+ * @param args
+ */
+ public void error(Throwable error, Enum<?> messageKey, Object... args);
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param error
+ */
+ public void error(Throwable error);
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param level
+ * @return
+ */
+ public boolean isLogEnabled(Level level);
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param level
+ * @param content
+ */
+ public void log(Level level, CharSequence content);
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param level
+ * @param content
+ * @param error
+ */
+ public void log(Level level, CharSequence content, Throwable error);
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param level
+ * @param error
+ */
+ public void log(Level level, Throwable error);
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param level
+ * @param messageKey
+ * @param args
+ */
+ public void log(Level level, Enum<?> messageKey, Object... args);
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param level
+ * @param error
+ * @param messageKey
+ * @param args
+ */
+ public void log(Level level, Throwable error, Enum<?> messageKey, Object... args);
+
+}
Copied: branches/RF-7560/core/api/src/test/java/org/richfaces/l10n (from rev 19051, branches/RF-7560/core/commons/src/test/java/org/richfaces/l10n)
Copied: branches/RF-7560/core/api/src/test/java/org/richfaces/log (from rev 19051, branches/RF-7560/core/commons/src/test/java/org/richfaces/log)
Copied: branches/RF-7560/core/api/src/test/resources/org/richfaces/l10n (from rev 19051, branches/RF-7560/core/commons/src/test/resources/org/richfaces/l10n)
Copied: branches/RF-7560/core/api/src/test/resources/org/richfaces/log (from rev 19051, branches/RF-7560/core/commons/src/test/resources/org/richfaces/log)
Modified: branches/RF-7560/core/impl/pom.xml
===================================================================
--- branches/RF-7560/core/impl/pom.xml 2010-08-31 17:20:11 UTC (rev 19052)
+++ branches/RF-7560/core/impl/pom.xml 2010-08-31 17:45:24 UTC (rev 19053)
@@ -40,10 +40,6 @@
<artifactId>richfaces-core-api</artifactId>
</dependency>
<dependency>
- <groupId>org.richfaces.commons</groupId>
- <artifactId>richfaces-commons-api</artifactId>
- </dependency>
- <dependency>
<groupId>net.sourceforge.cssparser</groupId>
<artifactId>cssparser</artifactId>
</dependency>
Added: branches/RF-7560/core/impl/src/test/java/org/richfaces/application/FacesMessages.java
===================================================================
--- branches/RF-7560/core/impl/src/test/java/org/richfaces/application/FacesMessages.java (rev 0)
+++ branches/RF-7560/core/impl/src/test/java/org/richfaces/application/FacesMessages.java 2010-08-31 17:45:24 UTC (rev 19053)
@@ -0,0 +1,47 @@
+/*
+ * 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.application;
+
+import org.richfaces.l10n.MessageBundle;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+@MessageBundle(baseName = "org.richfaces.application.FacesMessages")
+public enum FacesMessages {
+
+ UIINPUT_CONVERSION("javax.faces.component.UIInput.CONVERSION"),
+ ENUM_CONVERTER_ENUM("javax.faces.converter.EnumConverter.ENUM"),
+ CONVERTER_STRING("javax.faces.converter.STRING");
+
+ private String key;
+
+ private FacesMessages(String key) {
+ this.key = key;
+ }
+
+ @Override
+ public String toString() {
+ return key;
+ }
+}
Added: branches/RF-7560/core/impl/src/test/resources/org/richfaces/application/FacesMessages.properties
===================================================================
--- branches/RF-7560/core/impl/src/test/resources/org/richfaces/application/FacesMessages.properties (rev 0)
+++ branches/RF-7560/core/impl/src/test/resources/org/richfaces/application/FacesMessages.properties 2010-08-31 17:45:24 UTC (rev 19053)
@@ -0,0 +1,4 @@
+javax.faces.component.UIInput.CONVERSION={0}: Conversion error occurred.
+javax.faces.converter.STRING={1}: Could not convert ''{0}'' to a string.
+javax.faces.converter.EnumConverter.ENUM={2}: ''{0}'' must be convertible to an enum.
+javax.faces.converter.EnumConverter.ENUM_detail={2}: ''{0}'' must be convertible to an enum from the enum that contains the constant ''{1}''.
\ No newline at end of file
Modified: branches/RF-7560/core/pom.xml
===================================================================
--- branches/RF-7560/core/pom.xml 2010-08-31 17:20:11 UTC (rev 19052)
+++ branches/RF-7560/core/pom.xml 2010-08-31 17:45:24 UTC (rev 19053)
@@ -38,7 +38,6 @@
<modules>
<module>parent</module>
- <module>commons</module>
<module>api</module>
<module>impl</module>
</modules>
Modified: branches/RF-7560/dist/pom.xml
===================================================================
--- branches/RF-7560/dist/pom.xml 2010-08-31 17:20:11 UTC (rev 19052)
+++ branches/RF-7560/dist/pom.xml 2010-08-31 17:45:24 UTC (rev 19053)
@@ -55,10 +55,6 @@
<groupId>org.richfaces.core</groupId>
<artifactId>richfaces-core-impl</artifactId>
</dependency>
- <dependency>
- <groupId>org.richfaces.commons</groupId>
- <artifactId>richfaces-commons-api</artifactId>
- </dependency>
<!-- Examples -->
<dependency>
@@ -89,7 +85,7 @@
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<configuration>
- <includeGroupIds>org.richfaces.core,org.richfaces.commons,org.richfaces.ui</includeGroupIds>
+ <includeGroupIds>org.richfaces.core,org.richfaces.ui</includeGroupIds>
</configuration>
<executions>
<execution>
Modified: branches/RF-7560/dist/readme-ui.txt
===================================================================
--- branches/RF-7560/dist/readme-ui.txt 2010-08-31 17:20:11 UTC (rev 19052)
+++ branches/RF-7560/dist/readme-ui.txt 2010-08-31 17:45:24 UTC (rev 19053)
@@ -8,14 +8,13 @@
-------------------------------
1) Put RichFaces libraries and its dependencies in your application libraries folder:
- 1.1) richfaces-commons-api-4.0.0.20100824-M2.jar
- 1.2) richfaces-core-api-4.0.0.20100824-M2.jar
- 1.3) richfaces-core-impl-4.0.0.20100824-M2.jar
- 1.4) richfaces-components-api-4.0.0.20100824-M2.jar
- 1.5) richfaces-components-ui-4.0.0.20100824-M2.jar
- 1.6) sac-1.3, cssparser-0.9.5 - required for components CSS work
- 1.7) google-guava-r06 - core runtime dependency.
- 1.8) annotations.jar from org.richfaces.cdk . It's optional and should be added only if some RichFaces components will be
+ 1.1) richfaces-core-api-4.0.0.20100824-M2.jar
+ 1.2) richfaces-core-impl-4.0.0.20100824-M2.jar
+ 1.3) richfaces-components-api-4.0.0.20100824-M2.jar
+ 1.4) richfaces-components-ui-4.0.0.20100824-M2.jar
+ 1.5) sac-1.3, cssparser-0.9.5 - required for components CSS work
+ 1.6) google-guava-r06 - core runtime dependency.
+ 1.7) annotations.jar from org.richfaces.cdk . It's optional and should be added only if some RichFaces components will be
created/accessed dynamically from some appication actions/listeners.
For optimal performance it's recommended to add one of these caching frameworks to application classpath: EhCache, JBoss Cache, OsCache.
Copied: branches/RF-7560/ui/common/api/src/main/java/org/richfaces/appplication/FacesMessages.java (from rev 19051, branches/RF-7560/core/commons/src/main/java/org/richfaces/application/FacesMessages.java)
===================================================================
--- branches/RF-7560/ui/common/api/src/main/java/org/richfaces/appplication/FacesMessages.java (rev 0)
+++ branches/RF-7560/ui/common/api/src/main/java/org/richfaces/appplication/FacesMessages.java 2010-08-31 17:45:24 UTC (rev 19053)
@@ -0,0 +1,109 @@
+/*
+ * 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.appplication;
+
+import javax.faces.application.FacesMessage;
+
+import org.richfaces.l10n.MessageBundle;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+@MessageBundle(baseName = FacesMessage.FACES_MESSAGES)
+public enum FacesMessages {
+
+ UIINPUT_CONVERSION("javax.faces.component.UIInput.CONVERSION"),
+ UIINPUT_REQUIRED("javax.faces.component.UIInput.REQUIRED"),
+ UIINPUT_UPDATE("javax.faces.component.UIInput.UPDATE"),
+ UISELECTONE_INVALID("javax.faces.component.UISelectOne.INVALID"),
+ UISELECTMANY_INVALID("javax.faces.component.UISelectMany.INVALID"),
+ BIG_DECIMAL_CONVERTER_DECIMAL("javax.faces.converter.BigDecimalConverter.DECIMAL"),
+ BIG_DECIMAL_CONVERTER_DECIMAL_DETAIL("javax.faces.converter.BigDecimalConverter.DECIMAL_detail"),
+ BIG_INTEGER_CONVERTER_BIGINTEGER("javax.faces.converter.BigIntegerConverter.BIGINTEGER"),
+ BIG_INTEGER_CONVERTER_BIGINTEGER_DETAIL("javax.faces.converter.BigIntegerConverter.BIGINTEGER_detail"),
+ BOOLEAN_CONVERTER_BOOLEAN("javax.faces.converter.BooleanConverter.BOOLEAN"),
+ BOOLEAN_CONVERTER_BOOLEAN_DETAIL("javax.faces.converter.BooleanConverter.BOOLEAN_detail"),
+ BYTE_CONVERTER_BYTE("javax.faces.converter.ByteConverter.BYTE"),
+ BYTE_CONVERTER_BYTE_DETAIL("javax.faces.converter.ByteConverter.BYTE_detail"),
+ CHARACTER_CONVERTER_CHARACTER("javax.faces.converter.CharacterConverter.CHARACTER"),
+ CHARACTER_CONVERTER_CHARACTER_DETAIL("javax.faces.converter.CharacterConverter.CHARACTER_detail"),
+ DATE_TIME_CONVERTER_DATE("javax.faces.converter.DateTimeConverter.DATE"),
+ DATE_TIME_CONVERTER_DATE_DETAIL("javax.faces.converter.DateTimeConverter.DATE_detail"),
+ DATE_TIME_CONVERTER_TIME("javax.faces.converter.DateTimeConverter.TIME"),
+ DATE_TIME_CONVERTER_TIME_DETAIL("javax.faces.converter.DateTimeConverter.TIME_detail"),
+ DATE_TIME_CONVERTER_DATETIME("javax.faces.converter.DateTimeConverter.DATETIME"),
+ DATE_TIME_CONVERTER_DATETIME_DETAIL("javax.faces.converter.DateTimeConverter.DATETIME_detail"),
+ DATE_TIME_CONVERTER_PATTERN_TYPE("javax.faces.converter.DateTimeConverter.PATTERN_TYPE"),
+ DOUBLE_CONVERTER_DOUBLE("javax.faces.converter.DoubleConverter.DOUBLE"),
+ DOUBLE_CONVERTER_DOUBLE_DETAIL("javax.faces.converter.DoubleConverter.DOUBLE_detail"),
+ ENUM_CONVERTER_ENUM("javax.faces.converter.EnumConverter.ENUM"),
+ ENUM_CONVERTER_ENUM_DETAIL("javax.faces.converter.EnumConverter.ENUM_detail"),
+ ENUM_CONVERTER_ENUM_NO_CLASS("javax.faces.converter.EnumConverter.ENUM_NO_CLASS"),
+ ENUM_CONVERTER_ENUM_NO_CLASS_DETAIL("javax.faces.converter.EnumConverter.ENUM_NO_CLASS_detail"),
+ FLOAT_CONVERTER_FLOAT("javax.faces.converter.FloatConverter.FLOAT"),
+ FLOAT_CONVERTER_FLOAT_DETAIL("javax.faces.converter.FloatConverter.FLOAT_detail"),
+ INTEGER_CONVERTER_INTEGER("javax.faces.converter.IntegerConverter.INTEGER"),
+ INTEGER_CONVERTER_INTEGER_DETAIL("javax.faces.converter.IntegerConverter.INTEGER_detail"),
+ LONG_CONVERTER_LONG("javax.faces.converter.LongConverter.LONG"),
+ LONG_CONVERTER_LONG_DETAIL("javax.faces.converter.LongConverter.LONG_detail"),
+ NUMBER_CONVERTER_CURRENCY("javax.faces.converter.NumberConverter.CURRENCY"),
+ NUMBER_CONVERTER_CURRENCY_DETAIL("javax.faces.converter.NumberConverter.CURRENCY_detail"),
+ NUMBER_CONVERTER_PERCENT("javax.faces.converter.NumberConverter.PERCENT"),
+ NUMBER_CONVERTER_PERCENT_DETAIL("javax.faces.converter.NumberConverter.PERCENT_detail"),
+ NUMBER_CONVERTER_NUMBER("javax.faces.converter.NumberConverter.NUMBER"),
+ NUMBER_CONVERTER_NUMBER_DETAIL("javax.faces.converter.NumberConverter.NUMBER_detail"),
+ NUMBER_CONVERTER_PATTERN("javax.faces.converter.NumberConverter.PATTERN"),
+ NUMBER_CONVERTER_PATTERN_DETAIL("javax.faces.converter.NumberConverter.PATTERN_detail"),
+ SHORT_CONVERTER_SHORT("javax.faces.converter.ShortConverter.SHORT"),
+ SHORT_CONVERTER_SHORT_DETAIL("javax.faces.converter.ShortConverter.SHORT_detail"),
+ CONVERTER_STRING("javax.faces.converter.STRING"),
+ DOUBLE_RANGE_VALIDATOR_MAXIMUM("javax.faces.validator.DoubleRangeValidator.MAXIMUM"),
+ DOUBLE_RANGE_VALIDATOR_MINIMUM("javax.faces.validator.DoubleRangeValidator.MINIMUM"),
+ DOUBLE_RANGE_VALIDATOR_NOT_IN_RANGE("javax.faces.validator.DoubleRangeValidator.NOT_IN_RANGE"),
+ DOUBLE_RANGE_VALIDATOR_TYPE("javax.faces.validator.DoubleRangeValidator.TYPE"),
+ LENGTH_VALIDATOR_MAXIMUM("javax.faces.validator.LengthValidator.MAXIMUM"),
+ LENGTH_VALIDATOR_MINIMUM("javax.faces.validator.LengthValidator.MINIMUM"),
+ LONG_RANGE_VALIDATOR_MAXIMUM("javax.faces.validator.LongRangeValidator.MAXIMUM"),
+ LONG_RANGE_VALIDATOR_MINIMUM("javax.faces.validator.LongRangeValidator.MINIMUM"),
+ LONG_RANGE_VALIDATOR_NOT_IN_RANGE("javax.faces.validator.LongRangeValidator.NOT_IN_RANGE"),
+ LONG_RANGE_VALIDATOR_TYPE("javax.faces.validator.LongRangeValidator.TYPE"),
+ VALIDATOR_NOT_IN_RANGE("javax.faces.validator.NOT_IN_RANGE"),
+ REGEX_VALIDATOR_PATTERN_NOT_SET("javax.faces.validator.RegexValidator.PATTERN_NOT_SET"),
+ REGEX_VALIDATOR_PATTERN_NOT_SET_DETAIL("javax.faces.validator.RegexValidator.PATTERN_NOT_SET_detail"),
+ REGEX_VALIDATOR_NOT_MATCHED("javax.faces.validator.RegexValidator.NOT_MATCHED"),
+ REGEX_VALIDATOR_NOT_MATCHED_DETAIL("javax.faces.validator.RegexValidator.NOT_MATCHED_detail"),
+ REGEX_VALIDATOR_MATCH_EXCEPTION("javax.faces.validator.RegexValidator.MATCH_EXCEPTION"),
+ REGEX_VALIDATOR_MATCH_EXCEPTION_DETAIL("javax.faces.validator.RegexValidator.MATCH_EXCEPTION_detail"),
+ BEAN_VALIDATOR_MESSAGE("javax.faces.validator.BeanValidator.MESSAGE");
+
+ private String key;
+
+ private FacesMessages(String key) {
+ this.key = key;
+ }
+
+ @Override
+ public String toString() {
+ return key;
+ }
+}
Modified: branches/RF-7560/ui/dist/richfaces-components-api/pom.xml
===================================================================
--- branches/RF-7560/ui/dist/richfaces-components-api/pom.xml 2010-08-31 17:20:11 UTC (rev 19052)
+++ branches/RF-7560/ui/dist/richfaces-components-api/pom.xml 2010-08-31 17:45:24 UTC (rev 19053)
@@ -71,10 +71,6 @@
<artifactId>richfaces-core-impl</artifactId>
</dependency>
<dependency>
- <groupId>org.richfaces.commons</groupId>
- <artifactId>richfaces-commons-api</artifactId>
- </dependency>
- <dependency>
<groupId>javax.el</groupId>
<artifactId>el-api</artifactId>
</dependency>
Modified: branches/RF-7560/ui/dist/richfaces-components-ui/pom.xml
===================================================================
--- branches/RF-7560/ui/dist/richfaces-components-ui/pom.xml 2010-08-31 17:20:11 UTC (rev 19052)
+++ branches/RF-7560/ui/dist/richfaces-components-ui/pom.xml 2010-08-31 17:45:24 UTC (rev 19053)
@@ -80,10 +80,6 @@
<artifactId>richfaces-core-impl</artifactId>
</dependency>
<dependency>
- <groupId>org.richfaces.commons</groupId>
- <artifactId>richfaces-commons-api</artifactId>
- </dependency>
- <dependency>
<groupId>javax.el</groupId>
<artifactId>el-api</artifactId>
</dependency>
Modified: branches/RF-7560/ui/output/ui/pom.xml
===================================================================
--- branches/RF-7560/ui/output/ui/pom.xml 2010-08-31 17:20:11 UTC (rev 19052)
+++ branches/RF-7560/ui/output/ui/pom.xml 2010-08-31 17:45:24 UTC (rev 19053)
@@ -57,10 +57,6 @@
<artifactId>richfaces-core-api</artifactId>
</dependency>
<dependency>
- <groupId>org.richfaces.commons</groupId>
- <artifactId>richfaces-commons-api</artifactId>
- </dependency>
- <dependency>
<groupId>org.richfaces.ui.common</groupId>
<artifactId>richfaces-ui-common-ui</artifactId>
</dependency>
14 years, 3 months
JBoss Rich Faces SVN: r19052 - in branches/RF-7560: core/commons/src/test/java/org/richfaces/renderkit and 36 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-08-31 13:20:11 -0400 (Tue, 31 Aug 2010)
New Revision: 19052
Added:
branches/RF-7560/ui/common/api/src/main/java/org/richfaces/component/SequenceIterationStatus.java
branches/RF-7560/ui/common/api/src/main/java/org/richfaces/renderkit/
branches/RF-7560/ui/common/api/src/main/java/org/richfaces/renderkit/util/
branches/RF-7560/ui/common/api/src/main/java/org/richfaces/renderkit/util/EnclosingFormRequiredException.java
branches/RF-7560/ui/common/api/src/test/java/org/
branches/RF-7560/ui/common/api/src/test/java/org/richfaces/
branches/RF-7560/ui/common/api/src/test/java/org/richfaces/component/
branches/RF-7560/ui/common/api/src/test/java/org/richfaces/component/SequenceIterationStatusTest.java
branches/RF-7560/ui/common/ui/src/main/java/org/richfaces/component/RowKeyContextEventWrapper.java
branches/RF-7560/ui/common/ui/src/main/java/org/richfaces/component/SavedState.java
branches/RF-7560/ui/common/ui/src/main/java/org/richfaces/component/UIDataAdaptor.java
branches/RF-7560/ui/common/ui/src/main/java/org/richfaces/component/UISequence.java
branches/RF-7560/ui/common/ui/src/main/java/org/richfaces/renderkit/AjaxChildrenRenderer.java
branches/RF-7560/ui/common/ui/src/main/java/org/richfaces/renderkit/AjaxComponentRendererBase.java
branches/RF-7560/ui/common/ui/src/main/java/org/richfaces/renderkit/ComponentAttribute.java
branches/RF-7560/ui/common/ui/src/main/java/org/richfaces/renderkit/RenderKitUtils.java
branches/RF-7560/ui/common/ui/src/main/java/org/richfaces/renderkit/RendererBase.java
branches/RF-7560/ui/common/ui/src/main/java/org/richfaces/renderkit/SequenceRendererHelper.java
branches/RF-7560/ui/common/ui/src/main/java/org/richfaces/view/facelets/EmptyHandler.java
branches/RF-7560/ui/common/ui/src/main/java/org/richfaces/view/facelets/RowKeyConverterRule.java
branches/RF-7560/ui/common/ui/src/test/java/org/richfaces/component/
branches/RF-7560/ui/common/ui/src/test/java/org/richfaces/component/DataAdaptorTestCase.java
branches/RF-7560/ui/common/ui/src/test/java/org/richfaces/component/MockDataAdaptor.java
branches/RF-7560/ui/common/ui/src/test/java/org/richfaces/component/MockDataAdaptorComponentState.java
branches/RF-7560/ui/common/ui/src/test/java/org/richfaces/renderkit/MockClientBehaviorHolder.java
branches/RF-7560/ui/common/ui/src/test/java/org/richfaces/renderkit/RenderKitUtilsMocksTest.java
branches/RF-7560/ui/common/ui/src/test/java/org/richfaces/renderkit/RenderKitUtilsTest.java
branches/RF-7560/ui/input/ui/src/main/java/org/richfaces/renderkit/InputRendererBase.java
Removed:
branches/RF-7560/core/commons/src/main/java/org/richfaces/renderkit/ComponentAttribute.java
branches/RF-7560/core/commons/src/main/java/org/richfaces/renderkit/RenderKitUtils.java
branches/RF-7560/core/commons/src/test/java/org/richfaces/renderkit/MockClientBehaviorHolder.java
branches/RF-7560/core/commons/src/test/java/org/richfaces/renderkit/RenderKitUtilsMocksTest.java
branches/RF-7560/core/commons/src/test/java/org/richfaces/renderkit/RenderKitUtilsTest.java
branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/exception/
branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/renderkit/AjaxChildrenRenderer.java
branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/renderkit/AjaxComponentRendererBase.java
branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/renderkit/ComponentRendererBase.java
branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/renderkit/ComponentVariables.java
branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/renderkit/ComponentsVariableResolver.java
branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/renderkit/RendererBase.java
branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/resource/cached/
branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/util/style/
branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/webapp/CacheContent.java
branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/webapp/PollEventsManager.java
branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/webapp/taglib/AjaxActionsRule.java
branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/webapp/taglib/EmptyHandler.java
branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/webapp/taglib/RowKeyConverterRule.java
branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/webapp/taglib/package-info.java
branches/RF-7560/core/impl/src/main/java/org/richfaces/component/EnclosingFormRequiredException.java
branches/RF-7560/core/impl/src/main/java/org/richfaces/component/RowKeyContextEventWrapper.java
branches/RF-7560/core/impl/src/main/java/org/richfaces/component/SavedState.java
branches/RF-7560/core/impl/src/main/java/org/richfaces/component/SequenceIterationStatus.java
branches/RF-7560/core/impl/src/main/java/org/richfaces/component/UIDataAdaptor.java
branches/RF-7560/core/impl/src/main/java/org/richfaces/component/UISequence.java
branches/RF-7560/core/impl/src/main/java/org/richfaces/renderkit/CompositeRenderer.java
branches/RF-7560/core/impl/src/main/java/org/richfaces/renderkit/InputRendererBase.java
branches/RF-7560/core/impl/src/main/java/org/richfaces/renderkit/MacroDefinitionJSContentHandler.java
branches/RF-7560/core/impl/src/main/java/org/richfaces/renderkit/RendererContributor.java
branches/RF-7560/core/impl/src/main/java/org/richfaces/renderkit/SequenceRendererHelper.java
branches/RF-7560/core/impl/src/main/java/org/richfaces/renderkit/TemplateEncoderRendererBase.java
branches/RF-7560/core/impl/src/main/java/org/richfaces/webapp/taglib/SimpleComponentTag.java
branches/RF-7560/core/impl/src/main/java/org/richfaces/webapp/taglib/UIComponentELTagBase.java
branches/RF-7560/core/impl/src/main/javacc/
branches/RF-7560/core/impl/src/test/java/org/ajax4jsf/resource/cached/
branches/RF-7560/core/impl/src/test/java/org/richfaces/component/DataAdaptorTestCase.java
branches/RF-7560/core/impl/src/test/java/org/richfaces/component/MockDataAdaptor.java
branches/RF-7560/core/impl/src/test/java/org/richfaces/component/MockDataAdaptorComponentState.java
branches/RF-7560/core/impl/src/test/java/org/richfaces/component/SequenceIterationStatusTest.java
branches/RF-7560/core/impl/src/test/java/org/richfaces/renderkit/CompositeRendererTest.java
branches/RF-7560/core/impl/src/test/java/org/richfaces/renderkit/TemplateEncoderRendererBaseTest.java
branches/RF-7560/core/impl/src/test/java/org/richfaces/renderkit/TemplateUtilTest.java
Modified:
branches/RF-7560/core/impl/pom.xml
branches/RF-7560/core/impl/src/test/java/org/richfaces/context/AjaxTableComponentImpl.java
branches/RF-7560/core/impl/src/test/java/org/richfaces/context/ExtendedPartialVisitContextTest.java
branches/RF-7560/ui/common/ui/src/main/java/org/richfaces/renderkit/util/FormUtil.java
branches/RF-7560/ui/common/ui/src/test/java/org/richfaces/renderkit/util/FormUtilTest.java
branches/RF-7560/ui/core/ui/src/main/java/org/richfaces/renderkit/AjaxCommandRendererBase.java
branches/RF-7560/ui/core/ui/src/main/java/org/richfaces/renderkit/LogRendererBase.java
branches/RF-7560/ui/core/ui/src/main/java/org/richfaces/renderkit/html/AjaxOutputPanelRenderer.java
branches/RF-7560/ui/core/ui/src/main/java/org/richfaces/renderkit/html/AjaxPollRenderer.java
branches/RF-7560/ui/core/ui/src/main/java/org/richfaces/renderkit/html/AjaxPushRenderer.java
branches/RF-7560/ui/core/ui/src/main/java/org/richfaces/renderkit/html/AjaxStatusRenderer.java
branches/RF-7560/ui/core/ui/src/main/java/org/richfaces/renderkit/html/MediaOutputRenderer.java
branches/RF-7560/ui/iteration/ui/src/main/java/org/richfaces/renderkit/AbstractRowsRenderer.java
branches/RF-7560/ui/iteration/ui/src/main/java/org/richfaces/renderkit/DataScrollerBaseRenderer.java
branches/RF-7560/ui/iteration/ui/src/main/java/org/richfaces/renderkit/SubTableToggleControlRendererBase.java
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/renderkit/html/DivPanelRenderer.java
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/renderkit/html/PanelBaseRenderer.java
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/renderkit/html/PopupPanelBaseRenderer.java
Log:
RF-7560
Deleted: branches/RF-7560/core/commons/src/main/java/org/richfaces/renderkit/ComponentAttribute.java
===================================================================
--- branches/RF-7560/core/commons/src/main/java/org/richfaces/renderkit/ComponentAttribute.java 2010-08-31 16:59:42 UTC (rev 19051)
+++ branches/RF-7560/core/commons/src/main/java/org/richfaces/renderkit/ComponentAttribute.java 2010-08-31 17:20:11 UTC (rev 19052)
@@ -1,142 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, 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 java.util.Map;
-import java.util.TreeMap;
-
-/**
- * @author Nick Belaevski
- */
-public class ComponentAttribute implements Comparable<ComponentAttribute> {
-
- public enum Kind {
- BOOL,
- GENERIC,
- URI
- }
-
- private final String htmlAttributeName;
-
- private String componentAttributeName;
-
- private Object defaultValue;
-
- private String[] eventNames = {};
-
- private Kind kind = Kind.GENERIC;
-
- //TODO handling for aliases: "styleClass" -> "class"
-
- public ComponentAttribute(String htmlAttributeName) {
- super();
- this.htmlAttributeName = htmlAttributeName;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @return the defaultValue
- */
- public Object getDefaultValue() {
- return this.defaultValue;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @param defaultValue the defaultValue to set
- */
- public void setDefaultValue(Object dafaultValue) {
- this.defaultValue = dafaultValue;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @return the kind
- */
- public Kind getKind() {
- return this.kind;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @param kind the kind to set
- */
- public void setKind(Kind kind) {
- this.kind = kind;
- }
-
- public static final Map<String, ComponentAttribute> createMap(ComponentAttribute... attributes) {
- Map<String,ComponentAttribute> result = new TreeMap<String, ComponentAttribute>();
-
- for (ComponentAttribute componentAttribute : attributes) {
- result.put(componentAttribute.getComponentAttributeName(), componentAttribute);
- }
-
- return result;
- }
-
- /**
- * @return the name
- */
- public String getHtmlAttributeName() {
- return htmlAttributeName;
- }
-
- /**
- * @return the componentAttributeName
- */
- public String getComponentAttributeName() {
- return (componentAttributeName == null) ? htmlAttributeName : componentAttributeName;
- }
-
- /**
- * @param componentAttributeName the componentAttributeName to set
- * @return
- */
- public ComponentAttribute setComponentAttributeName(String componentAttributeName) {
- this.componentAttributeName = componentAttributeName;
-
- return this;
- }
-
- /**
- * @return the eventNames
- */
- public String[] getEventNames() {
- return eventNames;
- }
-
- /**
- * @param eventNames the eventNames to set
- * @return
- */
- public ComponentAttribute setEventNames(String... eventNames) {
- this.eventNames = eventNames;
-
- return this;
- }
-
- public int compareTo(ComponentAttribute o) {
- return getHtmlAttributeName().compareTo(o.getHtmlAttributeName());
- }
-}
Deleted: branches/RF-7560/core/commons/src/main/java/org/richfaces/renderkit/RenderKitUtils.java
===================================================================
--- branches/RF-7560/core/commons/src/main/java/org/richfaces/renderkit/RenderKitUtils.java 2010-08-31 16:59:42 UTC (rev 19051)
+++ branches/RF-7560/core/commons/src/main/java/org/richfaces/renderkit/RenderKitUtils.java 2010-08-31 17:20:11 UTC (rev 19052)
@@ -1,468 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, 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 java.io.IOException;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeSet;
-
-import javax.faces.component.UIComponent;
-import javax.faces.component.UIComponentBase;
-import javax.faces.component.behavior.ClientBehavior;
-import javax.faces.component.behavior.ClientBehaviorContext;
-import javax.faces.component.behavior.ClientBehaviorHint;
-import javax.faces.component.behavior.ClientBehaviorHolder;
-import javax.faces.context.ExternalContext;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-
-import org.richfaces.renderkit.ComponentAttribute.Kind;
-
-/**
- * @author Nick Belaevski
- *
- */
-public final class RenderKitUtils {
-
- /**
- *
- */
- static final String BEHAVIOR_SOURCE_ID = "javax.faces.source";
-
- /**
- *
- */
- static final String BEHAVIOR_EVENT_NAME = "javax.faces.behavior.event";
-
- /**
- *
- */
- private static final String XHTML_ATTRIBUTE_PREFIX = "xml:";
-
- /**
- *
- */
- private static final String XHTML_CONTENT_TYPE = "application/xhtml+xml";
-
- // TODO - check what's in MyFaces
- private static final String ATTRIBUTES_THAT_ARE_SET = UIComponentBase.class.getName() + ".attributesThatAreSet";
-
- private static final String[] BOOLEAN_ATTRIBUTE_NAMES = { "checked", "compact", "declare", "defer", "disabled",
- "ismap", "multiple", "nohref", "noshade", "nowrap", "readonly", "selected" };
-
- private static final String[] URI_ATTRIBUTE_NAMES = { "action", "background", "cite", "classid", "codebase",
- "data", "href", "longdesc", "profile", "src", "usemap" };
-
- private static final String[] XHTML_ATTRIBUTE_NAMES = { "lang" };
-
- private static final String DISABLED_ATTRIBUTE_NAME = "disabled";
-
- private RenderKitUtils() {
- // utility constructor
- }
-
- private static Map<String, List<ClientBehavior>> getClientBehaviorsMap(UIComponent component) {
- Map<String, List<ClientBehavior>> result;
- if (component instanceof ClientBehaviorHolder) {
- ClientBehaviorHolder clientBehaviorHolder = (ClientBehaviorHolder) component;
-
- result = clientBehaviorHolder.getClientBehaviors();
- } else {
- result = Collections.emptyMap();
- }
- return result;
- }
-
- static boolean isDisabled(UIComponent component) {
- Object disabledAttributeValue = component.getAttributes().get(DISABLED_ATTRIBUTE_NAME);
- if (disabledAttributeValue == null) {
- return false;
- }
-
- if (disabledAttributeValue instanceof Boolean) {
- return Boolean.TRUE.equals(disabledAttributeValue);
- }
-
- return Boolean.valueOf(disabledAttributeValue.toString());
- }
-
- static String escape(String s) {
- StringBuilder sb = new StringBuilder(s.length());
- int start = 0;
- int end;
-
- while ((end = s.indexOf('\'', start)) >= 0) {
- sb.append(s, start, end);
- sb.append("\\'");
-
- start = end + 1;
- }
-
- sb.append(s, start, s.length());
-
- return sb.toString();
- }
-
- static boolean chain(StringBuilder sb, Object object, boolean isChained) {
- if (object != null) {
- String objectString = object.toString().trim();
- if (objectString.length() != 0) {
- final boolean localIsChained;
-
- if (!isChained && sb.length() != 0) {
- // extract previously stored handler
- String previousHandlerString = sb.toString();
- // clear builder object
- sb.setLength(0);
-
- // append escaped handler
- sb.append("'");
- sb.append(escape(previousHandlerString));
- sb.append("'");
-
- localIsChained = true;
- } else {
- // use passed in value of chained indicator
- localIsChained = isChained;
- }
-
- if (localIsChained) {
- sb.append(",'");
- sb.append(escape(objectString));
- sb.append("'");
-
- return true;
- } else {
- sb.append(objectString);
- return false;
- }
- }
- }
-
- // no changes, pass chained indicator we initially used
- return isChained;
- }
-
- private static Object createBehaviorsChain(Object inlineHandlerValue, ClientBehaviorContext behaviorContext,
- List<ClientBehavior> behaviors) {
-
- boolean isChained = false;
- StringBuilder result = new StringBuilder();
-
- isChained = chain(result, inlineHandlerValue, isChained);
- for (ClientBehavior behavior : behaviors) {
- isChained = chain(result, behavior.getScript(behaviorContext), isChained);
-
- if (behavior.getHints().contains(ClientBehaviorHint.SUBMITTING)) {
- break;
- }
- }
-
- if (result.length() == 0) {
- return null;
- }
-
- if (isChained) {
- result.insert(0, "jsf.util.chain(");
- result.append(")");
- }
-
- return result.toString();
- }
-
- public static boolean shouldRenderAttribute(Object attributeValue) {
- if (attributeValue == null) {
- return false;
- } else if (attributeValue instanceof String) {
- return ((String) attributeValue).length() > 0;
- } else if (attributeValue instanceof Boolean && Boolean.FALSE.equals(attributeValue)) {
- return false;
- } else if (attributeValue instanceof Integer && (Integer) attributeValue == Integer.MIN_VALUE) {
- return false;
- } else if (attributeValue instanceof Double && (Double) attributeValue == Double.MIN_VALUE) {
- return false;
- } else if (attributeValue instanceof Character && (Character) attributeValue == Character.MIN_VALUE) {
- return false;
- } else if (attributeValue instanceof Float && (Float) attributeValue == Float.MIN_VALUE) {
- return false;
- } else if (attributeValue instanceof Short && (Short) attributeValue == Short.MIN_VALUE) {
- return false;
- } else if (attributeValue instanceof Byte && (Byte) attributeValue == Byte.MIN_VALUE) {
- return false;
- } else if (attributeValue instanceof Long && (Long) attributeValue == Long.MIN_VALUE) {
- return false;
- }
-
- return attributeValue.toString().length() > 0;
- }
-
- public static String prefixAttributeName(String attributeName, boolean isXhtmlMode) {
- if (isXhtmlMode) {
- if (Arrays.binarySearch(XHTML_ATTRIBUTE_NAMES, attributeName) >= 0) {
- return XHTML_ATTRIBUTE_PREFIX + attributeName;
- }
- }
-
- return attributeName;
- }
-
- public static String prefixAttributeName(String attributeName, ResponseWriter responseWriter) {
- return prefixAttributeName(attributeName, XHTML_CONTENT_TYPE.equals(responseWriter.getContentType()));
- }
-
- public static void renderAttribute(FacesContext facesContext, String attributeName, Object attributeValue)
- throws IOException {
-
- if (!shouldRenderAttribute(attributeValue)) {
- return;
- }
-
- ResponseWriter writer = facesContext.getResponseWriter();
-
- String prefixedAttributeName = prefixAttributeName(attributeName, writer);
-
- if (Arrays.binarySearch(URI_ATTRIBUTE_NAMES, attributeName) >= 0) {
- writer.writeURIAttribute(prefixedAttributeName, attributeValue, null);
- } else if (Arrays.binarySearch(BOOLEAN_ATTRIBUTE_NAMES, attributeName) >= 0) {
- boolean booleanAttributeValue = Boolean.valueOf(String.valueOf(attributeValue));
- if (booleanAttributeValue) {
- // TODO - is passing in Boolean.TRUE value documented somewhere?
- writer.writeAttribute(prefixedAttributeName, Boolean.TRUE, null);
- }
- } else {
- writer.writeAttribute(prefixedAttributeName, attributeValue, null);
- }
- }
-
- public static Object getAttributeAndBehaviorsValue(FacesContext facesContext, UIComponent component,
- ComponentAttribute componentAttribute) {
- if (facesContext == null) {
- throw new NullPointerException("facesContext");
- }
-
- if (component == null) {
- throw new NullPointerException("component");
- }
-
- if (componentAttribute == null) {
- throw new NullPointerException("componentAttribute");
- }
-
- String componentAttributeName = componentAttribute.getComponentAttributeName();
- Object attributeValue = component.getAttributes().get(componentAttributeName);
-
- String[] eventNames = componentAttribute.getEventNames();
- if (eventNames.length > 0) {
- Map<String, List<ClientBehavior>> behaviorsMap = getClientBehaviorsMap(component);
- if (behaviorsMap.size() > 0) {
- for (String eventName : eventNames) {
- if (behaviorsMap.containsKey(eventName)) {
- List<ClientBehavior> behaviorsList = behaviorsMap.get(eventName);
- if (!behaviorsList.isEmpty()) {
- // TODO - parameters handling
- ClientBehaviorContext behaviorContext =
- ClientBehaviorContext.createClientBehaviorContext(facesContext, component, eventName,
- null, null);
- attributeValue = createBehaviorsChain(attributeValue, behaviorContext, behaviorsList);
- }
- break;
- }
- }
- }
- }
- return attributeValue;
- }
-
- public static void renderAttributeAndBehaviors(FacesContext facesContext, UIComponent component,
- ComponentAttribute componentAttribute) throws IOException {
- Object attributeValue = getAttributeAndBehaviorsValue(facesContext, component, componentAttribute);
- renderAttribute(facesContext, componentAttribute.getHtmlAttributeName(), attributeValue);
- }
-
- public static void renderPassThroughAttributesOptimized(FacesContext context, UIComponent component,
- Map<String, ComponentAttribute> knownAttributesMap) throws IOException {
-
- boolean disabled = isDisabled(component);
- Set<String> handledAttributes = new HashSet<String>(knownAttributesMap.size());
- Object attributesThatAreSetObject = component.getAttributes().get(ATTRIBUTES_THAT_ARE_SET);
- if (attributesThatAreSetObject instanceof Collection<?>) {
- Collection<?> attributesThatAreSet = (Collection<?>) attributesThatAreSetObject;
- for (Object attributeNameObject : attributesThatAreSet) {
- if (attributeNameObject == null) {
- continue;
- }
-
- String attributeName = attributeNameObject.toString();
-
- ComponentAttribute knownAttribute = knownAttributesMap.get(attributeName);
- if (knownAttribute != null) {
- handledAttributes.add(knownAttribute.getHtmlAttributeName());
-
- if (disabled && knownAttribute.getEventNames() != null) {
- continue;
- }
-
- renderAttributeAndBehaviors(context, component, knownAttribute);
- }
- }
-
- // render attributes that haven't been processed yet - there can be behaviors
- for (ComponentAttribute knownAttribute : knownAttributesMap.values()) {
-
- if (handledAttributes.contains(knownAttribute.getHtmlAttributeName())) {
- continue;
- }
-
- renderAttributeAndBehaviors(context, component, knownAttribute);
- }
- } else {
- // switch to unoptimized mode
- renderPassThroughAttributes(context, component, knownAttributesMap);
- }
- }
-
- public static void renderPassThroughAttributes(FacesContext context, UIComponent component,
- Map<String, ComponentAttribute> knownAttributesMap) throws IOException {
- Collection<ComponentAttribute> attributes = knownAttributesMap.values();
-
- renderPassThroughAttributes(context, component, attributes);
- }
-
- public static void renderPassThroughAttributes(FacesContext context, UIComponent component, Collection<ComponentAttribute> attributes)
- throws IOException {
- boolean disabled = isDisabled(component);
- for (ComponentAttribute knownAttribute : attributes) {
- if (!disabled || knownAttribute.getEventNames().length == 0) {
- renderAttributeAndBehaviors(context, component, knownAttribute);
- }
- }
- }
-
- public static String decodeBehaviors(FacesContext context, UIComponent component) {
- if (!(component instanceof ClientBehaviorHolder)) {
- return null;
- }
-
- ClientBehaviorHolder holder = (ClientBehaviorHolder) component;
- Map<String, List<ClientBehavior>> behaviors = holder.getClientBehaviors();
-
- if (behaviors == null || behaviors.isEmpty()) {
- return null;
- }
-
- ExternalContext externalContext = context.getExternalContext();
- Map<String, String> parametersMap = externalContext.getRequestParameterMap();
- String behaviorEvent = parametersMap.get(BEHAVIOR_EVENT_NAME);
-
- if (behaviorEvent == null) {
- return null;
- }
-
- List<ClientBehavior> behaviorsForEvent = behaviors.get(behaviorEvent);
- String behaviorSource = parametersMap.get(BEHAVIOR_SOURCE_ID);
- String clientId = component.getClientId(context);
-
- if (behaviorSource != null && behaviorSource.equals(clientId)) {
- if (behaviorsForEvent != null && !behaviorsForEvent.isEmpty()) {
- for (ClientBehavior behavior : behaviorsForEvent) {
- behavior.decode(context, component);
- }
-
- return behaviorEvent;
- }
- }
-
- return null;
- }
-
- public static Attributes attributes() {
- return new Attributes();
- }
-
- public static Attributes attributes(Enum<?> ... attrs) {
- Attributes res = new Attributes();
- for (Enum<?> attr : attrs) {
- res.generic(attr.toString(), attr.toString());
- }
-
- return res;
- }
-
- public static Attributes attributes(String ... attrs) {
- Attributes res = new Attributes();
- for (String attr : attrs) {
- res.generic(attr, attr);
- }
-
- return res;
- }
-
- @SuppressWarnings("serial")
- public static final class Attributes extends TreeSet<ComponentAttribute> {
-
- private ComponentAttribute last;
-
- public void render(FacesContext context, UIComponent component) throws IOException {
- renderPassThroughAttributes(context, component, this);
- }
-
- public Attributes generic(String name, String componentAttribute, String... events) {
- ComponentAttribute attribute = createAttribute(name, componentAttribute);
- attribute.setEventNames(events);
- attribute.setKind(Kind.GENERIC);
- return this;
- }
-
- private ComponentAttribute createAttribute(String name, String componentAttribute) {
- ComponentAttribute attribute = new ComponentAttribute(name);
- attribute.setComponentAttributeName(componentAttribute);
- add(attribute);
- last = attribute;
- return attribute;
- }
-
- public Attributes uri(String name, String componentAttribute) {
- ComponentAttribute attribute = createAttribute(name, componentAttribute);
- attribute.setKind(Kind.URI);
- return this;
- }
-
- public Attributes bool(String name, String componentAttribute) {
- ComponentAttribute attribute = createAttribute(name, componentAttribute);
- attribute.setKind(Kind.BOOL);
- return this;
- }
-
- public Attributes defaultValue(Object value){
- last.setDefaultValue(value);
- return this;
- }
-
- }
-
-}
Deleted: branches/RF-7560/core/commons/src/test/java/org/richfaces/renderkit/MockClientBehaviorHolder.java
===================================================================
--- branches/RF-7560/core/commons/src/test/java/org/richfaces/renderkit/MockClientBehaviorHolder.java 2010-08-31 16:59:42 UTC (rev 19051)
+++ branches/RF-7560/core/commons/src/test/java/org/richfaces/renderkit/MockClientBehaviorHolder.java 2010-08-31 17:20:11 UTC (rev 19052)
@@ -1,58 +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;
-
-import static org.jboss.test.faces.mock.FacesMockController.invokeCurrent;
-
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-
-import javax.faces.component.behavior.ClientBehavior;
-import javax.faces.component.behavior.ClientBehaviorHolder;
-
-import org.easymock.IMocksControl;
-import org.jboss.test.faces.mock.component.MockUIComponent;
-
-public class MockClientBehaviorHolder extends MockUIComponent implements ClientBehaviorHolder {
-
- public MockClientBehaviorHolder(IMocksControl control, String name) {
- super(control, name);
- }
-
- public void addClientBehavior(String eventName, ClientBehavior behavior) {
- invokeCurrent(this, eventName, behavior);
- }
-
- public Map<String, List<ClientBehavior>> getClientBehaviors() {
- return invokeCurrent(this);
- }
-
- public String getDefaultEventName() {
- return invokeCurrent(this);
- }
-
- public Collection<String> getEventNames() {
- return invokeCurrent(this);
- }
-
-}
Deleted: branches/RF-7560/core/commons/src/test/java/org/richfaces/renderkit/RenderKitUtilsMocksTest.java
===================================================================
--- branches/RF-7560/core/commons/src/test/java/org/richfaces/renderkit/RenderKitUtilsMocksTest.java 2010-08-31 16:59:42 UTC (rev 19051)
+++ branches/RF-7560/core/commons/src/test/java/org/richfaces/renderkit/RenderKitUtilsMocksTest.java 2010-08-31 17:20:11 UTC (rev 19052)
@@ -1,377 +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;
-
-import static org.easymock.EasyMock.eq;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.expectLastCall;
-import static org.easymock.EasyMock.same;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-import java.io.IOException;
-import java.text.MessageFormat;
-import java.util.Arrays;
-import java.util.EnumSet;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeMap;
-
-import javax.faces.component.UIComponent;
-import javax.faces.component.behavior.ClientBehavior;
-import javax.faces.component.behavior.ClientBehaviorContext;
-import javax.faces.component.behavior.ClientBehaviorHint;
-import javax.faces.component.behavior.ClientBehaviorHolder;
-import javax.faces.context.ExternalContext;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-
-import org.easymock.EasyMock;
-import org.jboss.test.faces.mock.MockFacesEnvironment;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-/**
- * @author Nick Belaevski
- *
- */
-public class RenderKitUtilsMocksTest {
-
- /**
- *
- */
- private static final String CLIENT_ID = "submittedId";
-
- private MockFacesEnvironment facesEnvironment;
-
- private ResponseWriter responseWriter;
-
- private FacesContext facesContext;
-
- private ExternalContext externalContext;
-
- private Map<String, Object> componentAttributes;
-
- private Map<String, List<ClientBehavior>> behaviorsMap;
-
- private Map<String, ComponentAttribute> knownAttributes;
-
- @Before
- public void setUp() throws Exception {
- facesEnvironment = MockFacesEnvironment.createEnvironment().withExternalContext();
-
- facesContext = facesEnvironment.getFacesContext();
- externalContext = facesEnvironment.getExternalContext();
-
- responseWriter = facesEnvironment.createMock(ResponseWriter.class);
- expect(facesContext.getResponseWriter()).andStubReturn(responseWriter);
- expect(responseWriter.getContentType()).andStubReturn("application/xhtml+xml");
-
- componentAttributes = new HashMap<String, Object>();
- behaviorsMap = new HashMap<String, List<ClientBehavior>>();
- knownAttributes = new TreeMap<String, ComponentAttribute>();
- }
-
- @After
- public void tearDown() throws Exception {
- this.facesEnvironment.verify();
- this.facesEnvironment.release();
-
- this.facesEnvironment = null;
- this.responseWriter = null;
- this.facesContext = null;
- this.externalContext = null;
- this.componentAttributes = null;
- this.behaviorsMap = null;
- this.knownAttributes = null;
- }
-
- private UIComponent createMockComponent() {
- UIComponent component = facesEnvironment.createMock(UIComponent.class);
- expect(component.getAttributes()).andStubReturn(componentAttributes);
- expect(component.getClientId(same(facesContext))).andStubReturn(CLIENT_ID);
- return component;
- }
-
- private ClientBehaviorHolder createMockClientBehaviorHolder() {
- UIComponent component = facesEnvironment.createMock(MockClientBehaviorHolder.class);
- expect(component.getClientId(same(facesContext))).andStubReturn(CLIENT_ID);
- expect(component.getAttributes()).andStubReturn(componentAttributes);
- ClientBehaviorHolder behaviorHolder = (ClientBehaviorHolder) component;
- expect(behaviorHolder.getClientBehaviors()).andStubReturn(behaviorsMap);
- expect(behaviorHolder.getEventNames()).andStubReturn(
- Arrays.asList("click", "action", "mousemove", "keypress", "blur", "contextmenu"));
- return behaviorHolder;
- }
-
- @Test
- public void testRenderPassThroughAttributes() throws Exception {
- knownAttributes.put("disabled", new ComponentAttribute("disabled"));
- knownAttributes.put("checked", new ComponentAttribute("checked"));
- knownAttributes.put("style", new ComponentAttribute("style"));
- knownAttributes.put("src", new ComponentAttribute("src"));
- knownAttributes.put("lang", new ComponentAttribute("lang"));
- knownAttributes.put("class", new ComponentAttribute("class").setComponentAttributeName("styleClass"));
-
- componentAttributes.put("disabled", Boolean.TRUE);
- componentAttributes.put("checked", Boolean.FALSE);
- componentAttributes.put("style", "color:red");
- componentAttributes.put("src", "urn:abc");
- componentAttributes.put("facelets.Mark", 123);
- componentAttributes.put("lang", "ru");
- componentAttributes.put("styleClass", "rich-component");
-
- UIComponent component = createMockComponent();
-
- responseWriter.writeAttribute(eq("disabled"), eq(Boolean.TRUE), EasyMock.<String>isNull());
- // checked attribute shouldn't be rendered - it's 'false'
- responseWriter.writeAttribute(eq("style"), eq("color:red"), EasyMock.<String>isNull());
- responseWriter.writeURIAttribute(eq("src"), eq("urn:abc"), EasyMock.<String>isNull());
- // facelets.Mark shouldn't be rendered - it's unknown
- responseWriter.writeAttribute(eq("xml:lang"), eq("ru"), EasyMock.<String>isNull());
- responseWriter.writeAttribute(eq("class"), eq("rich-component"), EasyMock.<String>isNull());
-
- facesEnvironment.replay();
-
- RenderKitUtils.renderPassThroughAttributes(facesContext, component, knownAttributes);
- }
-
- private ClientBehavior createClientBehavior(String handlerData, Set<ClientBehaviorHint> hints) {
- ClientBehavior behavior = facesEnvironment.createMock(ClientBehavior.class);
- expect(behavior.getScript(EasyMock.<ClientBehaviorContext> notNull())).andStubReturn(
- MessageFormat.format("prompt({0})", handlerData));
-
- expect(behavior.getHints()).andStubReturn(hints);
- return behavior;
- }
-
- @Test
- public void testBehaviors() throws Exception {
- knownAttributes.put("onclick", new ComponentAttribute("onclick")
- .setEventNames(new String[] { "click", "action" }));
- knownAttributes.put("onmousemove", new ComponentAttribute("onmousemove")
- .setEventNames(new String[] { "mousemove" }));
- knownAttributes.put("onkeypress", new ComponentAttribute("onkeypress")
- .setEventNames(new String[] { "keypress" }));
- knownAttributes.put("oncontextmenu", new ComponentAttribute("oncontextmenu")
- .setEventNames(new String[] { "contextmenu" }));
-
- componentAttributes.put("onkeypress", "alert(keypress)");
- componentAttributes.put("onmousemove", "alert(mousemove)");
- componentAttributes.put("onclick", "alert(click)");
-
- Set<ClientBehaviorHint> emptyHintsSet = EnumSet.noneOf(ClientBehaviorHint.class);
- Set<ClientBehaviorHint> submittingHintsSet = EnumSet.of(ClientBehaviorHint.SUBMITTING);
-
- ClientBehavior keypressBehavior = createClientBehavior("keypress", emptyHintsSet);
- ClientBehavior actionBehavior1 = createClientBehavior("action1", emptyHintsSet);
- ClientBehavior actionBehavior2 = createClientBehavior("action2", submittingHintsSet);
- ClientBehavior actionBehavior3 = createClientBehavior("action3", emptyHintsSet);
- ClientBehavior contextmenuBehavior = createClientBehavior("contextmenu", emptyHintsSet);
-
- behaviorsMap.put("keypress", Arrays.asList(keypressBehavior));
- behaviorsMap.put("action", Arrays.asList(actionBehavior1, actionBehavior2, actionBehavior3));
- behaviorsMap.put("contextmenu", Arrays.asList(contextmenuBehavior));
-
- ClientBehaviorHolder behaviorHolder = createMockClientBehaviorHolder();
- UIComponent component = (UIComponent) behaviorHolder;
-
- responseWriter.writeAttribute(eq("onkeypress"), eq("jsf.util.chain('alert(keypress)','prompt(keypress)')"),
- EasyMock.<String>isNull());
- responseWriter.writeAttribute(eq("onclick"),
- eq("jsf.util.chain('alert(click)','prompt(action1)','prompt(action2)')"), EasyMock.<String>isNull());
- responseWriter.writeAttribute(eq("onmousemove"), eq("alert(mousemove)"), EasyMock.<String>isNull());
- responseWriter.writeAttribute(eq("oncontextmenu"), eq("prompt(contextmenu)"), EasyMock.<String>isNull());
-
- facesEnvironment.replay();
-
- RenderKitUtils.renderPassThroughAttributes(facesContext, component, knownAttributes);
- }
-
- private UIComponent setupBehaviorsTestForDisabledComponent() throws IOException {
- knownAttributes.put("style", new ComponentAttribute("style"));
- knownAttributes.put("onclick", new ComponentAttribute("onclick")
- .setEventNames(new String[] { "click", "action" }));
- knownAttributes.put("onmousemove", new ComponentAttribute("onmousemove")
- .setEventNames(new String[] { "mousemove" }));
-
- componentAttributes.put("onmousemove", "alert(mousemove)");
- componentAttributes.put("onclick", "alert(click)");
- componentAttributes.put("style", "color:green");
-
- Set<ClientBehaviorHint> emptyHintsSet = EnumSet.noneOf(ClientBehaviorHint.class);
-
- ClientBehavior actionBehavior1 = createClientBehavior("action1", emptyHintsSet);
- behaviorsMap.put("action", Arrays.asList(actionBehavior1));
-
- ClientBehaviorHolder behaviorHolder = createMockClientBehaviorHolder();
- UIComponent component = (UIComponent) behaviorHolder;
- return component;
- }
-
- @Test
- public void testBehaviorsForDisabledComponent() throws Exception {
- componentAttributes.put("disabled", Boolean.TRUE);
- UIComponent component = setupBehaviorsTestForDisabledComponent();
-
- responseWriter.writeAttribute(eq("style"), eq("color:green"), EasyMock.<String>isNull());
-
- facesEnvironment.replay();
-
- RenderKitUtils.renderPassThroughAttributes(facesContext, component, knownAttributes);
- }
-
- @Test
- public void testBehaviorsForNonDisabledComponent() throws Exception {
- componentAttributes.put("disabled", Boolean.FALSE);
- UIComponent component = setupBehaviorsTestForDisabledComponent();
-
- responseWriter.writeAttribute(eq("onclick"), eq("jsf.util.chain('alert(click)','prompt(action1)')"),
- EasyMock.<String>isNull());
- responseWriter.writeAttribute(eq("onmousemove"),
- eq("alert(mousemove)"), EasyMock.<String>isNull());
- responseWriter.writeAttribute(eq("style"), eq("color:green"), EasyMock.<String>isNull());
-
- facesEnvironment.replay();
-
- RenderKitUtils.renderPassThroughAttributes(facesContext, component, knownAttributes);
- }
-
- public void checkDisabled(Object attributeValue, boolean expectedValue) throws Exception {
- componentAttributes.put("disabled", attributeValue);
-
- UIComponent component = createMockComponent();
- facesEnvironment.replay();
- assertTrue(expectedValue == RenderKitUtils.isDisabled(component));
- }
-
- @Test
- public void testIsDisabled() throws Exception {
- checkDisabled(Boolean.TRUE, true);
- }
-
- @Test
- public void testIsDisabledString() throws Exception {
- checkDisabled("true", true);
- }
-
- @Test
- public void testIsNonDisabled() throws Exception {
- checkDisabled(Boolean.FALSE, false);
- }
-
- @Test
- public void testIsNonDisabledString() throws Exception {
- checkDisabled("false", false);
- }
-
- @Test
- public void testIsNonDisabledNull() throws Exception {
- checkDisabled(null, false);
- }
-
- private UIComponent setupTestDecodeBehaviors(String behaviorSourceId, String behaviorEventName) throws Exception {
- ClientBehaviorHolder behaviorHolder = createMockClientBehaviorHolder();
- UIComponent component = (UIComponent) behaviorHolder;
-
- Map<String, String> requestParameterMap = new HashMap<String, String>();
- requestParameterMap.put(RenderKitUtils.BEHAVIOR_SOURCE_ID, behaviorSourceId);
- requestParameterMap.put(RenderKitUtils.BEHAVIOR_EVENT_NAME, behaviorEventName);
- expect(externalContext.getRequestParameterMap()).andStubReturn(requestParameterMap);
-
- ClientBehavior actionBehavior = createClientBehavior("action1", EnumSet.of(ClientBehaviorHint.SUBMITTING));
- ClientBehavior actionBehavior1 = createClientBehavior("action2", EnumSet.of(ClientBehaviorHint.SUBMITTING));
- behaviorsMap.put("action", Arrays.asList(actionBehavior, actionBehavior1));
-
- ClientBehavior blurBehavior = createClientBehavior("blur1", EnumSet.of(ClientBehaviorHint.SUBMITTING));
- behaviorsMap.put("blur", Arrays.asList(blurBehavior));
-
- return component;
- }
-
- @Test
- public void testDecodeActionBehaviors() throws Exception {
- UIComponent component = setupTestDecodeBehaviors(CLIENT_ID, "action");
-
- List<ClientBehavior> behaviors = behaviorsMap.get("action");
- for (ClientBehavior clientBehavior : behaviors) {
- clientBehavior.decode(same(facesContext), same(component));
- expectLastCall();
- }
-
- facesEnvironment.replay();
-
- assertEquals("action", RenderKitUtils.decodeBehaviors(facesContext, component));
- }
-
- @Test
- public void testDecodeBlurBehaviors() throws Exception {
- UIComponent component = setupTestDecodeBehaviors(CLIENT_ID, "blur");
-
- List<ClientBehavior> behaviors = behaviorsMap.get("blur");
- for (ClientBehavior clientBehavior : behaviors) {
- clientBehavior.decode(same(facesContext), same(component));
- expectLastCall();
- }
-
- facesEnvironment.replay();
-
- assertEquals("blur", RenderKitUtils.decodeBehaviors(facesContext, component));
- }
-
- @Test
- public void testDecodeNonMatchingClientId() throws Exception {
- UIComponent component = setupTestDecodeBehaviors("wrongId", "action");
-
- //nothing should be called - clientId is not matched
-
- facesEnvironment.replay();
-
- assertNull(RenderKitUtils.decodeBehaviors(facesContext, component));
- }
-
- @Test
- public void testDecodeNoSubmittedBehavior() throws Exception {
- UIComponent component = setupTestDecodeBehaviors(CLIENT_ID, null);
-
- //nothing should be called - no behavior event information was submitted
-
- facesEnvironment.replay();
-
- assertNull(RenderKitUtils.decodeBehaviors(facesContext, component));
- }
-
- @Test
- public void testDecodeContextMenuBehaviors() throws Exception {
- UIComponent component = setupTestDecodeBehaviors(CLIENT_ID, "contextmenu");
-
- //nothing should be called - no context menu behaviors were created
-
- facesEnvironment.replay();
-
- assertNull(RenderKitUtils.decodeBehaviors(facesContext, component));
- }
-}
\ No newline at end of file
Deleted: branches/RF-7560/core/commons/src/test/java/org/richfaces/renderkit/RenderKitUtilsTest.java
===================================================================
--- branches/RF-7560/core/commons/src/test/java/org/richfaces/renderkit/RenderKitUtilsTest.java 2010-08-31 16:59:42 UTC (rev 19051)
+++ branches/RF-7560/core/commons/src/test/java/org/richfaces/renderkit/RenderKitUtilsTest.java 2010-08-31 17:20:11 UTC (rev 19052)
@@ -1,110 +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;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import org.junit.Test;
-
-/**
- * @author Nick Belaevski
- *
- */
-public class RenderKitUtilsTest {
-
- @Test
- public void testEscape() throws Exception {
- assertEquals("", RenderKitUtils.escape(""));
- assertEquals("abcd", RenderKitUtils.escape("abcd"));
- assertEquals("\\'abcd", RenderKitUtils.escape("'abcd"));
- assertEquals("abcd\\'", RenderKitUtils.escape("abcd'"));
- assertEquals("ab\\'cd", RenderKitUtils.escape("ab'cd"));
- assertEquals("ab\\'\\'cd", RenderKitUtils.escape("ab''cd"));
- assertEquals("ab\\'c\\'d", RenderKitUtils.escape("ab'c'd"));
- }
-
- @Test
- public void testChain() throws Exception {
- StringBuilder sb = new StringBuilder();
-
- assertFalse(RenderKitUtils.chain(sb, "", false));
- assertTrue(sb.length() == 0);
- assertFalse(RenderKitUtils.chain(sb, null, false));
- assertTrue(sb.length() == 0);
-
- assertFalse(RenderKitUtils.chain(sb, "test", false));
- assertEquals("test", sb.toString());
-
- assertFalse(RenderKitUtils.chain(sb, "", false));
- assertEquals("test", sb.toString());
-
- assertTrue(RenderKitUtils.chain(sb, "another'object", false));
- assertEquals("'test','another\\'object'", sb.toString());
-
- assertTrue(RenderKitUtils.chain(sb, "one more", true));
- assertEquals("'test','another\\'object','one more'", sb.toString());
- }
-
- @Test
- public void testShouldRenderAttribute() throws Exception {
- assertFalse(RenderKitUtils.shouldRenderAttribute(null));
-
- assertFalse(RenderKitUtils.shouldRenderAttribute(""));
- assertTrue(RenderKitUtils.shouldRenderAttribute("test"));
-
- assertTrue(RenderKitUtils.shouldRenderAttribute(new Object()));
-
- assertTrue(RenderKitUtils.shouldRenderAttribute(Long.valueOf(10)));
- assertTrue(RenderKitUtils.shouldRenderAttribute(Long.valueOf(0)));
- assertFalse(RenderKitUtils.shouldRenderAttribute(Long.MIN_VALUE));
-
- assertTrue(RenderKitUtils.shouldRenderAttribute(Integer.valueOf(10)));
- assertTrue(RenderKitUtils.shouldRenderAttribute(Integer.valueOf(0)));
- assertFalse(RenderKitUtils.shouldRenderAttribute(Integer.MIN_VALUE));
-
- assertTrue(RenderKitUtils.shouldRenderAttribute(Short.valueOf((short) 10)));
- assertTrue(RenderKitUtils.shouldRenderAttribute(Short.valueOf((short) 0)));
- assertFalse(RenderKitUtils.shouldRenderAttribute(Short.MIN_VALUE));
-
- assertTrue(RenderKitUtils.shouldRenderAttribute(Character.valueOf('a')));
- assertTrue(RenderKitUtils.shouldRenderAttribute(Character.valueOf((char) 13)));
- assertFalse(RenderKitUtils.shouldRenderAttribute(Character.MIN_VALUE));
-
- assertTrue(RenderKitUtils.shouldRenderAttribute(Byte.valueOf((byte) 10)));
- assertTrue(RenderKitUtils.shouldRenderAttribute(Byte.valueOf((byte) 0)));
- assertFalse(RenderKitUtils.shouldRenderAttribute(Byte.MIN_VALUE));
-
- assertTrue(RenderKitUtils.shouldRenderAttribute(Double.valueOf(10)));
- assertTrue(RenderKitUtils.shouldRenderAttribute(Double.valueOf(0)));
- assertFalse(RenderKitUtils.shouldRenderAttribute(Double.MIN_VALUE));
-
- assertTrue(RenderKitUtils.shouldRenderAttribute(Float.valueOf(10)));
- assertTrue(RenderKitUtils.shouldRenderAttribute(Float.valueOf(0)));
- assertFalse(RenderKitUtils.shouldRenderAttribute(Float.MIN_VALUE));
-
- assertTrue(RenderKitUtils.shouldRenderAttribute(Boolean.TRUE));
- assertFalse(RenderKitUtils.shouldRenderAttribute(Boolean.FALSE));
- }
-
-}
\ No newline at end of file
Modified: branches/RF-7560/core/impl/pom.xml
===================================================================
--- branches/RF-7560/core/impl/pom.xml 2010-08-31 16:59:42 UTC (rev 19051)
+++ branches/RF-7560/core/impl/pom.xml 2010-08-31 17:20:11 UTC (rev 19052)
@@ -124,23 +124,8 @@
</configuration>
</plugin>
- <!--
- TODO Centralize this because calendar and context menu use this too
- Note: This may be removed by redisgn
- -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
- <artifactId>javacc-maven-plugin</artifactId>
- <executions>
- <execution>
- <goals>
- <goal>javacc</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
<artifactId>buildnumber-maven-plugin</artifactId>
<executions>
<execution>
Deleted: branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/renderkit/AjaxChildrenRenderer.java
===================================================================
--- branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/renderkit/AjaxChildrenRenderer.java 2010-08-31 16:59:42 UTC (rev 19051)
+++ branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/renderkit/AjaxChildrenRenderer.java 2010-08-31 17:20:11 UTC (rev 19052)
@@ -1,221 +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 java.io.IOException;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-import javax.faces.component.NamingContainer;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.Messages;
-import org.ajax4jsf.component.AjaxChildrenEncoder;
-import org.ajax4jsf.component.AjaxOutput;
-import org.ajax4jsf.context.AjaxContext;
-import org.richfaces.log.Logger;
-import org.richfaces.log.RichfacesLogger;
-
-/**
- * @author shura
- */
-public abstract class AjaxChildrenRenderer extends AjaxComponentRendererBase implements AjaxRenderer {
- public static final String[] SPECIAL_COMPONENTS_TYPES = {"org.ajax4jsf.Bundle" /* UILoadBundle.COMPONENT_TYPE */,
- "org.apache.myfaces.AliasBean", "org.apache.myfaces.AliasBeansScope"};
-
- private static final String SPECIAL_TYPES_PARAMETER = "org.ajax4jsf.CONTROL_COMPONENTS";
- private static final Logger LOG = RichfacesLogger.RENDERKIT.getLogger();
-
- private Set<String> specialComponentTypes = null;
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.ajax4jsf.renderkit.AjaxRenderer#encodeAjaxChildren(javax.faces.context
- * .FacesContext, javax.faces.component.UIComponent, java.lang.String,
- * java.util.Set, java.util.Set)
- */
- public void encodeAjaxChildren(FacesContext context, UIComponent component, String path, Set<String> ids,
- Set<String> renderedAreas) throws IOException {
-
- if (LOG.isDebugEnabled()) {
- LOG.debug(Messages.getMessage(Messages.ENCODE_CHILD_AJAX_INFO, path, component.getId()));
- }
-
- String currentPath = path;
-
- if (component instanceof NamingContainer) {
- currentPath += component.getId() + NamingContainer.SEPARATOR_CHAR;
-
- // Do not check children if we have no id to render under naming
- // container.
- if (AjaxContext.getCurrentInstance(context).isLimitToList() && noIdUnderPath(path, ids)) {
- return;
- }
- }
-
- for (Iterator<UIComponent> it = component.getFacetsAndChildren(); it.hasNext();) {
- UIComponent element = (UIComponent) it.next();
-
- encodeAjaxComponent(context, element, currentPath, ids, renderedAreas);
- }
- }
-
- private boolean noIdUnderPath(String path, Set<String> ids) {
-
- // Do we have an any component for the rendering under that container ?
- boolean noSuchId = true;
-
- for (String id : ids) {
- if ((null != id) && id.startsWith(path)) {
- noSuchId = false;
-
- break;
- }
- }
-
- return noSuchId;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.ajax4jsf.renderkit.AjaxRenderer#encodeAjaxComponent(javax.faces.context
- * .FacesContext, javax.faces.component.UIComponent, java.lang.String,
- * java.util.Set, java.util.Set)
- */
- public void encodeAjaxComponent(FacesContext context, UIComponent component, String currentPath, Set<String> ids,
- Set<String> renderedAreas) throws IOException {
-
- if (component.isRendered()) { // skip not-rendered components.
- boolean found = false;
- boolean limitToList = AjaxContext.getCurrentInstance(context).isLimitToList();
- String elementId = component.getId();
- String absoluteId = currentPath + elementId;
-
- if (!ids.isEmpty()) {
-
- // list for rendering may contains absolute id ( best ),
- // component Id or client ID
- // String clientId = element.getClientId(context);
- if (ids.contains(absoluteId) || ids.contains(elementId)) {
- if (LOG.isDebugEnabled()) {
- LOG.debug(Messages.getMessage(Messages.RENDER_AJAX_AREA_INFO, absoluteId));
- }
-
- // renderChild(context, element);
- found = true;
- }
- }
-
- //
- if (!found && limitToList && (component instanceof NamingContainer)
- && noIdUnderPath(absoluteId + NamingContainer.SEPARATOR_CHAR, ids)) {
- return;
- }
-
- if (!found && !limitToList && (component instanceof AjaxOutput)) {
- if (((AjaxOutput) component).isAjaxRendered()) {
-
- // renderChild(context, element);
- found = true;
- }
- }
-
- if (!found) {
- if (component instanceof AjaxChildrenEncoder) {
- ((AjaxChildrenEncoder) component).encodeAjaxChild(context, currentPath, ids, renderedAreas);
- } else {
-
- // Special case - for control components, not produced
- // html code - such as message bundles loaders,
- // MyFaces aliases etc. we call encodeBegin/end methods
- // even if components not in rendered areas.
- boolean special = isSpecialElement(context, component);
-
- if (special) {
- component.encodeBegin(context);
- }
-
- encodeAjaxChildren(context, component, currentPath, ids, renderedAreas);
-
- if (special) {
- component.encodeEnd(context);
- }
- }
- } else {
- renderedAreas.add(component.getClientId(context));
- component.encodeAll(context);
- }
- }
- }
-
- /**
- * Detect component as special control case - such as messages bundle
- * loader, alias bean components etc. Type of component get by reflection
- * from static field COMPONENT_TYPE
- *
- * @param context
- * @param component
- * @return true if encode methods must be called for this component even in
- * not-rendered parts.
- */
- private boolean isSpecialElement(FacesContext context, UIComponent component) {
- if (specialComponentTypes == null) {
- specialComponentTypes = new HashSet<String>(10);
-
- for (int i = 0; i < SPECIAL_COMPONENTS_TYPES.length; i++) {
- specialComponentTypes.add(SPECIAL_COMPONENTS_TYPES[i]);
- }
-
- String special = context.getExternalContext().getInitParameter(SPECIAL_TYPES_PARAMETER);
-
- if (null != special) {
- String[] split = special.split(",");
-
- for (int i = 0; i < split.length; i++) {
- specialComponentTypes.add(split[i]);
- }
- }
- }
-
- boolean result;
-
- try {
- String componentType = (String) component.getClass().getField("COMPONENT_TYPE").get(null);
-
- result = specialComponentTypes.contains(componentType);
- } catch (Exception e) {
-
- // exception occurs if component not have accesible COMPONENT_TYPE
- // constant
- // we assume that component not in special types.
- result = false;
- }
-
- return result;
- }
-}
Deleted: branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/renderkit/AjaxComponentRendererBase.java
===================================================================
--- branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/renderkit/AjaxComponentRendererBase.java 2010-08-31 16:59:42 UTC (rev 19051)
+++ branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/renderkit/AjaxComponentRendererBase.java 2010-08-31 17:20:11 UTC (rev 19052)
@@ -1,32 +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;
-
-/**
- * Base class for all Ajax enabled components. Perform common task -
- * output javasript for component.
- *
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:58:49 $
- */
-public abstract class AjaxComponentRendererBase extends RendererBase {
-}
Deleted: branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/renderkit/ComponentRendererBase.java
===================================================================
--- branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/renderkit/ComponentRendererBase.java 2010-08-31 16:59:42 UTC (rev 19051)
+++ branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/renderkit/ComponentRendererBase.java 2010-08-31 17:20:11 UTC (rev 19052)
@@ -1,96 +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 javax.faces.component.UIComponent;
-import java.util.HashMap;
-import java.util.Stack;
-
-/**
- * Components Base Renderer for all chameleon Skin's and components.
- * At most, make all common procedures and realise concrete work in "template" methods.
- *
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:58:52 $
- */
-public abstract class ComponentRendererBase extends RendererBase {
-
- /**
- * logger for common cases.
- */
- protected static final String COMPONENT_RENDERER_BASE = ComponentRendererBase.class.getName();
-
- public ComponentVariables getVariables(UIComponent component) {
- HashMap components;
- Stack stackComponentsVariables;
- ComponentVariables variables;
-
- components = (HashMap) component.getAttributes().get(COMPONENT_RENDERER_BASE);
-
- if (components == null) {
- components = new HashMap();
- component.getAttributes().put(COMPONENT_RENDERER_BASE, components);
- }
-
- stackComponentsVariables = (Stack) components.get(this.getClass().getName());
-
- if (stackComponentsVariables == null) {
- stackComponentsVariables = new Stack();
- components.put(COMPONENT_RENDERER_BASE, stackComponentsVariables);
- }
-
- if (stackComponentsVariables.empty()) {
- variables = new ComponentVariables();
- stackComponentsVariables.push(variables);
- } else {
- variables = (ComponentVariables) stackComponentsVariables.peek();
- }
-
- return variables;
- }
-
- public void removeVariables(UIComponent component) {
- HashMap components;
- Stack stackComponentsVariables;
- ComponentVariables variables;
-
- components = (HashMap) component.getAttributes().get(COMPONENT_RENDERER_BASE);
-
- if (components != null) {
- stackComponentsVariables = (Stack) component.getAttributes().get(this.getClass().getName());
-
- if (stackComponentsVariables != null) {
- if (!stackComponentsVariables.empty()) {
- stackComponentsVariables.pop();
- }
-
- if (stackComponentsVariables.empty()) {
- components.remove(this.getClass().getName());
- }
- }
-
- if (components.isEmpty()) {
- component.getAttributes().remove(COMPONENT_RENDERER_BASE);
- }
- }
- }
-}
Deleted: branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/renderkit/ComponentVariables.java
===================================================================
--- branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/renderkit/ComponentVariables.java 2010-08-31 16:59:42 UTC (rev 19051)
+++ branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/renderkit/ComponentVariables.java 2010-08-31 17:20:11 UTC (rev 19052)
@@ -1,99 +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 java.io.IOException;
-import java.io.Serializable;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * storing tempates variables
- *
- * @author ayukhovich(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.2 $ $Date: 2007/02/28 17:01:01 $
- */
-public class ComponentVariables implements Serializable {
-
- /**
- *
- */
- private static final long serialVersionUID = 4310787278096026676L;
- private transient Map<String, Object> variablesMap = new HashMap<String, Object>();
-
- /**
- * setting variable
- *
- * @param variableName
- * @param variable
- */
- public void setVariable(final String variableName, final Object variable) {
- variablesMap.put(variableName, variable);
- }
-
- /**
- * @param variableName
- * @return
- */
- public Object getVariable(final String variableName) {
- return variablesMap.get(variableName);
- }
-
- /**
- * @param variableName
- * @param addValue
- */
- public void addValueToVariable(final String variableName, final Object addValue) {
- Object variable = getVariable(variableName);
-
- if (variable == null) {
- return;
- }
-
- if (variable instanceof Integer) {
- addToValue(variableName, (Integer) variable, addValue);
- }
- }
-
- /**
- * @param variableName
- * @param variable
- * @param addValue
- */
- protected void addToValue(final String variableName, Integer variable, final Object addValue) {
- Integer retultValue;
-
- if (addValue instanceof Integer) {
- Integer intAddValue = (Integer) addValue;
-
- retultValue = new Integer(variable.intValue() + intAddValue.intValue());
- } else {
- retultValue = variable;
- }
-
- setVariable(variableName, retultValue);
- }
-
- private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException {
- variablesMap = new HashMap<String, Object>();
- }
-}
Deleted: branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/renderkit/ComponentsVariableResolver.java
===================================================================
--- branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/renderkit/ComponentsVariableResolver.java 2010-08-31 16:59:42 UTC (rev 19051)
+++ branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/renderkit/ComponentsVariableResolver.java 2010-08-31 17:20:11 UTC (rev 19052)
@@ -1,60 +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 javax.faces.component.UIComponent;
-
-/**
- * Resolve component variables
- *
- * @author ayukhovich(a)exadel.com (latest modification by $Author:
- * alexeyyukhovich $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:58:53 $
- */
-public final class ComponentsVariableResolver {
- private static final String COMPONENTS_VARIABLE_RESOLVER = ComponentsVariableResolver.class.getName();
-
- private ComponentsVariableResolver() {
- }
-
- private static String getAttributeName(RendererBase renderer) {
- return COMPONENTS_VARIABLE_RESOLVER + ":" + ((renderer != null) ? renderer.getClass().getName() : null);
- }
-
- public static ComponentVariables getVariables(RendererBase renderer, UIComponent component) {
- ComponentVariables variables;
- String attributeName = getAttributeName(renderer);
-
- variables = (ComponentVariables) component.getAttributes().get(attributeName);
-
- if (variables == null) {
- variables = new ComponentVariables();
- component.getAttributes().put(attributeName, variables);
- }
-
- return variables;
- }
-
- public static void removeVariables(RendererBase renderer, UIComponent component) {
- component.getAttributes().remove(getAttributeName(renderer));
- }
-}
Deleted: branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/renderkit/RendererBase.java
===================================================================
--- branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/renderkit/RendererBase.java 2010-08-31 16:59:42 UTC (rev 19051)
+++ branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/renderkit/RendererBase.java 2010-08-31 17:20:11 UTC (rev 19052)
@@ -1,284 +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 java.io.IOException;
-
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-import javax.faces.render.Renderer;
-
-import org.ajax4jsf.Messages;
-import org.richfaces.log.Logger;
-import org.richfaces.log.RichfacesLogger;
-import org.richfaces.renderkit.RenderKitUtils;
-import org.richfaces.skin.Skin;
-import org.richfaces.skin.SkinFactory;
-
-/**
- * Base Renderer for all chameleon Skin's and components.
- * At most, make all common procedures and realise concrete work in "template" methods.
- *
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:58:51 $
- */
-public abstract class RendererBase extends Renderer {
-
- private static final Logger LOG = RichfacesLogger.RENDERKIT.getLogger();
- private static final RendererUtils UTILS = RendererUtils.getInstance();
-
- private SkinFactory skinFactory = null;
-
- /*
- * (non-Javadoc)
- * @see javax.faces.render.Renderer#decode(javax.faces.context.FacesContext, javax.faces.component.UIComponent)
- */
- @Override
- public void decode(FacesContext context, UIComponent component) {
-
- // Test for correct parameters.
- checkNull(context, component, "decode");
-
- if (!getComponentClass().isInstance(component)) {
- throw new IllegalArgumentException(Messages.getMessage(Messages.COMPONENT_CLASS_ERROR, "",
- getComponentClass().getName()));
- }
-
- if (LOG.isDebugEnabled()) {
- LOG.debug(Messages.getMessage(Messages.START_DECODING_COMPONENT_INFO, component.getClientId(context),
- component.getClass().getName()));
- }
-
- preDecode(context, component);
-
- // TODO - create set od common decoders ( UIInput, ActionSource etc. ) for process decoding.
- if (component.isRendered()) {
- String behaviorEventName = RenderKitUtils.decodeBehaviors(context, component);
- if (behaviorEventName != null) {
- queueComponentEventForBehaviorEvent(context, component, behaviorEventName);
- }
-
- doDecode(context, component);
- }
- }
-
- protected void queueComponentEventForBehaviorEvent(FacesContext context, UIComponent component, String eventName) {
-
- }
-
- protected void preDecode(FacesContext context, UIComponent component) {
- }
-
- protected void preEncodeBegin(FacesContext context, UIComponent component) throws IOException {
- }
-
- /*
- * (non-Javadoc)
- * @see javax.faces.render.Renderer#encodeBegin(javax.faces.context.FacesContext, javax.faces.component.UIComponent)
- */
- @Override
- public void encodeBegin(FacesContext context, UIComponent component) throws IOException {
-
- // Test for correct parameters.
- checkForCorrectParams(context, component, "encodeBegin");
-
- if (LOG.isDebugEnabled()) {
- LOG.debug(Messages.getMessage(Messages.START_ENCODING_COMPONENT_INFO, component.getClientId(context),
- component.getClass().getName()));
- }
-
- preEncodeBegin(context, component);
-
- if (component.isRendered()) {
- ResponseWriter writer = context.getResponseWriter();
-
- doEncodeBegin(writer, context, component);
- }
- }
-
- private void checkForCorrectParams(FacesContext context, UIComponent component, String exceptionMessageParam) {
- checkNull(context, component, exceptionMessageParam);
-
- if (!getComponentClass().isInstance(component)) {
- throw new IllegalArgumentException(Messages.getMessage(Messages.COMPONENT_CLASS_ERROR,
- component.getClientId(context), getComponentClass().getName()));
- }
- }
-
- private void checkNull(Object context, Object component, String exceptionMessageParam) {
- if (context == null) {
- throw new NullPointerException(Messages.getMessage(Messages.CONTEXT_NULL_ERROR, exceptionMessageParam));
- }
-
- if (component == null) {
- throw new NullPointerException(Messages.getMessage(Messages.COMPONENT_NULL_ERROR, exceptionMessageParam));
- }
- }
-
- /*
- * (non-Javadoc)
- * @see javax.faces.render.Renderer#encodeChildren(javax.faces.context.FacesContext, javax.faces.component.UIComponent)
- */
- @Override
- public void encodeChildren(FacesContext context, UIComponent component) throws IOException {
-
- // Test for correct parameters.
- checkForCorrectParams(context, component, "encodeBegin");
-
- if (LOG.isDebugEnabled()) {
- LOG.debug(Messages.getMessage(Messages.CHILDREN_ENCODING_COMPONENT_INFO, component.getClientId(context),
- component.getClass().getName()));
- }
-
- preEncodeBegin(context, component);
-
- if (component.isRendered()) {
- ResponseWriter writer = context.getResponseWriter();
-
- doEncodeChildren(writer, context, component);
- }
- }
-
- /*
- * (non-Javadoc)
- * @see javax.faces.render.Renderer#encodeEnd(javax.faces.context.FacesContext, javax.faces.component.UIComponent)
- */
- @Override
- public void encodeEnd(FacesContext context, UIComponent component) throws IOException {
-
- // Test for correct parameters.
- checkForCorrectParams(context, component, "encodeEnd");
-
- if (component.isRendered()) {
- ResponseWriter writer = context.getResponseWriter();
-
- doEncodeEnd(writer, context, component);
- }
-
- if (LOG.isDebugEnabled()) {
- LOG.debug(Messages.getMessage(Messages.FINISH_ENCODING_COMPONENT_INFO, component.getClientId(context),
- component.getClass().getName()));
- }
- }
-
- // ==========================================================
- // Protected common methods - for all Renderer's
-
- /**
- * Calculate current Skin for rendering.
- *
- * @param context - current {@link FacesContext }
- * @return
- */
- protected Skin getSkin(FacesContext context) {
- if (skinFactory == null) {
- skinFactory = SkinFactory.getInstance();
- }
-
- return skinFactory.getSkin(context);
- }
-
- /**
- * Due to big number of common utility methods, base renderer divide to 2 classes - renderer and utils.
- * since use static methods of utility class breack object paradigm, we use getter for concrete util instance.
- * Developer can override any utility metod in 2 stages :
- * 1) Create subclass of {@link RendererUtils} and override utility method.
- * 2) Override this method for return instance of such subclass.
- *
- * @return Returns the utils.
- */
- public RendererUtils getUtils() {
- return UTILS;
- }
-
- /**
- * Get base component slass , targetted for this renderer. Used for check arguments in decode/encode.
- *
- * @return
- */
- protected Class<? extends UIComponent> getComponentClass() {
- //TODO - do we need this function?
- return UIComponent.class;
- }
-
- /**
- * Template method for custom decoding of concrete renderer.
- * All parameters checking if performed in original {@see decode } method.
- *
- * @param context
- * @param component
- */
- protected void doDecode(FacesContext context, UIComponent component) {
- }
-
- /**
- * Template method for custom start encoding of concrete renderer.
- * All parameters checking and writer is performed in original {@link encodeBegin } method.
- *
- * @param writer
- * @param context
- * @param component
- */
- protected void doEncodeBegin(ResponseWriter writer, FacesContext context, UIComponent component)
- throws IOException {
- }
-
- /**
- * @param writer
- * @param context
- * @param component
- */
- protected void doEncodeChildren(ResponseWriter writer, FacesContext context, UIComponent component)
- throws IOException {
-
- // Hook method, must be overriden in renderers with special children processing
- }
-
- /**
- * Template method for custom finish encoding of concrete renderer.
- * All parameters checking and writer is performed in original {@link encodeEnd } method.
- *
- * @param writer
- * @param context
- * @param component
- * @throws IOException
- */
- protected void doEncodeEnd(ResponseWriter writer, FacesContext context, UIComponent component) throws IOException {
- }
-
- /**
- * Render all children for given component.
- *
- * @param facesContext
- * @param component
- * @throws IOException
- */
- public void renderChildren(FacesContext facesContext, UIComponent component) throws IOException {
- if (component.getChildCount() > 0) {
- for (UIComponent child : component.getChildren()) {
- child.encodeAll(facesContext);
- }
- }
- }
-
-}
Deleted: branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/webapp/CacheContent.java
===================================================================
--- branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/webapp/CacheContent.java 2010-08-31 16:59:42 UTC (rev 19051)
+++ branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/webapp/CacheContent.java 2010-08-31 17:20:11 UTC (rev 19052)
@@ -1,337 +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.webapp;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.PrintWriter;
-import java.io.Serializable;
-import java.io.Writer;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import javax.faces.context.ExternalContext;
-import javax.servlet.ServletOutputStream;
-import javax.servlet.http.HttpServletResponse;
-
-import org.ajax4jsf.io.FastBufferOutputStream;
-import org.ajax4jsf.io.FastBufferWriter;
-import org.richfaces.log.Logger;
-import org.richfaces.log.RichfacesLogger;
-import org.richfaces.util.Util;
-
-/**
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:58:20 $
- */
-public class CacheContent implements Serializable {
- private static final long serialVersionUID = 8120940486890871177L;
- private static final Logger LOG = RichfacesLogger.WEBAPP.getLogger();
-
- boolean filledOutputWriter = false;
- boolean filledOutputStream = false;
-
- // content to send.
- private byte[] content = null;
- private String writerContent = null;
- private Map<String, Object> headers = new HashMap<String, Object>();
- private Integer contentLength;
- private String contentType;
-
- // private transient ByteArrayOutputStream outputStream ;
- private transient FastBufferOutputStream outputStream;
- private transient ServletOutputStream servletStream;
- private transient PrintWriter servletWriter;
- private transient FastBufferWriter stringOutputWriter;
-
- @Deprecated
- public void send(HttpServletResponse response) throws IOException {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Send saved content to http responce
- *
- * @param response
- * @throws IOException
- */
- public void send(ExternalContext externalContext) throws IOException {
- if (filledOutputStream) {
- OutputStream out = externalContext.getResponseOutputStream();
-
- if (content != null) {
- out.write(content);
- } else {
- this.outputStream.writeTo(out);
- }
-
- // out.flush();
- // out.close();
- } else if (filledOutputWriter) {
- Writer out = externalContext.getResponseOutputWriter();
-
- if (null != writerContent) {
- out.write(writerContent);
- } else {
- stringOutputWriter.writeTo(out);
- }
-
- // out.flush();
- // out.close();
- }
- }
-
- /**
- * Send saved headers to http responce.
- *
- * @param response
- */
- public void sendHeaders(ExternalContext externalContext) {
-
- // set real content-length.
- // / if (null != content) {
- int realContentLength = 0;
-
- if (filledOutputStream) {
- if ((null != content) && (content.length > 0)) {
- realContentLength = content.length;
- } else if ((null != outputStream) && (outputStream.getLength() > 0)) {
- realContentLength = outputStream.getLength();
- }
- } // TODO - calculate content-lenght for writer ?
-
- if ((realContentLength <= 0) && (contentLength != null)) {
- realContentLength = contentLength.intValue();
- }
-
- for (Iterator<Entry<String, Object>> iter = headers.entrySet().iterator(); iter.hasNext();) {
- Entry<String, Object> element = iter.next();
- String header = (String) element.getKey();
- Object headerValue = element.getValue();
-
- try {
- if (headerValue instanceof Long) {
- Long time = (Long) headerValue;
- String formattedDate = Util.formatHttpDate(time);
-
- externalContext.setResponseHeader(header, formattedDate);
- } else if (headerValue instanceof Integer) {
- Integer value = (Integer) headerValue;
-
- // Check real content length.
- if ("Content-Length".equals(header)) {
- if (realContentLength <= 0) {
- realContentLength = value.intValue();
- } else {
-
- // do nothing
- }
- } else {
- externalContext.setResponseHeader(header, value.toString());
- }
- } else {
-
- // Don't send "chunked" transfer-encoding type with real content-length
- if (!((realContentLength > 0) && "Transfer-Encoding".equals(header)
- && "chunked".equals(headerValue))) {
- externalContext.setResponseHeader(header, (String) headerValue);
- }
- }
- } catch (Exception e) {
- LOG.error("Error set response header " + header + "for value " + headerValue, e);
- }
-
- if (realContentLength > 0) {
- externalContext.setResponseContentLength(realContentLength);
- }
-
- if (null != contentType) {
- externalContext.setResponseContentType(this.contentType);
- }
- }
- }
-
- @Deprecated
- public void sendHeaders(HttpServletResponse response) {
- throw new UnsupportedOperationException();
- }
-
- public void setDateHeader(String name, long value) {
-
- // Expires not stored in cache - must be re-calculated for every
- // response.
- if (!"Expires".equals(name)) {
- headers.put(name, new Long(value));
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.framework.resource.ResourceContext#setHeader(java.lang.String,
- * java.lang.String)
- */
- public void setHeader(String name, String value) {
- headers.put(name, value);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.framework.resource.ResourceContext#setIntHeader(java.lang.String,
- * int)
- */
- public void setIntHeader(String name, int value) {
- headers.put(name, new Integer(value));
- }
-
- /**
- * Create UNIX command 'tee' like stream - send all data to servlet
- *
- * @param responseStream
- * @return
- */
- public OutputStream getOutputStream() {
- if (null == servletStream) {
- outputStream = new FastBufferOutputStream(1024);
- servletStream = new ServletOutputStream() {
- @Override
- public void close() {
- filledOutputStream = true;
- content = null;
- }
-
- @Override
- public void flush() {
- }
-
- @Override
- public void write(byte[] b, int off, int len) throws IOException {
- outputStream.write(b, off, len);
- }
-
- @Override
- public void write(byte[] b) throws IOException {
- outputStream.write(b);
- }
-
- @Override
- public void write(int b) throws IOException {
- outputStream.write(b);
- }
- };
- }
-
- return servletStream;
- }
-
- public PrintWriter getWriter() {
- if (null == servletWriter) {
- stringOutputWriter = new FastBufferWriter(1024);
-
- Writer out = new Writer() {
- @Override
- public void write(char[] cbuf, int off, int len) throws IOException {
- stringOutputWriter.write(cbuf, off, len);
- }
-
- @Override
- public void flush() throws IOException {
- }
-
- @Override
- public void close() throws IOException {
- filledOutputWriter = true;
- writerContent = null;
- }
- };
-
- servletWriter = new PrintWriter(out);
- }
-
- return servletWriter;
- }
-
- public void setContentType(String contentType) {
- this.contentType = contentType;
- }
-
- /**
- * @return Returns the contentType.
- */
- public String getContentType() {
- return contentType;
- }
-
- private void writeObject(java.io.ObjectOutputStream s) throws IOException {
- if (filledOutputStream) {
- if (outputStream != null) {
- content = outputStream.toByteArray();
- }
- } else if (filledOutputWriter) {
- if (stringOutputWriter != null) {
- char[] cs = stringOutputWriter.toCharArray();
-
- writerContent = new String(cs);
- }
- }
-
- s.defaultWriteObject();
- }
-
- @Deprecated
- public void flush(HttpServletResponse response) throws IOException {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Flush used output writer/stream, to fix https://jira.jboss.org/jira/browse/RF-4017
- *
- * @param response
- * @throws IOException
- */
- public void flush(ExternalContext externalContext) throws IOException {
- if (filledOutputStream) {
- OutputStream out = externalContext.getResponseOutputStream();
-
- out.flush();
- } else if (filledOutputWriter) {
- Writer out = externalContext.getResponseOutputWriter();
-
- out.flush();
- }
- }
-
- public int getContentLength() {
- if (contentLength == null) {
- throw new IllegalStateException("Content length hasn't been set yet!");
- }
-
- return contentLength.intValue();
- }
-
- public void setContentLength(int contentLength) {
- this.contentLength = contentLength;
- }
-}
Deleted: branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/webapp/PollEventsManager.java
===================================================================
--- branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/webapp/PollEventsManager.java 2010-08-31 16:59:42 UTC (rev 19051)
+++ branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/webapp/PollEventsManager.java 2010-08-31 17:20:11 UTC (rev 19052)
@@ -1,63 +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.webapp;
-
-import java.io.Serializable;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-
-import javax.servlet.ServletContext;
-
-/**
- * @author asmirnov
- */
-
-//TODO: deprecate
-public class PollEventsManager implements Serializable {
- public static final String EVENTS_MANAGER_KEY = PollEventsManager.class.getName();
- private static final long serialVersionUID = -6257285396790747665L;
-
- // TODO should use cache - push is application-scoped, not session-scoped
- private ConcurrentMap<String, PushEventsCounter> counters = new ConcurrentHashMap<String, PushEventsCounter>();
-
- public void init(ServletContext servletContext) {
- servletContext.setAttribute(EVENTS_MANAGER_KEY, this);
- }
-
- public PushEventsCounter getListener(String key) {
- PushEventsCounter counter = counters.get(key);
-
- if (counter != null) {
- return counter;
- } else {
- counter = new PushEventsCounter();
-
- PushEventsCounter oldCounter = counters.putIfAbsent(key, counter);
-
- if (oldCounter != null) {
- return oldCounter;
- } else {
- return counter;
- }
- }
- }
-}
Deleted: branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/webapp/taglib/AjaxActionsRule.java
===================================================================
--- branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/webapp/taglib/AjaxActionsRule.java 2010-08-31 16:59:42 UTC (rev 19051)
+++ branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/webapp/taglib/AjaxActionsRule.java 2010-08-31 17:20:11 UTC (rev 19052)
@@ -1,123 +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.webapp.taglib;
-
-import javax.faces.component.ActionSource;
-import javax.faces.component.ActionSource2;
-import javax.faces.event.ActionEvent;
-import javax.faces.event.MethodExpressionActionListener;
-import javax.faces.view.facelets.FaceletContext;
-import javax.faces.view.facelets.MetaRule;
-import javax.faces.view.facelets.Metadata;
-import javax.faces.view.facelets.MetadataTarget;
-import javax.faces.view.facelets.TagAttribute;
-
-/**
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/02/01 15:31:21 $
- */
-public class AjaxActionsRule extends MetaRule {
- public static final Class<?>[] ACTION_SIG = new Class[0];
- public static final Class<?>[] ACTION_LISTENER_SIG = new Class[]{ActionEvent.class};
- public static final AjaxActionsRule INSTANCE = new AjaxActionsRule();
-
- public AjaxActionsRule() {
- super();
- }
-
- @Override
- public Metadata applyRule(String name, TagAttribute attribute, MetadataTarget meta) {
- if (meta.isTargetInstanceOf(ActionSource.class)) {
- if ("action".equals(name)) {
- if (meta.isTargetInstanceOf(ActionSource2.class)) {
- return new ActionMapper2(attribute);
- } else {
- return new ActionMapper(attribute);
- }
- }
-
- if ("actionListener".equals(name)) {
- if (meta.isTargetInstanceOf(ActionSource2.class)) {
- return new ActionListenerMapper2(attribute);
- } else {
- return new ActionListenerMapper(attribute);
- }
- }
- }
-
- return null;
- }
-
- public static final class ActionListenerMapper extends Metadata {
- private final TagAttribute attr;
-
- public ActionListenerMapper(TagAttribute attr) {
- this.attr = attr;
- }
-
- public void applyMetadata(FaceletContext ctx, Object instance) {
- ((ActionSource) instance).addActionListener(
- new MethodExpressionActionListener(
- this.attr.getMethodExpression(ctx, null, AjaxActionsRule.ACTION_LISTENER_SIG)));
- }
- }
-
- static final class ActionListenerMapper2 extends Metadata {
- private final TagAttribute attr;
-
- public ActionListenerMapper2(TagAttribute attr) {
- this.attr = attr;
- }
-
- public void applyMetadata(FaceletContext ctx, Object instance) {
- ((ActionSource2) instance).addActionListener(
- new MethodExpressionActionListener(
- this.attr.getMethodExpression(ctx, null, AjaxActionsRule.ACTION_LISTENER_SIG)));
- }
- }
-
- public static final class ActionMapper extends Metadata {
- private final TagAttribute attr;
-
- public ActionMapper(TagAttribute attr) {
- this.attr = attr;
- }
-
- public void applyMetadata(FaceletContext ctx, Object instance) {
- ((ActionSource2) instance).setActionExpression(this.attr.getMethodExpression(ctx, String.class,
- AjaxActionsRule.ACTION_SIG));
- }
- }
-
- static final class ActionMapper2 extends Metadata {
- private final TagAttribute attr;
-
- public ActionMapper2(TagAttribute attr) {
- this.attr = attr;
- }
-
- public void applyMetadata(FaceletContext ctx, Object instance) {
- ((ActionSource2) instance).setActionExpression(this.attr.getMethodExpression(ctx, String.class,
- AjaxActionsRule.ACTION_SIG));
- }
- }
-}
Deleted: branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/webapp/taglib/EmptyHandler.java
===================================================================
--- branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/webapp/taglib/EmptyHandler.java 2010-08-31 16:59:42 UTC (rev 19051)
+++ branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/webapp/taglib/EmptyHandler.java 2010-08-31 17:20:11 UTC (rev 19052)
@@ -1,53 +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.webapp.taglib;
-
-import javax.el.ELException;
-import javax.faces.FacesException;
-import javax.faces.component.UIComponent;
-import javax.faces.view.facelets.FaceletContext;
-import javax.faces.view.facelets.FaceletException;
-import javax.faces.view.facelets.TagConfig;
-import javax.faces.view.facelets.TagHandler;
-import java.io.IOException;
-
-/**
- * This if "empty" facelets tag handler stub. This handler used to ignore tags on a page.
- * At most, it used to bypass <jsp:root> and other tags, so we can use same markup for an facelets an jsp pages.
- *
- * @author asmirnov
- */
-public class EmptyHandler extends TagHandler {
- public EmptyHandler(TagConfig config) {
- super(config);
- }
-
- /*
- * (non-Javadoc)
- * @see com.sun.facelets.FaceletHandler#apply(com.sun.facelets.FaceletContext, javax.faces.component.UIComponent)
- */
- public void apply(FaceletContext ctx, UIComponent parent)
- throws IOException, FacesException, FaceletException, ELException {
-
- this.nextHandler.apply(ctx, parent);
- }
-}
Deleted: branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/webapp/taglib/RowKeyConverterRule.java
===================================================================
--- branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/webapp/taglib/RowKeyConverterRule.java 2010-08-31 16:59:42 UTC (rev 19051)
+++ branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/webapp/taglib/RowKeyConverterRule.java 2010-08-31 17:20:11 UTC (rev 19052)
@@ -1,94 +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.webapp.taglib;
-
-import org.richfaces.component.UIDataAdaptor;
-
-import javax.faces.convert.Converter;
-import javax.faces.view.facelets.FaceletContext;
-import javax.faces.view.facelets.MetaRule;
-import javax.faces.view.facelets.Metadata;
-import javax.faces.view.facelets.MetadataTarget;
-import javax.faces.view.facelets.TagAttribute;
-
-/**
- * Apply rowKeyConverter to component
- *
- * @author Maksim Kaszynski
- * @since 3.3.1
- */
-public class RowKeyConverterRule extends MetaRule {
- public static final RowKeyConverterRule INSTANCE = new RowKeyConverterRule();
-
- /*
- * (non-Javadoc)
- *
- * @see com.sun.facelets.tag.MetaRule#applyRule(java.lang.String,
- * com.sun.facelets.tag.TagAttribute,
- * com.sun.facelets.tag.MetadataTarget)
- */
- @Override
- public Metadata applyRule(String name, TagAttribute attribute, MetadataTarget meta) {
- if (meta.isTargetInstanceOf(UIDataAdaptor.class)) {
- if ("rowKeyConverter".equals(name)) {
- if (attribute.isLiteral()) {
- return new StaticConverterMetadata(attribute.getValue());
- } else {
- return new DynamicConverterMetaData(attribute);
- }
- }
- }
-
- return null;
- }
-
- static final class DynamicConverterMetaData extends Metadata {
- private final TagAttribute attribute;
-
- public DynamicConverterMetaData(TagAttribute attribute) {
- super();
- this.attribute = attribute;
- }
-
- @Override
- public void applyMetadata(FaceletContext ctx, Object instance) {
- ((UIDataAdaptor) instance).setValueExpression("rowKeyConverter",
- attribute.getValueExpression(ctx, Converter.class));
- }
- }
-
- static final class StaticConverterMetadata extends Metadata {
- private final String converterId;
-
- public StaticConverterMetadata(String converterId) {
- super();
- this.converterId = converterId;
- }
-
- @Override
- public void applyMetadata(FaceletContext ctx, Object instance) {
- Converter converter = ctx.getFacesContext().getApplication().createConverter(converterId);
-
- ((UIDataAdaptor) instance).setRowKeyConverter(converter);
- }
- }
-}
Deleted: branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/webapp/taglib/package-info.java
===================================================================
--- branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/webapp/taglib/package-info.java 2010-08-31 16:59:42 UTC (rev 19051)
+++ branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/webapp/taglib/package-info.java 2010-08-31 17:20:11 UTC (rev 19052)
@@ -1,4 +0,0 @@
-/**
- * Basic tag classes
- */
-package org.ajax4jsf.webapp.taglib;
Deleted: branches/RF-7560/core/impl/src/main/java/org/richfaces/component/EnclosingFormRequiredException.java
===================================================================
--- branches/RF-7560/core/impl/src/main/java/org/richfaces/component/EnclosingFormRequiredException.java 2010-08-31 16:59:42 UTC (rev 19051)
+++ branches/RF-7560/core/impl/src/main/java/org/richfaces/component/EnclosingFormRequiredException.java 2010-08-31 17:20:11 UTC (rev 19052)
@@ -1,52 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces - Ajax4jsf Component Library
- *
- * 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.component;
-
-import javax.faces.FacesException;
-
-/**
- * @author Filip Antonov - mailto:fantonov@exadel.com
- * created 08.02.2007
- */
-public class EnclosingFormRequiredException extends FacesException {
-
- /**
- *
- */
- private static final long serialVersionUID = 1877777524838776600L;
-
- public EnclosingFormRequiredException() {
- super();
- }
-
- public EnclosingFormRequiredException(String message) {
- super(message);
- }
-
- public EnclosingFormRequiredException(Throwable cause) {
- super(cause);
- }
-
- public EnclosingFormRequiredException(String message, Throwable cause) {
- super(message, cause);
- }
-}
Deleted: branches/RF-7560/core/impl/src/main/java/org/richfaces/component/RowKeyContextEventWrapper.java
===================================================================
--- branches/RF-7560/core/impl/src/main/java/org/richfaces/component/RowKeyContextEventWrapper.java 2010-08-31 16:59:42 UTC (rev 19051)
+++ branches/RF-7560/core/impl/src/main/java/org/richfaces/component/RowKeyContextEventWrapper.java 2010-08-31 17:20:11 UTC (rev 19052)
@@ -1,74 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright ${year}, 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.component;
-
-import javax.faces.component.UIComponent;
-import javax.faces.event.FacesEvent;
-import javax.faces.event.FacesListener;
-import javax.faces.event.PhaseId;
-
-/**
- * @author Nick Belaevski
- */
-class RowKeyContextEventWrapper extends FacesEvent {
-
- /**
- *
- */
- private static final long serialVersionUID = -869970815228914529L;
- private FacesEvent event;
- private Object rowKey;
-
- public RowKeyContextEventWrapper(UIComponent component, FacesEvent event, Object rowKey) {
- super(component);
- this.event = event;
- this.rowKey = rowKey;
- }
-
- public FacesEvent getFacesEvent() {
- return this.event;
- }
-
- public PhaseId getPhaseId() {
- return this.event.getPhaseId();
- }
-
- public void setPhaseId(PhaseId phaseId) {
- this.event.setPhaseId(phaseId);
- }
-
- public boolean isAppropriateListener(FacesListener listener) {
- return false;
- }
-
- public void processListener(FacesListener listener) {
- throw new IllegalStateException();
- }
-
- /**
- * @return the rowKey
- */
- public Object getRowKey() {
- return rowKey;
- }
-}
Deleted: branches/RF-7560/core/impl/src/main/java/org/richfaces/component/SavedState.java
===================================================================
--- branches/RF-7560/core/impl/src/main/java/org/richfaces/component/SavedState.java 2010-08-31 16:59:42 UTC (rev 19051)
+++ branches/RF-7560/core/impl/src/main/java/org/richfaces/component/SavedState.java 2010-08-31 17:20:11 UTC (rev 19052)
@@ -1,141 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright ${year}, 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.component;
-
-import java.io.Serializable;
-
-import javax.faces.component.EditableValueHolder;
-import javax.faces.component.UIForm;
-
-import org.ajax4jsf.component.IterationStateHolder;
-
-//from RI
-
-/**
- * This class keep values of {@link EditableValueHolder} row-sensitive
- * fields.
- *
- * @author shura
- */
-final class SavedState implements Serializable {
-
- public static final SavedState EMPTY = new SavedState();
-
- private static final long serialVersionUID = -1563864456074187422L;
-
- private boolean valid = true;
- private boolean localValueSet;
- private boolean submitted;
- private Object submittedValue;
- private Object value;
-
- private Object iterationState;
-
- public SavedState() {
- super();
- }
-
- public SavedState(EditableValueHolder evh) {
- super();
- this.value = evh.getLocalValue();
- this.valid = evh.isValid();
- this.submittedValue = evh.getSubmittedValue();
- this.localValueSet = evh.isLocalValueSet();
- }
-
- public SavedState(IterationStateHolder ish) {
- super();
-
- this.iterationState = ish.getIterationState();
- }
-
- public SavedState(UIForm form) {
- super();
- this.submitted = form.isSubmitted();
- }
-
- Object getSubmittedValue() {
- return this.submittedValue;
- }
-
- void setSubmittedValue(Object submittedValue) {
- this.submittedValue = submittedValue;
- }
-
- boolean isValid() {
- return this.valid;
- }
-
- void setValid(boolean valid) {
- this.valid = valid;
- }
-
- Object getValue() {
- return this.value;
- }
-
- void setValue(Object value) {
- this.value = value;
- }
-
- boolean isLocalValueSet() {
- return this.localValueSet;
- }
-
- void setLocalValueSet(boolean localValueSet) {
- this.localValueSet = localValueSet;
- }
-
- Object getIterationState() {
- return iterationState;
- }
-
- void setIterationState(Object iterationState) {
- this.iterationState = iterationState;
- }
-
- @Override
- public String toString() {
- if (iterationState != null) {
- return "iterationState: " + iterationState;
- } else {
- return "submittedValue: " + submittedValue + " value: " + value + " localValueSet: " + localValueSet
- + " submitted: " + submitted;
- }
- }
-
- public void apply(EditableValueHolder evh) {
- evh.setValue(this.value);
- evh.setValid(this.valid);
- evh.setSubmittedValue(this.submittedValue);
- evh.setLocalValueSet(this.localValueSet);
- }
-
- public void apply(IterationStateHolder ish) {
- ish.setIterationState(iterationState);
- }
-
- public void apply(UIForm form) {
- form.setSubmitted(this.submitted);
- }
-}
Deleted: branches/RF-7560/core/impl/src/main/java/org/richfaces/component/SequenceIterationStatus.java
===================================================================
--- branches/RF-7560/core/impl/src/main/java/org/richfaces/component/SequenceIterationStatus.java 2010-08-31 16:59:42 UTC (rev 19051)
+++ branches/RF-7560/core/impl/src/main/java/org/richfaces/component/SequenceIterationStatus.java 2010-08-31 17:20:11 UTC (rev 19052)
@@ -1,130 +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.component;
-
-import java.io.Serializable;
-
-import javax.servlet.jsp.jstl.core.LoopTagStatus;
-
-/**
- * @author Nick Belaevski
- *
- */
-public final class SequenceIterationStatus implements LoopTagStatus, Serializable {
-
- private static final long serialVersionUID = 1968212566967489719L;
-
- private Integer begin;
-
- private Integer count;
-
- private Integer end;
-
- private int index;
-
- private Integer rowCount;
-
- private boolean first;
-
- private boolean last;
-
- private boolean even;
-
- public SequenceIterationStatus(Integer begin, Integer end, int index, Integer rowCount) {
- int iBegin = (begin != null ? begin.intValue() : 0);
-
- int iRowCountEnd = (rowCount != null ? rowCount.intValue() - 1 : Integer.MAX_VALUE);
- int iEnd = (end != null ? end.intValue() : iRowCountEnd);
- int iLastIdx = Math.min(iEnd, iRowCountEnd);
-
- this.begin = begin;
- this.end = iEnd;
- this.index = index;
- this.rowCount = rowCount;
-
- this.first = (index == iBegin);
-
- this.last = (index >= iLastIdx);
-
- this.count = (index - iBegin) + 1;
- this.even = ((count % 2) == 0);
- }
-
- public Integer getBegin() {
- return begin;
- }
-
- public int getCount() {
- return count;
- }
-
- public Object getCurrent() {
- return null;
- }
-
- public Integer getEnd() {
- return end;
- }
-
- public int getIndex() {
- return index;
- }
-
- public Integer getStep() {
- return 1;
- }
-
- public boolean isFirst() {
- return first;
- }
-
- public boolean isLast() {
- return last;
- }
-
- public Integer getRowCount() {
- return rowCount;
- }
-
- public boolean isEven() {
- return even;
- }
-
- public boolean isOdd() {
- return !isEven();
- }
-
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder();
- sb.append("begin= " + begin);
- sb.append(", end= " + end);
- sb.append(", index= " + index);
- sb.append(", count= " + count);
- sb.append(", first= " + first);
- sb.append(", last= " + last);
- sb.append(", even= " + even);
- sb.append(", rowCount= " + rowCount);
-
- return sb.toString();
- }
-}
Deleted: branches/RF-7560/core/impl/src/main/java/org/richfaces/component/UIDataAdaptor.java
===================================================================
--- branches/RF-7560/core/impl/src/main/java/org/richfaces/component/UIDataAdaptor.java 2010-08-31 16:59:42 UTC (rev 19051)
+++ branches/RF-7560/core/impl/src/main/java/org/richfaces/component/UIDataAdaptor.java 2010-08-31 17:20:11 UTC (rev 19052)
@@ -1,1516 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright ${year}, 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.component;
-
-import java.io.IOException;
-import java.io.Serializable;
-import java.text.MessageFormat;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
-import javax.el.ValueExpression;
-import javax.faces.FacesException;
-import javax.faces.application.Application;
-import javax.faces.application.FacesMessage;
-import javax.faces.component.ContextCallback;
-import javax.faces.component.EditableValueHolder;
-import javax.faces.component.NamingContainer;
-import javax.faces.component.PartialStateHolder;
-import javax.faces.component.StateHelper;
-import javax.faces.component.StateHolder;
-import javax.faces.component.UIComponent;
-import javax.faces.component.UIComponentBase;
-import javax.faces.component.UIForm;
-import javax.faces.component.UINamingContainer;
-import javax.faces.component.UIViewRoot;
-import javax.faces.component.UniqueIdVendor;
-import javax.faces.component.visit.VisitCallback;
-import javax.faces.component.visit.VisitContext;
-import javax.faces.component.visit.VisitResult;
-import javax.faces.context.FacesContext;
-import javax.faces.convert.Converter;
-import javax.faces.convert.ConverterException;
-import javax.faces.event.AbortProcessingException;
-import javax.faces.event.ComponentSystemEvent;
-import javax.faces.event.ComponentSystemEventListener;
-import javax.faces.event.FacesEvent;
-import javax.faces.event.ListenerFor;
-import javax.faces.event.PhaseId;
-import javax.faces.event.PostValidateEvent;
-import javax.faces.event.PreRenderComponentEvent;
-import javax.faces.event.PreValidateEvent;
-import javax.faces.render.Renderer;
-
-import org.ajax4jsf.component.IterationStateHolder;
-import org.ajax4jsf.model.DataComponentState;
-import org.ajax4jsf.model.DataVisitResult;
-import org.ajax4jsf.model.DataVisitor;
-import org.ajax4jsf.model.ExtendedDataModel;
-import org.ajax4jsf.model.Range;
-import org.ajax4jsf.model.SerializableDataModel;
-import org.richfaces.context.ExtendedVisitContext;
-import org.richfaces.log.Logger;
-import org.richfaces.log.RichfacesLogger;
-
-/**
- * Base class for iterable components, like dataTable, Tomahawk dataList, Facelets repeat, tree etc., with support for
- * partial rendering on AJAX responces for one or more selected iterations.
- *
- * @author shura
- */
-@ListenerFor(systemEventClass = PreRenderComponentEvent.class)
-public abstract class UIDataAdaptor extends UIComponentBase implements NamingContainer,
- UniqueIdVendor, IterationStateHolder, ComponentSystemEventListener {
-
- /**
- * <p>The standard component family for this component.</p>
- */
- public static final String COMPONENT_FAMILY = "org.richfaces.Data";
-
- /**
- * <p>The standard component type for this component.</p>
- */
- public static final String COMPONENT_TYPE = "org.richfaces.Data";
-
- private static final class IterationState implements Serializable {
-
- private static final long serialVersionUID = -3502645160277416066L;
-
- private DataComponentState componentState;
-
- private Object savedComponentState;
-
- private boolean componentStateIsStateHolder;
-
- private ExtendedDataModel<?> dataModel;
-
- public IterationState() {
- super();
- }
-
- public IterationState(DataComponentState componentState, ExtendedDataModel<?> dataModel) {
- super();
- this.componentState = componentState;
- this.dataModel = dataModel;
- }
-
- public ExtendedDataModel<?> getDataModel() {
- return dataModel;
- }
-
- public DataComponentState getComponentState() {
- return componentState;
- }
-
- /**
- * @param uiDataAdaptor
- */
- public void restoreComponentState(UIDataAdaptor uiDataAdaptor) {
- if (savedComponentState != null && componentStateIsStateHolder) {
- componentState = uiDataAdaptor.createComponentState();
- ((StateHolder) componentState).restoreState(FacesContext.getCurrentInstance(), savedComponentState);
- savedComponentState = null;
- }
- }
-
- final Object saveState() {
- boolean localComponentStateIsHolder = false;
- Object localSavedComponentState = null;
-
- if (componentState != null) {
- if (componentState instanceof StateHolder) {
- localComponentStateIsHolder = true;
-
- StateHolder stateHolder = (StateHolder) componentState;
- if (!stateHolder.isTransient()) {
- localSavedComponentState = stateHolder.saveState(FacesContext.getCurrentInstance());
- }
- } else {
- if (componentState instanceof Serializable) {
- localSavedComponentState = componentState;
- }
- }
- }
-
- Object savedSerializableModel = null;
-
- if (componentState != null && dataModel != null) {
- // TODO handle model serialization - "execute" model
- savedSerializableModel = dataModel.getSerializableModel(componentState.getRange());
- }
-
- if (localSavedComponentState != null || savedSerializableModel != null) {
- return new Object[] {
- localComponentStateIsHolder,
- localSavedComponentState,
- savedSerializableModel
- };
- } else {
- return null;
- }
- }
-
- final void restoreState(Object stateObject) {
- if (stateObject != null) {
- Object[] state = (Object[]) stateObject;
- componentStateIsStateHolder = Boolean.TRUE.equals(state[0]);
- Object localSavedComponentState = state[1];
-
- if (componentStateIsStateHolder) {
- savedComponentState = localSavedComponentState;
- } else {
- componentState = (DataComponentState) localSavedComponentState;
- }
-
- dataModel = (ExtendedDataModel<?>) state[2];
- }
- }
-
- private void writeObject(java.io.ObjectOutputStream out)
- throws IOException {
-
- out.writeObject(saveState());
- }
-
- private void readObject(java.io.ObjectInputStream in)
- throws IOException, ClassNotFoundException {
-
- restoreState(in.readObject());
- }
- }
-
- private static final VisitCallback STUB_CALLBACK = new VisitCallback() {
-
- public VisitResult visit(VisitContext context, UIComponent target) {
- return VisitResult.ACCEPT;
- }
- };
-
- private static final Logger LOG = RichfacesLogger.COMPONENTS.getLogger();
-
- /**
- * Visitor for process decode on children components.
- */
- protected ComponentVisitor decodeVisitor = new ComponentVisitor() {
- @Override
- public void processComponent(FacesContext context, UIComponent c, Object argument) {
- c.processDecodes(context);
- }
- };
-
- /**
- * Visitor for process validation phase
- */
- protected ComponentVisitor validateVisitor = new ComponentVisitor() {
- @Override
- public void processComponent(FacesContext context, UIComponent c, Object argument) {
- c.processValidators(context);
- }
- };
-
- /**
- * Visitor for process update model phase.
- */
- protected ComponentVisitor updateVisitor = new ComponentVisitor() {
- @Override
- public void processComponent(FacesContext context, UIComponent c, Object argument) {
- c.processUpdates(context);
- }
- };
-
- //TODO nick - PSH support?
- private DataComponentState componentState = null;
- private ExtendedDataModel<?> extendedDataModel = null;
- private Object rowKey = null;
-
- private String clientId;
-
- private Object originalVarValue;
-
- private Converter rowKeyConverter;
-
- /**
- * @author Nick Belaevski
- *
- */
- private final class DataVisitorForVisitTree implements DataVisitor {
- /**
- *
- */
- private final VisitCallback callback;
- /**
- *
- */
- private final VisitContext visitContext;
- /**
- *
- */
- private boolean visitResult;
-
- /**
- * @param callback
- * @param visitContext
- */
- private DataVisitorForVisitTree(VisitCallback callback, VisitContext visitContext) {
- this.callback = callback;
- this.visitContext = visitContext;
- }
-
- public DataVisitResult process(FacesContext context, Object rowKey, Object argument) {
- setRowKey(context, rowKey);
-
- if (isRowAvailable()) {
- VisitResult result = VisitResult.ACCEPT;
-
- if (visitContext instanceof ExtendedVisitContext) {
- result = visitContext.invokeVisitCallback(UIDataAdaptor.this, callback);
- if (VisitResult.COMPLETE.equals(result)) {
- visitResult = true;
-
- return DataVisitResult.STOP;
- }
- }
-
- if (VisitResult.ACCEPT.equals(result)) {
- Iterator<UIComponent> dataChildrenItr = dataChildren();
-
- while (dataChildrenItr.hasNext()) {
- UIComponent dataChild = dataChildrenItr.next();
-
- if (dataChild.visitTree(visitContext, callback)) {
- visitResult = true;
-
- return DataVisitResult.STOP;
- }
- }
- }
- }
-
- return DataVisitResult.CONTINUE;
- }
-
- public boolean getVisitResult() {
- return visitResult;
- }
- }
-
- private enum PropertyKeys {
- lastId, var, rowKeyVar, stateVar, childState, rowKeyConverter, rowKeyConverterSet, keepSaved
- }
-
- public UIDataAdaptor() {
- super();
- }
-
- protected Map<String, Object> getVariablesMap(FacesContext facesContext) {
- return facesContext.getExternalContext().getRequestMap();
- }
-
- /*
- * (non-Javadoc)
- * @see javax.faces.component.UIComponent#getFamily()
- */
- @Override
- public String getFamily() {
- return COMPONENT_FAMILY;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.component.AjaxChildrenEncoder#encodeAjaxChild(javax.faces.context.FacesContext,
- * java.lang.String, java.util.Set, java.util.Set)
- */
- public void encodeAjaxChild(FacesContext context, String path, Set<String> ids, Set<String> renderedAreas)
- throws IOException {
-
- // TODO Auto-generated method stub
- }
-
- /*
- * (non-Javadoc)
- * @see javax.faces.component.UniqueIdVendor#createUniqueId(javax.faces.context.FacesContext, java.lang.String)
- */
- public String createUniqueId(FacesContext context, String seed) {
- Integer i = (Integer) getStateHelper().get(PropertyKeys.lastId);
- int lastId = (i != null) ? i : 0;
-
- getStateHelper().put(PropertyKeys.lastId, ++lastId);
-
- return UIViewRoot.UNIQUE_ID_PREFIX + ((seed == null) ? lastId : seed);
- }
-
- /**
- * @return the rowKey
- */
- public Object getRowKey() {
- return rowKey;
- }
-
- /**
- * Setup current row by key. Perform same functionality as
- * {@link javax.faces.component.UIData#setRowIndex(int)}, but for key object - it may be not only
- * row number in sequence data, but, for example - path to current node in
- * tree.
- *
- * @param faces -
- * current FacesContext
- * @param key new key value.
- */
- public void setRowKey(FacesContext facesContext, Object rowKey) {
- this.saveChildState(facesContext);
- this.rowKey = rowKey;
- this.clientId = null;
- getExtendedDataModel().setRowKey(rowKey);
-
- boolean rowSelected = (rowKey != null) && isRowAvailable();
-
- setupVariable(facesContext, rowSelected);
- this.restoreChildState(facesContext);
- }
-
- /**
- * Save values of {@link EditableValueHolder} fields before change current
- * row.
- *
- * @param faces
- */
- protected void saveChildState(FacesContext facesContext) {
- Iterator<UIComponent> itr = dataChildren();
-
- while (itr.hasNext()) {
- this.saveChildState(facesContext, (UIComponent) itr.next());
- }
- }
-
- /**
- * @param facesContext
- * @param next
- * @param childState
- */
- protected void saveChildState(FacesContext facesContext, UIComponent component) {
-
- // TODO - is it right?
- if (component.isTransient()) {
- return;
- }
-
- SavedState state = null;
-
- if (component instanceof IterationStateHolder) {
- IterationStateHolder ish = (IterationStateHolder) component;
-
- state = new SavedState(ish);
- } else if (component instanceof EditableValueHolder) {
- EditableValueHolder evh = (EditableValueHolder) component;
-
- state = new SavedState(evh);
- } else if (component instanceof UIForm) {
- UIForm form = (UIForm) component;
-
- state = new SavedState(form);
- }
-
- if (state != null) {
-
- // TODO - use local map - children save their state themselves using visitors
- getStateHelper().put(PropertyKeys.childState, component.getClientId(facesContext), state);
- }
-
- if (component.getChildCount() > 0) {
- for (UIComponent child : component.getChildren()) {
- saveChildState(facesContext, child);
- }
- }
-
- if (component.getFacetCount() > 0) {
- for (UIComponent facet : component.getFacets().values()) {
- saveChildState(facesContext, facet);
- }
- }
- }
-
- protected Iterator<UIComponent> dataChildren() {
- if (getChildCount() > 0) {
- return getChildren().iterator();
- } else {
- return Collections.<UIComponent>emptyList().iterator();
- }
- }
-
- protected Iterator<UIComponent> fixedChildren() {
- if (getFacetCount() > 0) {
- return getFacets().values().iterator();
- } else {
- return Collections.<UIComponent>emptyList().iterator();
- }
- }
-
- /**
- * @param facesContext
- */
- protected void restoreChildState(FacesContext facesContext) {
- Iterator<UIComponent> itr = dataChildren();
-
- while (itr.hasNext()) {
- this.restoreChildState(facesContext, (UIComponent) itr.next());
- }
- }
-
- /**
- * Restore values of {@link EditableValueHolder} fields after change current
- * row.
- *
- * @param facesContext
- * @param next
- * @param childState
- */
- protected void restoreChildState(FacesContext facesContext, UIComponent component) {
- String id = component.getId();
-
- component.setId(id); // Forces client id to be reset
-
- SavedState savedState = null;
- @SuppressWarnings("unchecked")
- Map<String, SavedState> savedStatesMap = (Map<String, SavedState>) getStateHelper()
- .get(PropertyKeys.childState);
-
- if (savedStatesMap != null) {
- savedState = savedStatesMap.get(component.getClientId(facesContext));
- }
-
- if (savedState == null) {
- savedState = SavedState.EMPTY;
- }
-
- if (component instanceof IterationStateHolder) {
- IterationStateHolder ish = (IterationStateHolder) component;
-
- savedState.apply(ish);
- } else if (component instanceof EditableValueHolder) {
- EditableValueHolder evh = (EditableValueHolder) component;
-
- savedState.apply(evh);
- } else if (component instanceof UIForm) {
- UIForm form = (UIForm) component;
-
- savedState.apply(form);
- }
-
- if (component.getChildCount() > 0) {
- for (UIComponent child : component.getChildren()) {
- restoreChildState(facesContext, child);
- }
- }
-
- if (component.getFacetCount() > 0) {
- for (UIComponent facet : component.getFacets().values()) {
- restoreChildState(facesContext, facet);
- }
- }
- }
-
- public void setRowKey(Object rowKey) {
- setRowKey(getFacesContext(), rowKey);
- }
-
- /*
- * (non-Javadoc)
- * @see javax.faces.component.UIComponentBase#queueEvent(javax.faces.event.FacesEvent)
- */
- @Override
- public void queueEvent(FacesEvent event) {
- super.queueEvent(new RowKeyContextEventWrapper(this, event, getRowKey()));
- }
-
- /*
- * (non-Javadoc)
- * @see javax.faces.component.UIComponentBase#broadcast(javax.faces.event.FacesEvent)
- */
- @Override
- public void broadcast(FacesEvent event) throws AbortProcessingException {
- if (!(event instanceof RowKeyContextEventWrapper)) {
- if (!broadcastLocal(event)) {
- super.broadcast(event);
- }
-
- return;
- }
-
- FacesContext context = getFacesContext();
-
- // Set up the correct context and fire our wrapped event
- RowKeyContextEventWrapper revent = (RowKeyContextEventWrapper) event;
- Object oldRowKey = getRowKey();
-
- setRowKey(context, revent.getRowKey());
-
- FacesEvent rowEvent = revent.getFacesEvent();
- UIComponent source = rowEvent.getComponent();
- UIComponent compositeParent = null;
-
- try {
- if (!UIComponent.isCompositeComponent(source)) {
- compositeParent = UIComponent.getCompositeComponentParent(source);
- }
-
- if (compositeParent != null) {
- compositeParent.pushComponentToEL(context, null);
- }
-
- source.pushComponentToEL(context, null);
- source.broadcast(rowEvent);
- } finally {
- source.popComponentFromEL(context);
-
- if (compositeParent != null) {
- compositeParent.popComponentFromEL(context);
- }
- }
-
- setRowKey(context, oldRowKey);
- }
-
- /**
- * Process events targetted for concrete implementation. Hook method called
- * from {@link #broadcast(FacesEvent)}
- *
- * @param event -
- * processed event.
- * @return true if event processed, false if component must continue
- * processing.
- */
-
- // TODO - is it still actual?
- protected boolean broadcastLocal(FacesEvent event) {
- return false;
- }
-
- /**
- * @return the extendedDataModel
- */
- protected ExtendedDataModel<?> getExtendedDataModel() {
- if (extendedDataModel == null) {
- extendedDataModel = createExtendedDataModel();
- }
-
- return extendedDataModel;
- }
-
- /**
- * @return
- */
- protected abstract ExtendedDataModel<?> createExtendedDataModel();
-
- /**
- * @param extendedDataModel the extendedDataModel to set
- */
- protected void setExtendedDataModel(ExtendedDataModel<?> extendedDataModel) {
- this.extendedDataModel = extendedDataModel;
- }
-
- public String getVar() {
- return (String) getStateHelper().get(PropertyKeys.var);
- }
-
- public void setVar(String var) {
- getStateHelper().put(PropertyKeys.var, var);
- }
-
- public String getRowKeyVar() {
- return (String) getStateHelper().get(PropertyKeys.rowKeyVar);
- }
-
- public void setRowKeyVar(String rowKeyVar) {
- getStateHelper().put(PropertyKeys.rowKeyVar, rowKeyVar);
- }
-
- public String getStateVar() {
- return (String) getStateHelper().get(PropertyKeys.stateVar);
- }
-
- public void setStateVar(String stateVar) {
- getStateHelper().put(PropertyKeys.stateVar, stateVar);
- }
-
- //XXX - review and probably remove - useful method, should be left
- public int getRowCount() {
- return getExtendedDataModel().getRowCount();
- }
-
- public Object getRowData() {
- return getExtendedDataModel().getRowData();
- }
-
- public boolean isRowAvailable() {
- return getExtendedDataModel().isRowAvailable();
- }
-
- /**
- * Boolean attribute that defines whether this iteration component will reset saved children's state
- * before rendering. By default state is reset if there are no faces messages with severity error or higher.
- * @return
- */
- public boolean isKeepSaved() {
- Object value = getStateHelper().eval(PropertyKeys.keepSaved);
-
- if (value == null) {
- return keepSaved(getFacesContext());
- } else {
- return Boolean.valueOf(value.toString());
- }
- }
-
- public void setKeepSaved(boolean keepSaved) {
- getStateHelper().put(PropertyKeys.keepSaved, keepSaved);
- }
-
- /**
- * Setup EL variable for different iteration. Value of row data and
- * component state will be put into request scope attributes with names
- * given by "var" and "varState" bean properties.
- * <p/>
- * Changed: does not check for row availability now
- *
- * @param faces current faces context
- * @param localModel
- * @param rowSelected
- */
- protected void setupVariable(FacesContext faces, boolean rowSelected) {
- Map<String, Object> attrs = getVariablesMap(faces);
-
- if (rowSelected) {
-
- // Current row data.
- setupVariable(getVar(), attrs, getRowData());
-
- // Component state variable.
- setupVariable(getStateVar(), attrs, getComponentState());
-
- // Row key Data variable.
- setupVariable(getRowKeyVar(), attrs, getRowKey());
- } else {
- removeVariable(getVar(), attrs);
- removeVariable(getStateVar(), attrs);
- removeVariable(getRowKeyVar(), attrs);
- }
- }
-
- /**
- * @return
- */
- public DataComponentState getComponentState() {
- if (componentState != null) {
- return componentState;
- }
-
- ValueExpression componentStateExpression = getValueExpression("componentState");
-
- if (componentStateExpression != null) {
- componentState = (DataComponentState) componentStateExpression.getValue(getFacesContext().getELContext());
- }
-
- if (componentState == null) {
- componentState = createComponentState();
-
- if ((componentStateExpression != null)
- && !componentStateExpression.isReadOnly(getFacesContext().getELContext())) {
- componentStateExpression.setValue(getFacesContext().getELContext(), componentState);
- }
- }
-
- return componentState;
- }
-
- protected abstract DataComponentState createComponentState();
-
- /**
- * @param var
- * @param attrs
- * @param rowData
- */
- private void setupVariable(String var, Map<String, Object> attrs, Object rowData) {
- if (var != null) {
- attrs.put(var, rowData);
- }
- }
-
- /**
- * @param var
- * @param attrs
- * @param rowData
- */
- private void removeVariable(String var, Map<String, Object> attrs) {
- if (var != null) {
- attrs.remove(var);
- }
- }
-
- public Converter getRowKeyConverter() {
- if (this.rowKeyConverter != null) {
- return this.rowKeyConverter;
- }
-
- return (Converter) getStateHelper().eval(PropertyKeys.rowKeyConverter);
- }
-
- public void setRowKeyConverter(Converter converter) {
- StateHelper stateHelper = getStateHelper();
- if (initialStateMarked()) {
- stateHelper.put(PropertyKeys.rowKeyConverterSet, Boolean.TRUE);
- }
-
- this.rowKeyConverter = converter;
- }
-
- private boolean isSetRowKeyConverter() {
- Boolean value = (Boolean) getStateHelper().get(PropertyKeys.rowKeyConverterSet);
- return Boolean.TRUE.equals(value);
- }
-
- @Override
- public String getClientId(FacesContext facesContext) {
- if (facesContext == null) {
- throw new NullPointerException("context");
- }
-
- if (null == clientId) {
- StringBuilder id = new StringBuilder(super.getClientId(facesContext));
- Object rowKey = getRowKey();
-
- if (rowKey != null) {
-
- // Use converter to get String representation ot the row key.
- Converter rowKeyConverter = getRowKeyConverter();
-
- if (null == rowKeyConverter) {
-
- // Create default converter for a row key.
- rowKeyConverter = facesContext.getApplication().createConverter(rowKey.getClass());
-
- // Store converter for a invokeOnComponents call.
- if (null != rowKeyConverter) {
- // TODO - review
- setRowKeyConverter(rowKeyConverter);
- }
- }
-
- String rowKeyString;
-
- if (null != rowKeyConverter) {
-
- // Temporary set clientId, to avoid infinite calls from converter.
- clientId = id.toString();
- rowKeyString = rowKeyConverter.getAsString(facesContext, this, rowKey);
- } else {
- rowKeyString = rowKey.toString();
- }
-
- id.append(UINamingContainer.getSeparatorChar(facesContext)).append(rowKeyString);
- }
-
- Renderer renderer = getRenderer(facesContext);
-
- if (null != renderer) {
- clientId = renderer.convertClientId(facesContext, id.toString());
- } else {
- clientId = id.toString();
- }
- }
-
- return clientId;
- }
-
- /**
- * Save current state of data variable.
- *
- * @param faces current faces context
- */
-
- // TODO move into walk() method body
- public void captureOrigValue(FacesContext faces) {
- String var = getVar();
-
- if (var != null) {
- Map<String, Object> attrs = getVariablesMap(faces);
-
- this.originalVarValue = attrs.get(var);
- }
-
- // TODO add support for another variables
- }
-
- /**
- * Restore value of data variable after processing phase.
- *
- * @param faces current faces context
- */
- public void restoreOrigValue(FacesContext faces) {
- String var = getVar();
-
- if (var != null) {
- Map<String, Object> attrs = getVariablesMap(faces);
-
- if (this.originalVarValue != null) {
- attrs.put(var, this.originalVarValue);
- } else {
- attrs.remove(var);
- }
- }
- }
-
- /*
- * (non-Javadoc)
- * @see javax.faces.component.UIComponent#setValueExpression(java.lang.String, javax.el.ValueExpression)
- */
- @Override
- public void setValueExpression(String name, ValueExpression binding) {
- if ("var".equals(name) || "rowKeyVar".equals(name) || "stateVar".equals(name)) {
- throw new IllegalArgumentException(MessageFormat.format("{0} cannot be EL-expression", name));
- }
-
- super.setValueExpression(name, binding);
- }
-
- /**
- * Check for validation errors on children components. If true, saved values
- * must be keep on render phase
- *
- * @param context
- * @return
- */
- protected boolean keepSaved(FacesContext context) {
-
- // For an any validation errors, children components state should be preserved
- FacesMessage.Severity sev = context.getMaximumSeverity();
-
- return (sev != null) && (FacesMessage.SEVERITY_ERROR.compareTo(sev) >= 0);
- }
-
- /**
- * Perform iteration on all children components and all data rows with given
- * visitor.
- *
- * @param faces
- * @param visitor
- */
- protected void iterate(FacesContext faces, ComponentVisitor visitor) {
-
- // stop if not rendered
- if (!this.isRendered()) {
- return;
- }
-
- // reset rowIndex
- this.captureOrigValue(faces);
- this.setRowKey(faces, null);
-
- try {
- Iterator<UIComponent> fixedChildren = fixedChildren();
-
- while (fixedChildren.hasNext()) {
- UIComponent component = fixedChildren.next();
-
- visitor.processComponent(faces, component, null);
- }
-
- walk(faces, visitor, null);
- } catch (Exception e) {
- throw new FacesException(e);
- } finally {
- this.setRowKey(faces, null);
- this.restoreOrigValue(faces);
- }
- }
-
- /**
- * Walk ( visit ) this component on all data-aware children for each row.
- *
- * @param faces
- * @param visitor
- */
- public void walk(FacesContext faces, DataVisitor visitor, Object argument) {
- Object key = getRowKey();
- captureOrigValue(faces);
-
- Range range = null;
- DataComponentState componentState = getComponentState();
-
- if (componentState != null) {
- range = componentState.getRange();
- }
-
- getExtendedDataModel().walk(faces, visitor, range, argument);
-
- setRowKey(faces, key);
- restoreOrigValue(faces);
- }
-
- public void processDecodes(FacesContext faces) {
- if (!this.isRendered()) {
- return;
- }
-
- pushComponentToEL(faces, this);
- preDecode(faces);
- this.iterate(faces, decodeVisitor);
- this.decode(faces);
- popComponentFromEL(faces);
- }
-
- public void processValidators(FacesContext faces) {
- if (!this.isRendered()) {
- return;
- }
-
- pushComponentToEL(faces, this);
- Application app = faces.getApplication();
- app.publishEvent(faces, PreValidateEvent.class, this);
- preValidate(faces);
- this.iterate(faces, validateVisitor);
- app.publishEvent(faces, PostValidateEvent.class, this);
- popComponentFromEL(faces);
- }
-
- public void processUpdates(FacesContext faces) {
- if (!this.isRendered()) {
- return;
- }
-
- pushComponentToEL(faces, this);
- preUpdate(faces);
- this.iterate(faces, updateVisitor);
-
- ExtendedDataModel<?> dataModel = getExtendedDataModel();
-
- // If no validation errors, update values for serializable model,
- // restored from view.
- if ((dataModel instanceof SerializableDataModel) && (!isKeepSaved())) {
- SerializableDataModel serializableModel = (SerializableDataModel) dataModel;
-
- serializableModel.update();
- }
-
- popComponentFromEL(faces);
- }
-
- @Override
- public void setId(String id) {
- super.setId(id);
- this.clientId = null;
- }
-
- /*
- * (non-Javadoc)
- * @see org.ajax4jsf.component.IterationStateHolder#getIterationState()
- */
- public Object getIterationState() {
- assert rowKey == null;
-
- return new IterationState(this.componentState, this.extendedDataModel);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.component.IterationStateHolder#setIterationState(java.lang.Object)
- */
- public void setIterationState(Object stateObject) {
- assert rowKey == null;
-
- // TODO - ?
- // restoreChildState(getFacesContext());
- if (stateObject != null) {
- IterationState iterationState = (IterationState) stateObject;
- iterationState.restoreComponentState(this);
-
- this.componentState = iterationState.getComponentState();
- this.extendedDataModel = iterationState.getDataModel();
- } else {
- this.componentState = null;
- this.extendedDataModel = null;
- }
- }
-
- protected void resetDataModel() {
- this.extendedDataModel = null;
- }
-
- protected void resetChildState() {
- getStateHelper().remove(PropertyKeys.childState);
- }
-
- protected void preDecode(FacesContext context) {
- resetDataModel();
-
- Object savedChildState = getStateHelper().get(PropertyKeys.childState);
- // TODO - verify the check for null: savedChildState == null
- if (savedChildState == null || !isKeepSaved()) {
- resetChildState();
- }
- }
-
- // TODO - do we need this method?
- protected void preValidate(FacesContext context) {
- }
-
- // TODO - do we need this method?
- protected void preUpdate(FacesContext context) {
- }
-
- protected void preEncodeBegin(FacesContext context) {
- resetDataModel();
-
- if (!isKeepSaved()) {
- //TODO - this also resets state for the nested iteration components - is it correct?
- resetChildState();
- }
- }
-
- @Override
- public void markInitialState() {
- super.markInitialState();
-
- if (rowKeyConverter instanceof PartialStateHolder) {
- ((PartialStateHolder) rowKeyConverter).markInitialState();
- }
- }
-
- @Override
- public void clearInitialState() {
- super.clearInitialState();
-
- if (rowKeyConverter instanceof PartialStateHolder) {
- ((PartialStateHolder) rowKeyConverter).clearInitialState();
- }
- }
-
- /*
- * (non-Javadoc)
- * @see javax.faces.component.UIComponentBase#saveState(javax.faces.context.FacesContext)
- */
- @Override
- public Object saveState(FacesContext context) {
- Object parentState = super.saveState(context);
- Object savedComponentState = new IterationState(componentState, extendedDataModel).saveState();
-
- Object converterState = null;
- boolean nullDelta = true;
-
- boolean converterHasPartialState = false;
-
- if (initialStateMarked()) {
- if (!isSetRowKeyConverter() && rowKeyConverter != null && rowKeyConverter instanceof PartialStateHolder) {
- // Delta
- StateHolder holder = (StateHolder) rowKeyConverter;
- if (!holder.isTransient()) {
- Object attachedState = holder.saveState(context);
- if (attachedState != null) {
- nullDelta = false;
- converterState = attachedState;
- }
- converterHasPartialState = true;
- } else {
- converterState = null;
- }
- } else if (isSetRowKeyConverter() || rowKeyConverter != null) {
- // Full
- converterState = saveAttachedState(context, rowKeyConverter);
- nullDelta = false;
- }
-
- if (parentState == null && savedComponentState == null && nullDelta) {
- // No values
- return null;
- }
- } else {
- converterState = saveAttachedState(context, rowKeyConverter);
- }
-
- return new Object[] {
- parentState,
- savedComponentState,
- converterHasPartialState,
- converterState
- };
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.faces.component.UIComponentBase#restoreState(javax.faces.context.FacesContext, java.lang.Object)
- */
- @Override
- public void restoreState(FacesContext context, Object stateObject) {
- if (stateObject == null) {
- return ;
- }
-
- Object[] state = (Object[]) stateObject;
-
- super.restoreState(context, state[0]);
-
- if (state[1] != null) {
- IterationState iterationState = new IterationState();
- iterationState.restoreState(state[1]);
- iterationState.restoreComponentState(this);
-
- // TODO update state model binding
- componentState = iterationState.getComponentState();
- extendedDataModel = iterationState.getDataModel();
- }
-
- boolean converterHasPartialState = Boolean.TRUE.equals(state[2]);
- Object savedConverterState = state[3];
- if (converterHasPartialState) {
- ((StateHolder) rowKeyConverter).restoreState(context, savedConverterState);
- } else {
- rowKeyConverter = (Converter) UIComponentBase.restoreAttachedState(context, savedConverterState);
- }
- }
-
- private boolean matchesBaseId(String clientId, String baseId, char separatorChar) {
- if (clientId.equals(baseId)) {
- return true;
- }
-
- // if clientId.startsWith(baseId + separatorChar)
- if (clientId.startsWith(baseId) && (clientId.length() > baseId.length())
- && (clientId.charAt(baseId.length()) == separatorChar)) {
- return true;
- }
-
- return false;
- }
-
- @Override
- public boolean invokeOnComponent(FacesContext context, String clientId, ContextCallback callback)
- throws FacesException {
-
- if ((null == context) || (null == clientId) || (null == callback)) {
- throw new NullPointerException();
- }
-
- String baseId = super.getClientId(context);
-
- if (!matchesBaseId(clientId, baseId, UINamingContainer.getSeparatorChar(context))) {
- return false;
- }
-
- boolean found = false;
- Object oldRowKey = getRowKey();
-
- // TODO - this does not seem right
- captureOrigValue(context);
-
- try {
-
- // TODO - ?
- // if (null != oldRowKey) {
- setRowKey(context, null);
-
- // }
- if (clientId.equals(baseId)) {
- callback.invokeContextCallback(context, this);
- found = true;
- } else {
- Iterator<UIComponent> fixedChildrenItr = fixedChildren();
-
- while (fixedChildrenItr.hasNext() && !found) {
- UIComponent fixedChild = fixedChildrenItr.next();
-
- found = fixedChild.invokeOnComponent(context, clientId, callback);
- }
- }
-
- if (!found) {
- Object newRowKey = null;
-
- // Call for a child component - try to detect row key
- // baseId.length() + 1 expression skips SEPARATOR_CHAR
- //TODO - convertKeyString
- String rowKeyString = extractKeySegment(context, clientId.substring(baseId.length() + 1));
-
- if (rowKeyString != null) {
- Converter keyConverter = getRowKeyConverter();
-
- if (null != keyConverter) {
- try {
- //TODO: review
- newRowKey = keyConverter.getAsObject(context, this, rowKeyString);
- } catch (ConverterException e) {
-
- // TODO: LOG error
- }
- }
- }
-
- setRowKey(context, newRowKey);
-
- if (isRowAvailable()) {
- Iterator<UIComponent> dataChildrenItr = dataChildren();
-
- while (dataChildrenItr.hasNext() && !found) {
- UIComponent dataChild = dataChildrenItr.next();
-
- found = dataChild.invokeOnComponent(context, clientId, callback);
- }
- }
- }
- } catch (Exception e) {
- throw new FacesException(e);
- } finally {
-
- // if (null != oldRowKey) {
- try {
- setRowKey(context, oldRowKey);
- restoreOrigValue(context);
- } catch (Exception e) {
- LOG.error(e.getMessage(), e);
- }
-
- // }
- }
-
- return found;
- }
-
- // Tests whether we need to visit our children as part of
- // a tree visit
- private boolean doVisitChildren(VisitContext context, boolean visitRows) {
-
- // Just need to check whether there are any ids under this
- // subtree. Make sure row index is cleared out since
- // getSubtreeIdsToVisit() needs our row-less client id.
-
- // TODO check this
- if (visitRows) {
- setRowKey(context.getFacesContext(), null);
- }
-
- // TODO optimize for returned IDs
- Collection<String> idsToVisit = context.getSubtreeIdsToVisit(this);
-
- assert idsToVisit != null;
-
- if (idsToVisit == VisitContext.ALL_IDS) {
- // TODO
- }
-
- // All ids or non-empty collection means we need to visit our children.
- return !idsToVisit.isEmpty();
- }
-
- private boolean visitComponents(Iterator<UIComponent> components, VisitContext context, VisitCallback callback) {
-
- while (components.hasNext()) {
- UIComponent nextChild = components.next();
-
- if (nextChild.visitTree(context, callback)) {
- return true;
- }
- }
-
- return false;
- }
-
- protected boolean visitFixedChildren(VisitContext visitContext, VisitCallback callback) {
-
- return visitComponents(fixedChildren(), visitContext, callback);
- }
-
- protected boolean visitDataChildren(VisitContext visitContext, VisitCallback callback, boolean visitRows) {
-
- if (visitRows) {
- FacesContext facesContext = visitContext.getFacesContext();
-
- DataVisitorForVisitTree dataVisitor = new DataVisitorForVisitTree(callback, visitContext);
- this.walk(facesContext, dataVisitor, null);
-
- return dataVisitor.getVisitResult();
- } else {
- return visitComponents(dataChildren(), visitContext, callback);
- }
- }
-
- @Override
- public boolean visitTree(VisitContext visitContext, VisitCallback callback) {
-
- // First check to see whether we are visitable. If not
- // short-circuit out of this subtree, though allow the
- // visit to proceed through to other subtrees.
- if (!isVisitable(visitContext)) {
- return false;
- }
-
- // Clear out the row index is one is set so that
- // we start from a clean slate.
- FacesContext facesContext = visitContext.getFacesContext();
-
- // NOTE: that the visitRows local will be obsolete once the
- // appropriate visit hints have been added to the API
- boolean visitRows = requiresRowIteration(facesContext);
-
- Object oldRowKey = null;
- if (visitRows) {
- captureOrigValue(facesContext);
- oldRowKey = getRowKey();
- setRowKey(facesContext, null);
- }
-
- // Push ourselves to EL
- pushComponentToEL(facesContext, null);
-
- try {
-
- // Visit ourselves. Note that we delegate to the
- // VisitContext to actually perform the visit.
- VisitResult result = visitContext.invokeVisitCallback(this, callback);
-
- // If the visit is complete, short-circuit out and end the visit
- if (result == VisitResult.COMPLETE) {
- return true;
- }
-
- // Visit children, short-circuiting as necessary
- if ((result == VisitResult.ACCEPT) && doVisitChildren(visitContext, visitRows)) {
- if (visitRows) {
- setRowKey(facesContext, null);
- }
-
- if (visitFixedChildren(visitContext, callback)) {
- return true;
- }
-
- if (visitContext instanceof ExtendedVisitContext) {
- ExtendedVisitContext extendedVisitContext = (ExtendedVisitContext) visitContext;
-
- Collection<String> directSubtreeIdsToVisit = extendedVisitContext.getDirectSubtreeIdsToVisit(this);
- if (directSubtreeIdsToVisit != VisitContext.ALL_IDS) {
- if (directSubtreeIdsToVisit.isEmpty()) {
- return false;
- } else {
- VisitContext directChildrenVisitContext =
- extendedVisitContext.createNamingContainerVisitContext(this, directSubtreeIdsToVisit);
-
- if (visitRows) {
- setRowKey(facesContext, null);
- }
- if (visitFixedChildren(directChildrenVisitContext, STUB_CALLBACK)) {
- return false;
- }
- }
- }
- }
-
- if (visitDataChildren(visitContext, callback, visitRows)) {
- return true;
- }
- }
- } finally {
-
- // Clean up - pop EL and restore old row index
- popComponentFromEL(facesContext);
-
- if (visitRows) {
- try {
- setRowKey(facesContext, oldRowKey);
- restoreOrigValue(facesContext);
- } catch (Exception e) {
-
- // TODO: handle exception
- LOG.error(e.getMessage(), e);
- }
- }
- }
-
- // Return false to allow the visit to continue
- return false;
- }
-
- /**
- * @param facesContext
- * @return
- */
- private boolean requiresRowIteration(FacesContext context) {
- return (!PhaseId.RESTORE_VIEW.equals(context.getCurrentPhaseId()));
- }
-
- /**
- * @param context
- * @param substring
- * @return
- */
- // TODO review!
- protected String extractKeySegment(FacesContext context, String substring) {
- char separatorChar = UINamingContainer.getSeparatorChar(context);
- int separatorIndex = substring.indexOf(separatorChar);
-
- if (separatorIndex < 0) {
- return substring;
- } else {
- return substring.substring(0, separatorIndex);
- }
- }
-
- /**
- * Base class for visit data model at phases decode, validation and update model
- *
- * @author shura
- */
- protected abstract class ComponentVisitor implements DataVisitor {
- public DataVisitResult process(FacesContext context, Object rowKey, Object argument) {
- setRowKey(context, rowKey);
-
- if (isRowAvailable()) {
- Iterator<UIComponent> childIterator = dataChildren();
-
- while (childIterator.hasNext()) {
- UIComponent component = childIterator.next();
-
- processComponent(context, component, argument);
- }
- }
-
- return DataVisitResult.CONTINUE;
- }
-
- public abstract void processComponent(FacesContext context, UIComponent c, Object argument);
- }
-
- @Override
- public void processEvent(ComponentSystemEvent event) throws AbortProcessingException {
- super.processEvent(event);
-
- if (event instanceof PreRenderComponentEvent) {
- preEncodeBegin(getFacesContext());
- }
- }
-
- protected DataComponentState getLocalComponentState() {
- return componentState;
- }
-}
Deleted: branches/RF-7560/core/impl/src/main/java/org/richfaces/component/UISequence.java
===================================================================
--- branches/RF-7560/core/impl/src/main/java/org/richfaces/component/UISequence.java 2010-08-31 16:59:42 UTC (rev 19051)
+++ branches/RF-7560/core/impl/src/main/java/org/richfaces/component/UISequence.java 2010-08-31 17:20:11 UTC (rev 19052)
@@ -1,305 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright ${year}, 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.component;
-
-import java.sql.ResultSet;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-
-import javax.el.ValueExpression;
-import javax.faces.component.UINamingContainer;
-import javax.faces.context.FacesContext;
-import javax.faces.convert.Converter;
-import javax.faces.model.ArrayDataModel;
-import javax.faces.model.DataModel;
-import javax.faces.model.ListDataModel;
-import javax.faces.model.ResultDataModel;
-import javax.faces.model.ResultSetDataModel;
-import javax.faces.model.ScalarDataModel;
-import javax.servlet.jsp.jstl.sql.Result;
-
-import org.ajax4jsf.model.DataComponentState;
-import org.ajax4jsf.model.ExtendedDataModel;
-import org.ajax4jsf.model.Range;
-import org.ajax4jsf.model.SequenceDataModel;
-import org.ajax4jsf.model.SequenceRange;
-import org.ajax4jsf.model.SequenceState;
-
-/**
- * @author Nick Belaevski
- */
-public class UISequence extends UIDataAdaptor {
-
- private Object iterationStatusVarObject;
-
- protected enum PropertyKeys {
- first, rows, value, iterationStatusVar
- }
-
- protected void updateState(SequenceState state) {
- state.setFirst(getActualFirst());
- state.setRows(getActualRows());
- }
-
- protected void updateState() {
- DataComponentState localState = getLocalComponentState();
- if (localState instanceof SequenceState) {
- updateState((SequenceState) localState);
- }
- }
-
- protected int getActualFirst() {
- return getFirst();
- }
-
- protected int getActualRows() {
- return getRows();
- }
-
- @SuppressWarnings("unchecked")
- protected DataModel<?> createFacesModel(Object value) {
- DataModel<?> model = null;
-
- if (value == null) {
- model = new ListDataModel(Collections.EMPTY_LIST);
- } else if (value instanceof DataModel) {
- model = (DataModel) value;
- } else if (value instanceof List) {
- model = new ListDataModel((List) value);
- } else if (Object[].class.isAssignableFrom(value.getClass())) {
- model = new ArrayDataModel((Object[]) value);
- } else if (value instanceof ResultSet) {
- model = new ResultSetDataModel((ResultSet) value);
- } else if (value instanceof Result) {
- model = new ResultDataModel((Result) value);
- } else {
- model = new ScalarDataModel(value);
- }
-
- return model;
- }
-
- @SuppressWarnings("unchecked")
- @Override
- protected ExtendedDataModel<?> createExtendedDataModel() {
- ExtendedDataModel<?> model = null;
-
- // Synthesize a DataModel around our current value if possible
- Object value = getValue();
-
- if (value instanceof ExtendedDataModel<?>) {
- model = (ExtendedDataModel<?>) value;
- } else {
- model = new SequenceDataModel(createFacesModel(value));
- }
-
- return model;
- }
-
- @Override
- protected DataComponentState createComponentState() {
- SequenceState state = new SequenceState();
-
- updateState(state);
-
- return state;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.richfaces.component.UIDataAdaptor#getRowKeyConverter()
- */
-
- // TODO make this a property of model
-
- @Override
- public Converter getRowKeyConverter() {
- return getFacesContext().getApplication().createConverter(Integer.class);
- }
-
- public int getFirst() {
- return (Integer) getStateHelper().eval(PropertyKeys.first, 0);
- }
-
- public void setFirst(int first) {
- getStateHelper().put(PropertyKeys.first, first);
- updateState();
- }
-
- public int getRows() {
- return (Integer) getStateHelper().eval(PropertyKeys.rows, 0);
- }
-
- public void setRows(int rows) {
- getStateHelper().put(PropertyKeys.rows, rows);
- updateState();
- }
-
- public Object getValue() {
- return getStateHelper().eval(PropertyKeys.value);
- }
-
- public void setValue(Object value) {
- resetDataModel();
- getStateHelper().put(PropertyKeys.value, value);
- }
-
- public String getIterationStatusVar() {
- return (String) getStateHelper().get(PropertyKeys.iterationStatusVar);
- }
-
- public void setIterationStatusVar(String iterationStatusVar) {
- getStateHelper().put(PropertyKeys.iterationStatusVar, iterationStatusVar);
- }
-
- public int getRowIndex() {
- return getExtendedDataModel().getRowIndex();
- }
-
- @Override
- public void captureOrigValue(FacesContext faces) {
- super.captureOrigValue(faces);
-
- String iterationStatusVar = getIterationStatusVar();
- if (iterationStatusVar != null) {
- Map<String, Object> variablesMap = getVariablesMap(faces);
-
- iterationStatusVarObject = variablesMap.get(iterationStatusVar);
- }
- }
-
- @Override
- public void restoreOrigValue(FacesContext faces) {
- super.restoreOrigValue(faces);
-
- String iterationStatusVar = getIterationStatusVar();
- if (iterationStatusVar != null) {
- Map<String, Object> variablesMap = getVariablesMap(faces);
-
- if (iterationStatusVarObject != null) {
- variablesMap.put(iterationStatusVar, iterationStatusVarObject);
- } else {
- variablesMap.remove(iterationStatusVar);
- }
- }
- }
-
- @Override
- protected void setupVariable(FacesContext faces, boolean rowSelected) {
- super.setupVariable(faces, rowSelected);
-
- //TODO nick - should iterationStatus be available out of iteration?
- // if yes, better name than "iterationStatusVar" is required
- String iterationStatusVar = getIterationStatusVar();
- if (iterationStatusVar != null) {
- Map<String, Object> requestMap = getVariablesMap(faces);
-
- if (rowSelected) {
- Integer begin = null;
- Integer end = null;
-
- Range range = getComponentState().getRange();
- if (range instanceof SequenceRange) {
- SequenceRange sequenceRange = (SequenceRange) range;
-
- begin = sequenceRange.getFirstRow();
- int iRows = sequenceRange.getRows();
-
- if (iRows > 0) {
- // end is zero-based
- end = begin + iRows - 1;
- }
- }
-
- SequenceIterationStatus iterationStatus = new SequenceIterationStatus(begin, end,
- getRowIndex(), getRowCount());
-
- requestMap.put(iterationStatusVar, iterationStatus);
- } else {
- requestMap.remove(iterationStatusVar);
- }
- }
- }
-
- @SuppressWarnings("deprecation")
- @Override
- public void setValueBinding(String name, javax.faces.el.ValueBinding binding) {
- if ("value".equals(name)) {
- resetDataModel();
- } else if ("first".equals(name) || "rows".equals(name)) {
- updateState();
- }
-
- super.setValueBinding(name, binding);
- }
-
- @Override
- public void setValueExpression(String name, ValueExpression binding) {
- if ("value".equals(name)) {
- resetDataModel();
- } else if ("first".equals(name) || "rows".equals(name)) {
- updateState();
- }
-
- super.setValueExpression(name, binding);
- }
-
- @Override
- protected void preEncodeBegin(FacesContext context) {
- super.preEncodeBegin(context);
-
- updateState();
- }
-
- public int getRelativeRowIndex() {
- int rowIndex = getRowIndex();
- int rows = getRows();
-
- if (rows > 1) {
- return rowIndex % rows;
- }
-
- return rowIndex;
- }
-
- public String getRelativeClientId(FacesContext facesContext) {
-
- //save current rowKey
- Object savedRowKey = getRowKey();
-
- setRowKey(null);
-
- //retrieve base client id without rowkey part
- StringBuilder baseId = new StringBuilder(getClientId(facesContext));
-
- //restore rowKey
- setRowKey(savedRowKey);
-
- String result = baseId.append(UINamingContainer.getSeparatorChar(facesContext)).append(getRelativeRowIndex())
- .toString();
-
- return result;
- }
-}
Deleted: branches/RF-7560/core/impl/src/main/java/org/richfaces/renderkit/CompositeRenderer.java
===================================================================
--- branches/RF-7560/core/impl/src/main/java/org/richfaces/renderkit/CompositeRenderer.java 2010-08-31 16:59:42 UTC (rev 19051)
+++ branches/RF-7560/core/impl/src/main/java/org/richfaces/renderkit/CompositeRenderer.java 2010-08-31 17:20:11 UTC (rev 19052)
@@ -1,148 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces - Ajax4jsf Component Library
- *
- * 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;
-
-import org.ajax4jsf.renderkit.AjaxChildrenRenderer;
-
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-/**
- * @author Nick Belaevski - nbelaevski(a)exadel.com
- * created 18.12.2006
- */
-public abstract class CompositeRenderer extends AjaxChildrenRenderer {
- private static final Command MERGE_OPTIONS_COMMAND = new Command() {
- @Override
- protected void execute(RendererContributor renderer, FacesContext context, UIComponent component,
- Object argument) {
- ScriptOptions initialOptions = (ScriptOptions) argument;
- ScriptOptions builtOptions = renderer.buildOptions(context, component);
-
- if (builtOptions != null) {
- initialOptions.merge(builtOptions);
- }
- }
- };
- private static final Command GET_SCRIPT_CONTRIBUTIONS = new Command() {
- @Override
- protected void execute(RendererContributor renderer, FacesContext context, UIComponent component,
- Object argument) {
- String contribution = renderer.getScriptContribution(context, component);
-
- if (contribution != null) {
- ((List<String>) argument).add(contribution);
- }
- }
- };
- private List<RendererContributor> renderers = new ArrayList<RendererContributor>();
- private List<AttributeParametersEncoder> parameterEncoders = new ArrayList<AttributeParametersEncoder>();
- private final Command decodeCommand = new Command() {
- @Override
- protected void execute(RendererContributor renderer, FacesContext context, UIComponent component,
- Object argument) {
- renderer.decode(context, component, CompositeRenderer.this);
- }
- };
-
- @Override
- protected void doDecode(FacesContext context, UIComponent component) {
- super.doDecode(context, component);
- decodeCommand.execute(renderers.iterator(), context, component, null, component.getClass());
- }
-
- protected void mergeScriptOptions(ScriptOptions scriptOptions, FacesContext context, UIComponent component) {
- mergeScriptOptions(scriptOptions, context, component, null);
- }
-
- protected void mergeScriptOptions(ScriptOptions scriptOptions, FacesContext context, UIComponent component,
- Class<?> acceptableClass) {
- MERGE_OPTIONS_COMMAND.execute(renderers.iterator(), context, component, scriptOptions, acceptableClass);
- }
-
- protected String getScriptContributions(String varString, FacesContext context, UIComponent component) {
- return getScriptContributions(varString, context, component, component.getClass());
- }
-
- protected String getScriptContributions(String varString, FacesContext context, UIComponent component,
- Class<?> acceptableClass) {
- List<String> scriptContributions = new ArrayList<String>();
-
- GET_SCRIPT_CONTRIBUTIONS.execute(renderers.iterator(), context, component, scriptContributions,
- acceptableClass);
-
- StringBuffer result = new StringBuffer();
-
- for (Iterator<String> itr = scriptContributions.iterator(); itr.hasNext();) {
- result.append(varString);
- result.append(itr.next());
- }
-
- return result.toString();
- }
-
- protected void addContributor(RendererContributor renderer) {
- renderers.add(renderer);
- }
-
- protected RendererContributor[] getContributors() {
- return (RendererContributor[]) renderers.toArray(new RendererContributor[renderers.size()]);
- }
-
- protected void addParameterEncoder(AttributeParametersEncoder encoder) {
- parameterEncoders.add(encoder);
- }
-
- protected AttributeParametersEncoder[] getParameterEncoders() {
- return (AttributeParametersEncoder[]) parameterEncoders.toArray(
- new AttributeParametersEncoder[renderers.size()]);
- }
-
- public void encodeAttributeParameters(FacesContext context, UIComponent component) throws IOException {
- for (Iterator<AttributeParametersEncoder> iterator = parameterEncoders.iterator(); iterator.hasNext();) {
- AttributeParametersEncoder encoder = iterator.next();
-
- encoder.doEncode(context, component);
- }
- }
-
- private abstract static class Command {
- protected final void execute(Iterator<?> renderers, FacesContext facesContext, UIComponent component,
- Object argument, Class<?> clazz) {
- while (renderers.hasNext()) {
- RendererContributor contributor = (RendererContributor) renderers.next();
- Class<?> acceptableClass = contributor.getAcceptableClass();
-
- if ((clazz == null) || (acceptableClass == null) || acceptableClass.isAssignableFrom(clazz)) {
- execute(contributor, facesContext, component, argument);
- }
- }
- }
-
- protected abstract void execute(RendererContributor renderer, FacesContext facesContext, UIComponent component,
- Object argument);
- }
-}
Deleted: branches/RF-7560/core/impl/src/main/java/org/richfaces/renderkit/InputRendererBase.java
===================================================================
--- branches/RF-7560/core/impl/src/main/java/org/richfaces/renderkit/InputRendererBase.java 2010-08-31 16:59:42 UTC (rev 19051)
+++ branches/RF-7560/core/impl/src/main/java/org/richfaces/renderkit/InputRendererBase.java 2010-08-31 17:20:11 UTC (rev 19052)
@@ -1,84 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces - Ajax4jsf Component Library
- *
- * 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;
-
-import org.ajax4jsf.renderkit.AjaxComponentRendererBase;
-import org.ajax4jsf.util.SelectUtils;
-
-import javax.faces.component.UIComponent;
-import javax.faces.component.UIInput;
-import javax.faces.context.FacesContext;
-import javax.faces.convert.Converter;
-import javax.faces.convert.ConverterException;
-import java.util.Map;
-
-/**
- * @author Nick Belaevski - nbelaevski(a)exadel.com
- * created 23.01.2007
- */
-public class InputRendererBase extends AjaxComponentRendererBase {
- protected Class getComponentClass() {
- return UIInput.class;
- }
-
- protected void doDecode(FacesContext context, UIComponent component) {
- String clientId = component.getClientId(context);
- Map requestParameterMap = context.getExternalContext().getRequestParameterMap();
- String newValue = (String) requestParameterMap.get(clientId);
-
- if (null != newValue) {
- UIInput input = (UIInput) component;
-
- input.setSubmittedValue(newValue);
- }
- }
-
- public Object getConvertedValue(FacesContext context, UIComponent component, Object val) throws ConverterException {
- return SelectUtils.getConvertedUIInputValue(context, (UIInput) component, (String) val);
- }
-
- public String getInputValue(FacesContext context, UIComponent component) {
- UIInput input = (UIInput) component;
- String value = (String) input.getSubmittedValue();
-
- if (value == null) {
- Object curVal = input.getValue();
- Converter converter = SelectUtils.getConverterForProperty(context, input, "value");
-
- if (converter != null) {
- value = converter.getAsString(context, input, curVal);
- } else {
- if (curVal == null) {
- value = "";
- } else {
- value = curVal.toString();
- }
- }
- }
-
- if (value == null) {
- value = "";
- }
-
- return value;
- }
-}
Deleted: branches/RF-7560/core/impl/src/main/java/org/richfaces/renderkit/MacroDefinitionJSContentHandler.java
===================================================================
--- branches/RF-7560/core/impl/src/main/java/org/richfaces/renderkit/MacroDefinitionJSContentHandler.java 2010-08-31 16:59:42 UTC (rev 19051)
+++ branches/RF-7560/core/impl/src/main/java/org/richfaces/renderkit/MacroDefinitionJSContentHandler.java 2010-08-31 17:20:11 UTC (rev 19052)
@@ -1,241 +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;
-
-import org.richfaces.javacc.RichMacroDefinition;
-import org.richfaces.json.JSContentHandler;
-import org.xml.sax.Attributes;
-import org.xml.sax.SAXException;
-
-import java.io.FilterWriter;
-import java.io.IOException;
-import java.io.StringReader;
-import java.io.Writer;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-/**
- * @author Nick Belaevski - mailto:nbelaevski@exadel.com created 21.06.2007
- */
-public class MacroDefinitionJSContentHandler extends JSContentHandler {
- private String epilog;
- private String prolog;
-
- public MacroDefinitionJSContentHandler(Writer writer, String prolog, String epilog) {
- super(writer);
- this.prolog = prolog;
- this.epilog = epilog;
- }
-
- protected List<?> parseExpressiion(String expressionString) throws SAXException {
- try {
- if (expressionString.length() != 0) {
- List<?> result = new RichMacroDefinition(new StringReader(expressionString)).expression();
-
- return result;
- } else {
- List<Object> list = new ArrayList<Object>(1);
-
- list.add("");
-
- return list;
- }
- } catch (Exception e) {
- throw new SAXException(e.getMessage(), e);
- }
- }
-
- private void encodeExpressionString(String string) throws IOException, SAXException {
-
- /*
- * if (string.length() == 0) {
- * this.outputWriter.write("\'\'");
- * }
- */
- List<?> parsedExpressiion = parseExpressiion(string);
- boolean isExpression = false;
-
- for (Iterator<?> iterator = parsedExpressiion.iterator(); iterator.hasNext();) {
- Object next = (Object) iterator.next();
-
- if (next instanceof Expression) {
- isExpression = true;
-
- break;
- }
- }
-
- if (isExpression) {
- this.outputWriter.write("function (context) { return ");
- }
-
- boolean first = true;
-
- for (Iterator<?> iterator = parsedExpressiion.iterator(); iterator.hasNext();) {
- Object next = (Object) iterator.next();
-
- if (next == null) {
- continue;
- }
-
- if (!first) {
- this.outputWriter.write('+');
- }
-
- if (next instanceof Expression) {
- Expression macroExpression = (Expression) next;
-
- this.outputWriter.write(prolog);
- this.encode(macroExpression.getExpression().toString());
- this.outputWriter.write(epilog);
- } else {
- this.outputWriter.write('\'');
- this.encode(next.toString());
- this.outputWriter.write('\'');
- }
-
- first = false;
- }
-
- if (isExpression) {
- this.outputWriter.write(";}");
- }
- }
-
- protected void encodeAttributeValue(Attributes attributes, int idx) throws SAXException, IOException {
- String value = attributes.getValue(idx);
-
- encodeExpressionString(value);
- }
-
- public void characters(char[] ch, int start, int length) throws SAXException {
- if (isProcessingCdata()) {
- super.characters(ch, start, length);
- } else {
- Writer oldWriter = outputWriter;
-
- outputWriter = new WellFormedWriter(oldWriter);
-
- try {
- List<?> parsedExpression = parseExpressiion(new String(ch, start, length));
-
- for (Iterator<?> iterator = parsedExpression.iterator(); iterator.hasNext();) {
- Object next = iterator.next();
-
- if (next instanceof Expression) {
- Expression expression = (Expression) next;
-
- if (this.isBeforeDocumentStart() || (level < 0)) {
- return;
- }
-
- try {
- if ((level != 0) && !this.closeElement(false) && !this.isProcessingCdata()) {
- this.outputWriter.write(',');
- }
-
- if (!this.isProcessingCdata()) {
- this.outputWriter.write("new ET(");
- }
-
- this.outputWriter.write("function (context) { return ");
- this.outputWriter.write(prolog);
- this.encode(expression.getExpression().toString());
- this.outputWriter.write(epilog);
- this.outputWriter.write("}");
-
- if (!this.isProcessingCdata()) {
- this.outputWriter.write(")");
- }
- } catch (IOException e) {
- throw new SAXException("Write error", e);
- }
- } else {
- char[] cs = next.toString().toCharArray();
-
- super.characters(cs, 0, cs.length);
- }
-
- if (iterator.hasNext()) {
- try {
- this.outputWriter.write(',');
- } catch (IOException e) {
-
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- }
- } finally {
- outputWriter = oldWriter;
- }
- }
- }
-
- protected void encodeText(char[] chars, int start, int length) throws SAXException, IOException {
- if (!isProcessingCdata()) {
- String str = new String(chars, start, length);
-
- encodeExpressionString(str);
- } else {
- super.encodeText(chars, start, length);
- }
- }
-
- /**
- * Writer will not output duplicate commas
- *
- * @author Maksim Kaszynski
- */
- static class WellFormedWriter extends FilterWriter {
- private char lastChar;
-
- public WellFormedWriter(Writer out) {
- super(out);
- }
-
- public void write(char[] cbuf, int off, int len) throws IOException {
-
- // Skip comma
- while ((cbuf[off] == lastChar) && (lastChar == ',') && (len > 0)) {
- off++;
- len--;
- }
-
- while ((len > 1) && (cbuf[off] == cbuf[off + 1]) && (cbuf[off] == ',')) {
- len--;
- off++;
- }
-
- super.write(cbuf, off, len);
- lastChar = cbuf[off + len - 1];
- }
-
- public void write(int c) throws IOException {
- if ((c != lastChar) || (lastChar != ',')) {
- super.write(c);
- lastChar = (char) c;
- }
- }
- }
-}
Deleted: branches/RF-7560/core/impl/src/main/java/org/richfaces/renderkit/RendererContributor.java
===================================================================
--- branches/RF-7560/core/impl/src/main/java/org/richfaces/renderkit/RendererContributor.java 2010-08-31 16:59:42 UTC (rev 19051)
+++ branches/RF-7560/core/impl/src/main/java/org/richfaces/renderkit/RendererContributor.java 2010-08-31 17:20:11 UTC (rev 19052)
@@ -1,41 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces - Ajax4jsf Component Library
- *
- * 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;
-
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-
-/**
- * @author Nick Belaevski - nbelaevski(a)exadel.com
- * created 18.12.2006
- */
-public interface RendererContributor extends ScriptOptionsContributor {
- public String getScriptContribution(FacesContext context, UIComponent component);
-
- public void decode(FacesContext context, UIComponent component, CompositeRenderer compositeRenderer);
-
- public String[] getScriptDependencies();
-
- public String[] getStyleDependencies();
-
- public Class<?> getAcceptableClass();
-}
Deleted: branches/RF-7560/core/impl/src/main/java/org/richfaces/renderkit/SequenceRendererHelper.java
===================================================================
--- branches/RF-7560/core/impl/src/main/java/org/richfaces/renderkit/SequenceRendererHelper.java 2010-08-31 16:59:42 UTC (rev 19051)
+++ branches/RF-7560/core/impl/src/main/java/org/richfaces/renderkit/SequenceRendererHelper.java 2010-08-31 17:20:11 UTC (rev 19052)
@@ -1,100 +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;
-
-import org.richfaces.component.UISequence;
-import org.richfaces.component.util.HtmlUtil;
-
-/**
- * @author Nick Belaevski
- *
- */
-public class SequenceRendererHelper {
-
- private UISequence sequence;
-
- private int rowIndex = -1;
-
- private int columnIndex = 0;
-
- private String[] rowClasses = null;
-
- private String[] columnClasses = null;
-
- public SequenceRendererHelper(UISequence sequence) {
- super();
- this.sequence = sequence;
-
- this.rowClasses = splitClassesString((String) sequence.getAttributes().get("rowClasses"));
- this.columnClasses = splitClassesString((String) sequence.getAttributes().get("columnClasses"));
- }
-
- private static String[] splitClassesString(String s) {
- if (s != null) {
- return s.split(",");
- }
-
- return null;
- }
-
- private static String getCorrespondingArrayItem(String[] strings, int idx) {
- if (strings != null && strings.length > 0) {
- return strings[idx % strings.length];
- }
-
- return null;
- }
-
- public UISequence getSequence() {
- return sequence;
- }
-
- private void initialize() {
- rowIndex = sequence.getRowIndex();
- }
-
- public void nextRow() {
- if (rowIndex == -1) {
- initialize();
- }
-
- rowIndex++;
- columnIndex = 0;
- }
-
- public void nextColumn() {
- columnIndex++;
- }
-
- public String getRowClass() {
- String rowClass = (String) sequence.getAttributes().get("rowClass");
- return HtmlUtil.concatClasses(getCorrespondingArrayItem(rowClasses, rowIndex), rowClass);
- }
-
- public String getColumnClass() {
- return getCorrespondingArrayItem(columnClasses, columnIndex);
- }
-
- public boolean hasWalkedOverRows() {
- return rowIndex != -1;
- }
-}
Deleted: branches/RF-7560/core/impl/src/main/java/org/richfaces/renderkit/TemplateEncoderRendererBase.java
===================================================================
--- branches/RF-7560/core/impl/src/main/java/org/richfaces/renderkit/TemplateEncoderRendererBase.java 2010-08-31 16:59:42 UTC (rev 19051)
+++ branches/RF-7560/core/impl/src/main/java/org/richfaces/renderkit/TemplateEncoderRendererBase.java 2010-08-31 17:20:11 UTC (rev 19052)
@@ -1,98 +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;
-
-import org.ajax4jsf.io.SAXResponseWriter;
-import org.ajax4jsf.renderkit.RendererBase;
-import org.richfaces.component.TemplateComponent;
-import org.xml.sax.ContentHandler;
-
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-import java.io.IOException;
-import java.io.Writer;
-
-/**
- * @author Nick Belaevski - mailto:nbelaevski@exadel.com
- * created 22.06.2007
- */
-public abstract class TemplateEncoderRendererBase extends RendererBase {
- public final boolean getRendersChildren() {
- return true;
- }
-
- protected void writeScriptBody(FacesContext context, UIComponent component, boolean children) throws IOException {
- ResponseWriter writer = context.getResponseWriter();
- ContentHandler handler = createContentHandler(writer);
- SAXResponseWriter saxResponseWriter = new SAXResponseWriter(handler);
-
- context.setResponseWriter(saxResponseWriter);
-
- TemplateComponent templateComponent = null;
-
- if (component instanceof TemplateComponent) {
- templateComponent = (TemplateComponent) component;
- }
-
- try {
- if (templateComponent != null) {
- templateComponent.startTemplateEncode();
- }
-
- saxResponseWriter.startDocument();
-
- // TODO - how to handle extra "root" element?
- saxResponseWriter.startElement("root", component);
-
- if (children) {
- this.renderChildren(context, component);
- } else {
- component.encodeAll(context);
- }
-
- saxResponseWriter.endElement("root");
- saxResponseWriter.endDocument();
- } finally {
- if (templateComponent != null) {
- templateComponent.endTemplateEncode();
- }
-
- context.setResponseWriter(writer);
- }
- }
-
- public void encodeChildren(FacesContext context, UIComponent component) throws IOException {
- ResponseWriter writer = context.getResponseWriter();
-
- writer.startElement("script", component);
- writer.write("var evaluator = ");
- writeScriptBody(context, component, true);
- writer.write(";\n new Insertion.Top($('" + component.getClientId(context)
- + "'), evaluator.invoke('getContent', window).join(''));");
- writer.endElement("script");
- }
-
- protected ContentHandler createContentHandler(Writer writer) {
- return new MacroDefinitionJSContentHandler(writer, "Richfaces.evalMacro(\"", "\", context)");
- }
-}
Deleted: branches/RF-7560/core/impl/src/main/java/org/richfaces/webapp/taglib/SimpleComponentTag.java
===================================================================
--- branches/RF-7560/core/impl/src/main/java/org/richfaces/webapp/taglib/SimpleComponentTag.java 2010-08-31 16:59:42 UTC (rev 19051)
+++ branches/RF-7560/core/impl/src/main/java/org/richfaces/webapp/taglib/SimpleComponentTag.java 2010-08-31 17:20:11 UTC (rev 19052)
@@ -1,169 +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.webapp.taglib;
-
-import javax.el.MethodExpression;
-import javax.el.ValueExpression;
-import javax.faces.component.UIComponent;
-import javax.faces.component.UIComponentBase;
-import javax.faces.component.UIInput;
-import javax.faces.el.MethodBinding;
-
-/**
- * @author Maksim Kaszynski
- */
-public class SimpleComponentTag extends UIComponentELTagBase {
- private MethodExpression action;
- private MethodExpression actionListener;
- private ValueExpression converter;
- private MethodExpression legacyBinding;
- private MethodExpression methodExpression;
- private ValueExpression title;
- private MethodExpression validator;
- private ValueExpression value;
- private MethodExpression valueChangeListener;
-
- public SimpleComponentTag() {
-
- // TODO Auto-generated constructor stub
- }
-
- @Override
- public String getComponentType() {
- return UIInput.COMPONENT_TYPE;
- }
-
- @Override
- public String getRendererType() {
- return "javax.faces.Text";
- }
-
- @Override
- protected void setProperties(UIComponent component) {
- super.setProperties(component);
-
- MyUIComponent myUIComponent = (MyUIComponent) component;
-
- myUIComponent.setValueExpression("value", value);
- setActionListenerProperty(myUIComponent, actionListener);
- setActionProperty(myUIComponent, action);
- setConverterProperty(myUIComponent, converter);
- setValidatorProperty(myUIComponent, validator);
-
- if (methodExpression != null) {
- myUIComponent.setMethodExpression(methodExpression);
- }
-
- if (legacyBinding != null) {
- myUIComponent.setLegacyMethodBinding(new MethodBindingMethodExpressionAdaptor(legacyBinding));
- }
- }
-
- @Override
- public void release() {
- super.release();
- }
-
- public void setAction(MethodExpression action) {
- this.action = action;
- }
-
- public MethodExpression getAction() {
- return action;
- }
-
- public MethodExpression getActionListener() {
- return actionListener;
- }
-
- public void setActionListener(MethodExpression listener) {
- actionListener = listener;
- }
-
- public MethodExpression getValueChangeListener() {
- return valueChangeListener;
- }
-
- public void setValueChangeListener(MethodExpression changeListener) {
- valueChangeListener = changeListener;
- }
-
- public MethodExpression getValidator() {
- return validator;
- }
-
- public void setValidator(MethodExpression validator) {
- this.validator = validator;
- }
-
- public ValueExpression getConverter() {
- return converter;
- }
-
- public void setConverter(ValueExpression converter) {
- this.converter = converter;
- }
-
- public ValueExpression getTitle() {
- return title;
- }
-
- public void setTitle(ValueExpression title) {
- this.title = title;
- }
-
- public ValueExpression getValue() {
- return value;
- }
-
- public void setValue(ValueExpression value) {
- this.value = value;
- }
-
- static class MyUIComponent extends UIComponentBase {
- private MethodBinding legacyMethodBinding;
- private MethodExpression methodExpression;
-
- @Override
- public String getFamily() {
-
- // TODO Auto-generated method stub
- return null;
- }
-
- public MethodBinding getLegacyMethodBinding() {
- return legacyMethodBinding;
- }
-
- public void setLegacyMethodBinding(MethodBinding legacyMethodBinding) {
- this.legacyMethodBinding = legacyMethodBinding;
- }
-
- public MethodExpression getMethodExpression() {
- return methodExpression;
- }
-
- public void setMethodExpression(MethodExpression methodExpression) {
- this.methodExpression = methodExpression;
- }
- }
-}
Deleted: branches/RF-7560/core/impl/src/main/java/org/richfaces/webapp/taglib/UIComponentELTagBase.java
===================================================================
--- branches/RF-7560/core/impl/src/main/java/org/richfaces/webapp/taglib/UIComponentELTagBase.java 2010-08-31 16:59:42 UTC (rev 19051)
+++ branches/RF-7560/core/impl/src/main/java/org/richfaces/webapp/taglib/UIComponentELTagBase.java 2010-08-31 17:20:11 UTC (rev 19052)
@@ -1,135 +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.webapp.taglib;
-
-import org.ajax4jsf.Messages;
-import org.richfaces.component.UIDataAdaptor;
-
-import javax.el.MethodExpression;
-import javax.el.ValueExpression;
-import javax.faces.component.ActionSource2;
-import javax.faces.component.EditableValueHolder;
-import javax.faces.component.UIComponent;
-import javax.faces.component.ValueHolder;
-import javax.faces.context.FacesContext;
-import javax.faces.convert.Converter;
-import javax.faces.event.MethodExpressionActionListener;
-import javax.faces.event.MethodExpressionValueChangeListener;
-import javax.faces.validator.MethodExpressionValidator;
-import javax.faces.webapp.UIComponentELTag;
-
-/**
- * @author Maksim Kaszynski
- */
-public abstract class UIComponentELTagBase extends UIComponentELTag {
- protected void setActionListenerProperty(UIComponent component, MethodExpression actionListener) {
- if (actionListener != null) {
- if (component instanceof ActionSource2) {
- ActionSource2 actionSource2 = (ActionSource2) component;
-
- actionSource2.addActionListener(new MethodExpressionActionListener(actionListener));
- } else {
- throw new IllegalArgumentException(Messages.getMessage(Messages.NO_ACTION_SOURCE2_ERROR,
- component.getClientId(getFacesContext())));
- }
- }
- }
-
- protected void setActionProperty(UIComponent component, MethodExpression action) {
- if (action != null) {
- if (component instanceof ActionSource2) {
- ActionSource2 actionSource2 = (ActionSource2) component;
-
- actionSource2.setActionExpression(action);
- } else {
- throw new IllegalArgumentException(Messages.getMessage(Messages.NO_ACTION_SOURCE2_ERROR,
- component.getClientId(getFacesContext())));
- }
- }
- }
-
- protected void setConverterProperty(UIComponent component, ValueExpression converter) {
- if (converter != null) {
- if (component instanceof ValueHolder) {
- ValueHolder output = (ValueHolder) component;
-
- if (!converter.isLiteralText()) {
- component.setValueExpression("converter", converter);
- } else {
- Converter conv = FacesContext.getCurrentInstance().getApplication().createConverter(
- converter.getExpressionString());
-
- output.setConverter(conv);
- }
- } else {
- throw new IllegalArgumentException(Messages.getMessage(Messages.NO_VALUE_HOLDER_ERROR,
- component.getClass().getName()));
- }
- }
- }
-
- protected void setRowKeyConverterProperty(UIComponent component, ValueExpression converter) {
- if (converter != null) {
- if (component instanceof UIDataAdaptor) {
- UIDataAdaptor data = (UIDataAdaptor) component;
-
- if (!converter.isLiteralText()) {
- component.setValueExpression("rowKeyConverter", converter);
- } else {
- Converter conv = FacesContext.getCurrentInstance().getApplication().createConverter(
- converter.getExpressionString());
-
- data.setRowKeyConverter(conv);
- }
- } else {
- throw new IllegalArgumentException(Messages.getMessage(Messages.NO_DATA_ADAPTOR,
- component.getClass().getName()));
- }
- }
- }
-
- protected void setValidatorProperty(UIComponent component, MethodExpression validator) {
- if (validator != null) {
- if (component instanceof EditableValueHolder) {
- EditableValueHolder input = (EditableValueHolder) component;
-
- input.addValidator(new MethodExpressionValidator(validator));
- } else {
- throw new IllegalArgumentException(Messages.getMessage(Messages.NO_EDITABLE_VALUE_HOLDER_ERROR,
- component.getId()));
- }
- }
- }
-
- protected void setValueChangeListenerProperty(UIComponent component, MethodExpression valueChangeListener) {
- if (valueChangeListener != null) {
- if (component instanceof EditableValueHolder) {
- EditableValueHolder input = (EditableValueHolder) component;
-
- input.addValueChangeListener(new MethodExpressionValueChangeListener(valueChangeListener));
- } else {
- throw new IllegalArgumentException(Messages.getMessage(Messages.NO_EDITABLE_VALUE_HOLDER_ERROR,
- component.getId()));
- }
- }
- }
-}
Deleted: branches/RF-7560/core/impl/src/test/java/org/richfaces/component/DataAdaptorTestCase.java
===================================================================
--- branches/RF-7560/core/impl/src/test/java/org/richfaces/component/DataAdaptorTestCase.java 2010-08-31 16:59:42 UTC (rev 19051)
+++ branches/RF-7560/core/impl/src/test/java/org/richfaces/component/DataAdaptorTestCase.java 2010-08-31 17:20:11 UTC (rev 19052)
@@ -1,503 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright ${year}, 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.component;
-
-import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.EnumSet;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import javax.faces.component.ContextCallback;
-import javax.faces.component.UIComponent;
-import javax.faces.component.UIComponentBase;
-import javax.faces.component.UINamingContainer;
-import javax.faces.component.html.HtmlForm;
-import javax.faces.component.html.HtmlInputText;
-import javax.faces.component.html.HtmlOutputText;
-import javax.faces.component.visit.VisitCallback;
-import javax.faces.component.visit.VisitContext;
-import javax.faces.component.visit.VisitHint;
-import javax.faces.component.visit.VisitResult;
-import javax.faces.context.FacesContext;
-import javax.faces.event.AbortProcessingException;
-import javax.faces.event.PhaseId;
-import javax.faces.event.ValueChangeEvent;
-import javax.faces.event.ValueChangeListener;
-import javax.faces.model.ListDataModel;
-
-import org.ajax4jsf.component.IterationStateHolder;
-import org.ajax4jsf.model.ExtendedDataModel;
-import org.ajax4jsf.model.SequenceDataModel;
-import org.jboss.test.faces.AbstractFacesTest;
-
-/**
- * @author Nick Belaevski
- *
- */
-public class DataAdaptorTestCase extends AbstractFacesTest {
-
- private static final String VAR_NAME = "item";
-
- private static class TestCallback {
-
- private int value;
-
- public void handle() {
-
- }
-
- public void reset() {
- value = 0;
- }
-
- public int getAndIncrement() {
- return value++;
- }
-
- public int get() {
- return value;
- }
- }
-
- private MockDataAdaptor mockDataAdaptor;
-
- private List<String> data;
-
- private ExtendedDataModel<String> createDataModel() {
- return new SequenceDataModel<String>(new ListDataModel<String>(new ArrayList<String>(data)));
- }
-
- private Object getVarValue() {
- return facesContext.getApplication().evaluateExpressionGet(facesContext,
- MessageFormat.format("#'{'{0}'}'", VAR_NAME), Object.class);
- }
-
- @Override
- public void setUp() throws Exception {
- super.setUp();
-
- data = Arrays.asList("a", "b", "c", "d");
-
- setupFacesRequest();
-
- mockDataAdaptor = new MockDataAdaptor();
- mockDataAdaptor.setDataModel(createDataModel());
- mockDataAdaptor.setVar(VAR_NAME);
-
- facesContext.getViewRoot().getChildren().add(mockDataAdaptor);
- }
-
- @Override
- public void tearDown() throws Exception {
- super.tearDown();
-
- data = null;
- mockDataAdaptor = null;
- }
-
- private void resetCallbacks(TestCallback... callbacks) {
- for (TestCallback callback : callbacks) {
- callback.reset();
- assertEquals(0, callback.get());
- }
- }
-
- private UIComponent createCallbackComponent(final TestCallback callback) throws Exception {
- return new HtmlOutputText() {
-
- private void notifyCallbacks() {
- callback.handle();
- }
-
- @Override
- public void processDecodes(FacesContext context) {
- super.processDecodes(context);
- notifyCallbacks();
- }
-
- @Override
- public void processValidators(FacesContext context) {
- super.processValidators(context);
- notifyCallbacks();
- }
-
- @Override
- public void processUpdates(FacesContext context) {
- super.processUpdates(context);
- notifyCallbacks();
- }
- };
- }
-
- public void testProcessChildren() throws Exception {
-
- TestCallback childCallback = new TestCallback() {
- @Override
- public void handle() {
- assertEquals(getVarValue(), data.get(getAndIncrement()));
- }
- };
- UIComponent child = createCallbackComponent(childCallback);
- child.setId("child");
-
- TestCallback facetCallback = new TestCallback() {
- @Override
- public void handle() {
- assertEquals(getVarValue(), data.get(getAndIncrement()));
- }
- };
- UIComponent facet = createCallbackComponent(facetCallback);
- child.getFacets().put("f", facet);
- facet.setId("facet");
-
- TestCallback immediateFacetCallback = new TestCallback() {
- @Override
- public void handle() {
- getAndIncrement();
- assertNull(getVarValue());
- }
- };
- UIComponent immediateFacet = createCallbackComponent(immediateFacetCallback);
- immediateFacet.setId("immediateFacet");
-
- mockDataAdaptor.getChildren().add(child);
- mockDataAdaptor.getFacets().put("facet", immediateFacet);
-
- mockDataAdaptor.processDecodes(facesContext);
-
- assertEquals(data.size(), facetCallback.get());
- assertEquals(data.size(), childCallback.get());
- assertEquals(1, immediateFacetCallback.get());
-
- resetCallbacks(childCallback, facetCallback, immediateFacetCallback);
-
- mockDataAdaptor.processValidators(facesContext);
-
- assertEquals(data.size(), facetCallback.get());
- assertEquals(data.size(), childCallback.get());
- assertEquals(1, immediateFacetCallback.get());
-
- resetCallbacks(childCallback, facetCallback, immediateFacetCallback);
-
- mockDataAdaptor.processUpdates(facesContext);
-
- assertEquals(data.size(), facetCallback.get());
- assertEquals(data.size(), childCallback.get());
- assertEquals(1, immediateFacetCallback.get());
-
- resetCallbacks(childCallback, facetCallback, immediateFacetCallback);
- }
-
- public void testSaveRestoreChildrenState() throws Exception {
- HtmlForm form = new HtmlForm();
- HtmlInputText input = new HtmlInputText();
- IterationStateHolderComponent stateHolder = new IterationStateHolderComponent();
-
- List<UIComponent> children = mockDataAdaptor.getChildren();
- children.add(form);
- form.getChildren().add(input);
- form.getFacets().put("facet", stateHolder);
-
- mockDataAdaptor.setRowKey(facesContext, Integer.valueOf(0));
-
- assertFalse(form.isSubmitted());
- assertNull(input.getSubmittedValue());
- assertNull(input.getLocalValue());
- assertTrue(input.isValid());
- assertFalse(input.isLocalValueSet());
- assertNull(stateHolder.getIterationState());
-
- form.setSubmitted(true);
- input.setSubmittedValue("user input");
- input.setValue("component value");
- input.setValid(false);
- input.setLocalValueSet(true);
- stateHolder.setIterationState("state");
-
- mockDataAdaptor.setRowKey(facesContext, Integer.valueOf(1));
-
- assertFalse(form.isSubmitted());
- assertNull(input.getSubmittedValue());
- assertNull(input.getLocalValue());
- assertTrue(input.isValid());
- assertFalse(input.isLocalValueSet());
- assertNull(stateHolder.getIterationState());
-
- input.setSubmittedValue("another input from user");
- input.setValue("123");
- assertTrue(input.isLocalValueSet());
- stateHolder.setIterationState("456");
-
- mockDataAdaptor.setRowKey(facesContext, Integer.valueOf(0));
- assertTrue(form.isSubmitted());
- assertEquals("user input", input.getSubmittedValue());
- assertEquals("component value", input.getLocalValue());
- assertFalse(input.isValid());
- assertTrue(input.isLocalValueSet());
- assertEquals("state", stateHolder.getIterationState());
-
- mockDataAdaptor.setRowKey(facesContext, Integer.valueOf(1));
- assertFalse(form.isSubmitted());
- assertEquals("another input from user", input.getSubmittedValue());
- assertEquals("123", input.getLocalValue());
- assertTrue(input.isValid());
- assertTrue(input.isLocalValueSet());
- assertEquals("456", stateHolder.getIterationState());
-
- mockDataAdaptor.setRowKey(facesContext, null);
- assertFalse(form.isSubmitted());
- assertNull(input.getSubmittedValue());
- assertNull(input.getLocalValue());
- assertTrue(input.isValid());
- assertFalse(input.isLocalValueSet());
- assertNull(stateHolder.getIterationState());
- }
-
- public void testSaveRestoreChildrenStateNestedDataAdaptors() throws Exception {
- MockDataAdaptor childAdaptor = new MockDataAdaptor();
- childAdaptor.setDataModel(createDataModel());
-
- HtmlInputText input = new HtmlInputText();
-
- mockDataAdaptor.getChildren().add(childAdaptor);
- childAdaptor.getChildren().add(input);
-
- Integer rowKey = Integer.valueOf(2);
- Integer childKey = Integer.valueOf(1);
-
- mockDataAdaptor.setRowKey(facesContext, rowKey);
- childAdaptor.setRowKey(facesContext, childKey);
-
- assertNull(input.getSubmittedValue());
- assertNull(input.getLocalValue());
- assertTrue(input.isValid());
- assertFalse(input.isLocalValueSet());
-
- input.setSubmittedValue("submittedValue");
- input.setValue("value");
-
- childAdaptor.setRowKey(facesContext, null);
- mockDataAdaptor.setRowKey(facesContext, Integer.valueOf(3));
- childAdaptor.setRowKey(facesContext, Integer.valueOf(0));
-
- assertNull(input.getSubmittedValue());
- assertNull(input.getLocalValue());
- assertFalse(input.isLocalValueSet());
-
- childAdaptor.setRowKey(facesContext, null);
- mockDataAdaptor.setRowKey(facesContext, rowKey);
- childAdaptor.setRowKey(facesContext, childKey);
-
- assertEquals("submittedValue", input.getSubmittedValue());
- assertEquals("value", input.getLocalValue());
- assertTrue(input.isValid());
- assertTrue(input.isLocalValueSet());
- }
-
- public void testEventsQueueing() throws Exception {
- HtmlInputText input = new HtmlInputText();
-
- final TestCallback testCallback = new TestCallback();
- input.addValueChangeListener(new ValueChangeListener() {
-
- public void processValueChange(ValueChangeEvent event) throws AbortProcessingException {
- testCallback.getAndIncrement();
- assertEquals(data.get(1), getVarValue());
- }
- });
-
- mockDataAdaptor.getChildren().add(input);
- mockDataAdaptor.setRowKey(facesContext, Integer.valueOf(1));
- assertEquals(data.get(1), getVarValue());
-
- new ValueChangeEvent(input, null, "testValue").queue();
- mockDataAdaptor.setRowKey(facesContext, null);
-
- facesContext.getViewRoot().broadcastEvents(facesContext, PhaseId.PROCESS_VALIDATIONS);
- assertEquals(1, testCallback.get());
- }
-
- public void testInvokeOnComponent() throws Exception {
- final HtmlInputText facet = new HtmlInputText();
- final HtmlInputText child = new HtmlInputText();
-
- mockDataAdaptor.getFacets().put("facet", facet);
- mockDataAdaptor.getChildren().add(child);
-
- mockDataAdaptor.setId("_data");
- facet.setId("_facet");
- child.setId("_child");
-
- boolean invocationResult;
- final TestCallback callback = new TestCallback();
- invocationResult = mockDataAdaptor.invokeOnComponent(facesContext, "_data", new ContextCallback() {
-
- public void invokeContextCallback(FacesContext context, UIComponent target) {
- callback.getAndIncrement();
- assertEquals(mockDataAdaptor, target);
- assertEquals("_data", target.getClientId());
- }
- });
-
- assertTrue(invocationResult);
- assertEquals(1, callback.get());
- callback.reset();
-
- final char separatorChar = UINamingContainer.getSeparatorChar(facesContext);
- invocationResult = mockDataAdaptor.invokeOnComponent(facesContext, "_data" + separatorChar + "_facet",
- new ContextCallback() {
-
- public void invokeContextCallback(FacesContext context, UIComponent target) {
- callback.getAndIncrement();
- assertEquals(facet, target);
- assertEquals("_data" + separatorChar + "_facet", target.getClientId());
- }
- });
-
- assertTrue(invocationResult);
- assertEquals(1, callback.get());
- callback.reset();
-
- invocationResult = mockDataAdaptor.invokeOnComponent(facesContext, "_data" + separatorChar + "2"
- + separatorChar + "_child", new ContextCallback() {
-
- public void invokeContextCallback(FacesContext context, UIComponent target) {
- callback.getAndIncrement();
- assertEquals(child, target);
- assertEquals(data.get(2), getVarValue());
- assertEquals("_data" + separatorChar + "2" + separatorChar + "_child", target.getClientId());
- }
- });
-
- assertTrue(invocationResult);
- assertEquals(1, callback.get());
- callback.reset();
-
- invocationResult = mockDataAdaptor.invokeOnComponent(facesContext, "_data" + separatorChar + "100"
- + separatorChar + "_child", new ContextCallback() {
-
- public void invokeContextCallback(FacesContext context, UIComponent target) {
- fail();
- }
- });
- assertFalse(invocationResult);
-
- invocationResult = mockDataAdaptor.invokeOnComponent(facesContext, "_data" + separatorChar
- + "nonExistentComponent", new ContextCallback() {
-
- public void invokeContextCallback(FacesContext context, UIComponent target) {
- fail();
- }
- });
- assertFalse(invocationResult);
- }
-
- public void testVisitChildren() throws Exception {
- final HtmlInputText facet = new HtmlInputText();
- final HtmlInputText child = new HtmlInputText();
-
- mockDataAdaptor.getFacets().put("facet", facet);
- mockDataAdaptor.getChildren().add(child);
-
- mockDataAdaptor.setId("_data");
- facet.setId("_facet");
- child.setId("_child");
-
- VisitContext fullVisitContext = VisitContext.createVisitContext(facesContext);
-
- final char separatorChar = UINamingContainer.getSeparatorChar(facesContext);
- final Set<String> idsToVisit = new HashSet<String>();
- idsToVisit.add("_data" + separatorChar + "_facet");
- idsToVisit.add("_data" + separatorChar + "0" + separatorChar + "_child");
- idsToVisit.add("_data" + separatorChar + "2" + separatorChar + "_child");
-
- VisitContext partialVisitContext = VisitContext.createVisitContext(facesContext, idsToVisit, EnumSet
- .of(VisitHint.SKIP_UNRENDERED));
-
- final TestCallback callback = new TestCallback();
- mockDataAdaptor.visitTree(fullVisitContext, new VisitCallback() {
-
- public VisitResult visit(VisitContext context, UIComponent target) {
- callback.getAndIncrement();
- assertNotNull(target);
-
- return VisitResult.ACCEPT;
- }
- });
-
- assertEquals(1 /* adaptor itself */+ 1 /* facet */+ data.size(), callback.get());
-
- callback.reset();
-
- mockDataAdaptor.visitTree(partialVisitContext, new VisitCallback() {
-
- public VisitResult visit(VisitContext context, UIComponent target) {
- callback.getAndIncrement();
- assertNotNull(target);
- assertTrue(idsToVisit.contains(target.getClientId()));
- return VisitResult.ACCEPT;
- }
- });
-
- assertEquals(idsToVisit.size(), callback.get());
-
- callback.reset();
-
- mockDataAdaptor.visitTree(fullVisitContext, new VisitCallback() {
-
- public VisitResult visit(VisitContext context, UIComponent target) {
- callback.getAndIncrement();
-
- if (child.equals(target)
- && child.getClientId().equals("_data" + separatorChar + "1" + separatorChar + "_child")) {
- return VisitResult.COMPLETE;
- }
-
- return VisitResult.ACCEPT;
- }
- });
-
- assertEquals(1 /* data adaptor */+ 1 /* facet */+ 2 /* [0..1] children */, callback.get());
- }
-}
-
-class IterationStateHolderComponent extends UIComponentBase implements IterationStateHolder {
-
- private Object iterationState;
-
- @Override
- public String getFamily() {
- return "test.Component";
- }
-
- public Object getIterationState() {
- return iterationState;
- }
-
- public void setIterationState(Object state) {
- iterationState = state;
- }
-
-}
Deleted: branches/RF-7560/core/impl/src/test/java/org/richfaces/component/MockDataAdaptor.java
===================================================================
--- branches/RF-7560/core/impl/src/test/java/org/richfaces/component/MockDataAdaptor.java 2010-08-31 16:59:42 UTC (rev 19051)
+++ branches/RF-7560/core/impl/src/test/java/org/richfaces/component/MockDataAdaptor.java 2010-08-31 17:20:11 UTC (rev 19052)
@@ -1,66 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, 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.component;
-
-import javax.faces.context.FacesContext;
-import javax.faces.convert.Converter;
-
-import org.ajax4jsf.model.DataComponentState;
-import org.ajax4jsf.model.ExtendedDataModel;
-
-/**
- * @author Nick Belaevski
- *
- */
-public class MockDataAdaptor extends UIDataAdaptor {
-
- private ExtendedDataModel<?> dataModel;
-
- @Override
- protected DataComponentState createComponentState() {
- return new MockDataAdaptorComponentState();
- }
-
- @Override
- protected ExtendedDataModel<?> createExtendedDataModel() {
- return dataModel;
- }
-
- public ExtendedDataModel<?> getDataModel() {
- return dataModel;
- }
-
- public void setDataModel(ExtendedDataModel<?> dataModel) {
- this.dataModel = dataModel;
- }
-
- /* (non-Javadoc)
- * @see org.richfaces.component.UIDataAdaptor#getRowKeyConverter()
- */
- @Override
- public Converter getRowKeyConverter() {
- // TODO Auto-generated method stub
- FacesContext facesContext = FacesContext.getCurrentInstance();
- return facesContext.getApplication().createConverter(Integer.class);
- }
-
-}
Deleted: branches/RF-7560/core/impl/src/test/java/org/richfaces/component/MockDataAdaptorComponentState.java
===================================================================
--- branches/RF-7560/core/impl/src/test/java/org/richfaces/component/MockDataAdaptorComponentState.java 2010-08-31 16:59:42 UTC (rev 19051)
+++ branches/RF-7560/core/impl/src/test/java/org/richfaces/component/MockDataAdaptorComponentState.java 2010-08-31 17:20:11 UTC (rev 19052)
@@ -1,39 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, 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.component;
-
-import org.ajax4jsf.model.DataComponentState;
-import org.ajax4jsf.model.Range;
-import org.ajax4jsf.model.SequenceRange;
-
-/**
- * @author Nick Belaevski
- *
- */
-public class MockDataAdaptorComponentState implements DataComponentState {
-
- private Range range = new SequenceRange(0, -1);
-
- public Range getRange() {
- return range;
- }
-}
Deleted: branches/RF-7560/core/impl/src/test/java/org/richfaces/component/SequenceIterationStatusTest.java
===================================================================
--- branches/RF-7560/core/impl/src/test/java/org/richfaces/component/SequenceIterationStatusTest.java 2010-08-31 16:59:42 UTC (rev 19051)
+++ branches/RF-7560/core/impl/src/test/java/org/richfaces/component/SequenceIterationStatusTest.java 2010-08-31 17:20:11 UTC (rev 19052)
@@ -1,158 +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.component;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-import org.junit.Test;
-
-
-/**
- * @author Nick Belaevski
- *
- */
-public class SequenceIterationStatusTest {
-
- @Test
- public void testBeginEnd() throws Exception {
- SequenceIterationStatus s1 = new SequenceIterationStatus(5, 10, 5, 100);
- assertEquals(Integer.valueOf(5), s1.getBegin());
- assertEquals(Integer.valueOf(10), s1.getEnd());
-
- SequenceIterationStatus s2 = new SequenceIterationStatus(null, null, 5, 100);
- assertNull(s2.getBegin());
- assertEquals(Integer.valueOf(99), s2.getEnd());
-
- SequenceIterationStatus s3 = new SequenceIterationStatus(null, null, 5, null);
- assertNull(s3.getBegin());
- assertEquals(Integer.valueOf(Integer.MAX_VALUE), s3.getEnd());
- }
-
- @Test
- public void testFirst() throws Exception {
- SequenceIterationStatus s1 = new SequenceIterationStatus(0, 10, 0, 100);
- assertTrue(s1.isFirst());
- assertFalse(s1.isLast());
-
- SequenceIterationStatus s2 = new SequenceIterationStatus(0, 10, 1, 100);
- assertFalse(s2.isFirst());
- assertFalse(s2.isLast());
-
- SequenceIterationStatus s3 = new SequenceIterationStatus(0, 0, 0, 100);
- assertTrue(s3.isFirst());
- assertTrue(s3.isLast());
-
- SequenceIterationStatus s4 = new SequenceIterationStatus(5, 10, 5, 100);
- assertTrue(s4.isFirst());
- assertFalse(s4.isLast());
-
- SequenceIterationStatus s5 = new SequenceIterationStatus(5, 10, 6, 100);
- assertFalse(s5.isFirst());
- assertFalse(s5.isLast());
-
- SequenceIterationStatus s6 = new SequenceIterationStatus(null, 10, 0, 100);
- assertTrue(s6.isFirst());
- assertFalse(s6.isLast());
- }
-
- @Test
- public void testLast() throws Exception {
- SequenceIterationStatus s1 = new SequenceIterationStatus(0, 9, 9, 100);
- assertTrue(s1.isLast());
- assertFalse(s1.isFirst());
-
- SequenceIterationStatus s2 = new SequenceIterationStatus(0, 9, 8, 100);
- assertFalse(s2.isLast());
- assertFalse(s2.isFirst());
-
- SequenceIterationStatus s3 = new SequenceIterationStatus(0, 100, 9, 10);
- assertTrue(s3.isLast());
- assertFalse(s3.isFirst());
-
- SequenceIterationStatus s4 = new SequenceIterationStatus(0, 100, 8, 10);
- assertFalse(s4.isLast());
- assertFalse(s4.isFirst());
-
- SequenceIterationStatus s5 = new SequenceIterationStatus(0, null, 9, 10);
- assertTrue(s5.isLast());
- assertFalse(s5.isFirst());
-
- SequenceIterationStatus s6 = new SequenceIterationStatus(0, null, 8, 10);
- assertFalse(s6.isLast());
- assertFalse(s6.isFirst());
- }
-
- @Test
- public void testIsEvenOdd() throws Exception {
- SequenceIterationStatus s1 = new SequenceIterationStatus(0, 100, 0, 10);
- assertTrue(s1.isOdd());
- assertFalse(s1.isEven());
-
- SequenceIterationStatus s2 = new SequenceIterationStatus(0, 100, 1, 10);
- assertTrue(s2.isEven());
- assertFalse(s2.isOdd());
-
- SequenceIterationStatus s3 = new SequenceIterationStatus(5, 100, 7, 10);
- assertTrue(s3.isOdd());
- assertFalse(s3.isEven());
-
- SequenceIterationStatus s4 = new SequenceIterationStatus(5, 100, 6, 10);
- assertTrue(s4.isEven());
- assertFalse(s4.isOdd());
- }
-
- @Test
- public void testGetRowCount() throws Exception {
- SequenceIterationStatus s1 = new SequenceIterationStatus(0, 100, 0, 200);
- assertEquals(Integer.valueOf(200), s1.getRowCount());
-
- SequenceIterationStatus s2 = new SequenceIterationStatus(0, 400, 100, 150);
- assertEquals(Integer.valueOf(150), s2.getRowCount());
- }
-
- @Test
- public void testGetIndex() throws Exception {
- SequenceIterationStatus s1 = new SequenceIterationStatus(0, 100, 30, 200);
- assertTrue(30 == s1.getIndex());
-
- SequenceIterationStatus s2 = new SequenceIterationStatus(0, 400, 100, 150);
- assertTrue(100 == s2.getIndex());
- }
-
- @Test
- public void testGetCount() throws Exception {
- SequenceIterationStatus s1 = new SequenceIterationStatus(0, 100, 0, 10);
- assertTrue(s1.getCount() == 1);
-
- SequenceIterationStatus s2 = new SequenceIterationStatus(0, 100, 1, 10);
- assertTrue(s2.getCount() == 2);
-
- SequenceIterationStatus s3 = new SequenceIterationStatus(5, 100, 7, 10);
- assertTrue(s3.getCount() == 3);
-
- SequenceIterationStatus s4 = new SequenceIterationStatus(5, 100, 8, 10);
- assertTrue(s4.getCount() == 4);
- }
-}
Modified: branches/RF-7560/core/impl/src/test/java/org/richfaces/context/AjaxTableComponentImpl.java
===================================================================
--- branches/RF-7560/core/impl/src/test/java/org/richfaces/context/AjaxTableComponentImpl.java 2010-08-31 16:59:42 UTC (rev 19051)
+++ branches/RF-7560/core/impl/src/test/java/org/richfaces/context/AjaxTableComponentImpl.java 2010-08-31 17:20:11 UTC (rev 19052)
@@ -19,21 +19,29 @@
* 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.util.Collection;
+
import javax.faces.component.UIComponent;
+import javax.faces.component.UIData;
import javax.faces.component.visit.VisitCallback;
import javax.faces.component.visit.VisitContext;
import javax.faces.component.visit.VisitResult;
+import javax.faces.context.FacesContext;
-import org.richfaces.component.UISequence;
+import org.richfaces.log.Logger;
+import org.richfaces.log.RichfacesLogger;
/**
* @author Nick Belaevski
*
*/
-public class AjaxTableComponentImpl extends UISequence {
+public class AjaxTableComponentImpl extends UIData {
+ private static final Logger LOG = RichfacesLogger.COMPONENTS.getLogger();
+
private boolean visitMetaComponent(String name, ExtendedVisitContext visitContext, VisitCallback callback) {
UIComponent facet = getFacet(name);
if (facet != null) {
@@ -51,7 +59,81 @@
}
}
+ private boolean doVisitChildren(VisitContext context) {
+ // TODO optimize for returned IDs
+ Collection<String> idsToVisit = context.getSubtreeIdsToVisit(this);
+
+ assert idsToVisit != null;
+
+ if (idsToVisit == VisitContext.ALL_IDS) {
+ // TODO
+ }
+
+ // All ids or non-empty collection means we need to visit our children.
+ return !idsToVisit.isEmpty();
+ }
+
@Override
+ public boolean visitTree(VisitContext visitContext, VisitCallback callback) {
+
+ // First check to see whether we are visitable. If not
+ // short-circuit out of this subtree, though allow the
+ // visit to proceed through to other subtrees.
+ if (!isVisitable(visitContext)) {
+ return false;
+ }
+
+ // Clear out the row index is one is set so that
+ // we start from a clean slate.
+ FacesContext facesContext = visitContext.getFacesContext();
+
+ int oldRowIndex = getRowIndex();
+ setRowIndex(-1);
+
+ // Push ourselves to EL
+ pushComponentToEL(facesContext, null);
+
+ try {
+
+ // Visit ourselves. Note that we delegate to the
+ // VisitContext to actually perform the visit.
+ VisitResult result = visitContext.invokeVisitCallback(this, callback);
+
+ // If the visit is complete, short-circuit out and end the visit
+ if (result == VisitResult.COMPLETE) {
+ return true;
+ }
+
+ // Visit children, short-circuiting as necessary
+ if ((result == VisitResult.ACCEPT) && doVisitChildren(visitContext)) {
+ setRowIndex(-1);
+
+ if (visitFixedChildren(visitContext, callback)) {
+ return true;
+ }
+
+ if (visitDataChildren(visitContext, callback)) {
+ return true;
+ }
+ }
+ } finally {
+
+ // Clean up - pop EL and restore old row index
+ popComponentFromEL(facesContext);
+
+ try {
+ setRowIndex(oldRowIndex);
+ } catch (Exception e) {
+
+ // TODO: handle exception
+ LOG.error(e.getMessage(), e);
+ }
+ }
+
+ // Return false to allow the visit to continue
+ return false;
+ }
+
protected boolean visitFixedChildren(VisitContext visitContext, VisitCallback callback) {
if (visitContext instanceof ExtendedVisitContext) {
@@ -67,8 +149,38 @@
return false;
} else {
- return super.visitFixedChildren(visitContext, callback);
+ for (UIComponent facet: getFacets().values()) {
+ if (facet.visitTree(visitContext, callback)) {
+ return true;
+ }
+ }
+
+ return false;
}
}
+ protected boolean visitDataChildren(VisitContext visitContext, VisitCallback callback) {
+ int rowIndex = 0;
+
+ for (setRowIndex(rowIndex); isRowAvailable(); setRowIndex(++rowIndex)) {
+ VisitResult result = visitContext.invokeVisitCallback(this, callback);
+
+ if (result == VisitResult.COMPLETE) {
+ return true;
+ }
+
+ if (result == VisitResult.REJECT) {
+ continue;
+ }
+
+ for (UIComponent child: getChildren()) {
+ if (child.visitTree(visitContext, callback)) {
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
+
}
Modified: branches/RF-7560/core/impl/src/test/java/org/richfaces/context/ExtendedPartialVisitContextTest.java
===================================================================
--- branches/RF-7560/core/impl/src/test/java/org/richfaces/context/ExtendedPartialVisitContextTest.java 2010-08-31 16:59:42 UTC (rev 19051)
+++ branches/RF-7560/core/impl/src/test/java/org/richfaces/context/ExtendedPartialVisitContextTest.java 2010-08-31 17:20:11 UTC (rev 19052)
@@ -44,6 +44,7 @@
import javax.el.ExpressionFactory;
import javax.el.ValueExpression;
import javax.faces.application.Application;
+import javax.faces.component.UIColumn;
import javax.faces.component.UIComponent;
import javax.faces.component.UIForm;
import javax.faces.component.UIOutput;
@@ -76,17 +77,21 @@
* <h:outputText id="theHeader" />
* </f:facet>
*
- * <a4j:outputText id="nestedOutput" value="#{item}" />
+ * <h:column>
+ * <a4j:outputText id="nestedOutput" value="#{item}" />
*
- * <h:outputText id="nestedText" value="#{item}" />
+ * <h:outputText id="nestedText" value="#{item}" />
*
- * <a4j:table id="nestedTable" value="['Nested item 0',... ,'Nested item 2']" var="nestedItem">
- * <f:facet name="footer">
- * <h:outputText id="nestedTableFooter" value="#{item}" />
- * </f:facet>
+ * <a4j:table id="nestedTable" value="['Nested item 0',... ,'Nested item 2']" var="nestedItem">
+ * <f:facet name="footer">
+ * <h:outputText id="nestedTableFooter" value="#{item}" />
+ * </f:facet>
*
- * <h:outputText id="nestedTableText" value="#{nestedItem}" />
- * </a4j:table>
+ * <h:column>
+ * <h:outputText id="nestedTableText" value="#{nestedItem}" />
+ * </h:column>
+ * </a4j:table>
+ * </h:column>
* </a4j:table>
* </h:form>
* </pre>
@@ -220,7 +225,7 @@
nestedText.setId("nestedText");
nestedText.setValueExpression("value", createTableVarValueExpression());
- table.getChildren().add(nestedText);
+ table.getChildren().get(0).getChildren().add(nestedText);
}
private void createNestedOutput() {
@@ -229,7 +234,7 @@
nestedOutput.setId("nestedOutput");
nestedOutput.setValueExpression("value", createTableVarValueExpression());
- table.getChildren().add(nestedOutput);
+ table.getChildren().get(0).getChildren().add(nestedOutput);
}
private void createOuterOutput() {
@@ -255,7 +260,9 @@
createNestedTableData();
nestedTable.setValue(nestedTableData);
- table.getChildren().add(nestedTable);
+ nestedTable.getChildren().add(new UIColumn());
+
+ table.getChildren().get(0).getChildren().add(nestedTable);
createNestedTableText();
createNestedTableFooter();
@@ -274,7 +281,7 @@
nestedTableText.setId("nestedTableText");
nestedTableText.setValueExpression("value", createNestedTableVarValueExpression());
- nestedTable.getChildren().add(nestedTableText);
+ nestedTable.getChildren().get(0).getChildren().add(nestedTableText);
}
private void createTable() {
@@ -285,6 +292,8 @@
createTableData();
table.setValue(tableData);
+ table.getChildren().add(new UIColumn());
+
form.getChildren().add(table);
createNestedOutput();
createNestedText();
@@ -478,7 +487,7 @@
assertEqualSets(tableClientIds, renderingContext.getSubtreeIdsToVisit(table));
assertEqualSets(tableIds, renderingContext.getDirectSubtreeIdsToVisit(table));
- table.setRowKey(Integer.valueOf(0));
+ table.setRowIndex(0);
Set<String> nestedTableClientIds = asSet("myForm:table:0:nestedTable:1",
"myForm:table:0:nestedTable:nestedFooter");
@@ -487,7 +496,7 @@
assertEqualSets(nestedTableClientIds, renderingContext.getSubtreeIdsToVisit(nestedTable));
assertEqualSets(nestedTableIds, renderingContext.getDirectSubtreeIdsToVisit(nestedTable));
- table.setRowKey(null);
+ table.setRowIndex(-1);
}
@Test
@@ -503,7 +512,7 @@
assertSame(VisitContext.ALL_IDS, renderingContext.getDirectSubtreeIdsToVisit(table));
for (int i = 0; i < tableData.size(); i++) {
- table.setRowKey(Integer.valueOf(i));
+ table.setRowIndex(i);
assertSame(VisitContext.ALL_IDS, renderingContext.getSubtreeIdsToVisit(table));
assertEqualSets(asSet("nestedText", "nestedTable", "nestedOutput"),
@@ -513,7 +522,7 @@
assertEqualSets(asSet("0"), renderingContext.getDirectSubtreeIdsToVisit(nestedTable));
}
- table.setRowKey(null);
+ table.setRowIndex(-1);
}
@Test
@@ -529,7 +538,7 @@
assertSame(VisitContext.ALL_IDS, renderingContext.getDirectSubtreeIdsToVisit(table));
for (int i = 0; i < tableData.size(); i++) {
- table.setRowKey(Integer.valueOf(i));
+ table.setRowIndex(i);
assertSame(VisitContext.ALL_IDS, renderingContext.getSubtreeIdsToVisit(table));
assertEqualSets(asSet("nestedText", "nestedTable"), renderingContext.getDirectSubtreeIdsToVisit(table));
@@ -538,7 +547,7 @@
assertEqualSets(asSet("0"), renderingContext.getDirectSubtreeIdsToVisit(nestedTable));
}
- table.setRowKey(null);
+ table.setRowIndex(-1);
}
@Test
@@ -553,7 +562,7 @@
assertSame(VisitContext.ALL_IDS, renderingContext.getDirectSubtreeIdsToVisit(table));
for (int i = 0; i < tableData.size(); i++) {
- table.setRowKey(Integer.valueOf(i));
+ table.setRowIndex(i);
assertSame(VisitContext.ALL_IDS, renderingContext.getSubtreeIdsToVisit(table));
assertEqualSets(asSet("nestedTable"), renderingContext.getDirectSubtreeIdsToVisit(table));
@@ -562,7 +571,7 @@
assertTrue(renderingContext.getDirectSubtreeIdsToVisit(nestedTable).isEmpty());
}
- table.setRowKey(null);
+ table.setRowIndex(-1);
}
@Test
Deleted: branches/RF-7560/core/impl/src/test/java/org/richfaces/renderkit/CompositeRendererTest.java
===================================================================
--- branches/RF-7560/core/impl/src/test/java/org/richfaces/renderkit/CompositeRendererTest.java 2010-08-31 16:59:42 UTC (rev 19051)
+++ branches/RF-7560/core/impl/src/test/java/org/richfaces/renderkit/CompositeRendererTest.java 2010-08-31 17:20:11 UTC (rev 19052)
@@ -1,368 +0,0 @@
-package org.richfaces.renderkit;
-
-import java.io.IOException;
-import java.io.StringWriter;
-import java.util.Arrays;
-import java.util.Map;
-
-import javax.faces.component.NamingContainer;
-import javax.faces.component.UIComponent;
-import javax.faces.component.UIForm;
-import javax.faces.component.UIInput;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-
-import org.jboss.test.faces.AbstractFacesTest;
-
-public class CompositeRendererTest extends AbstractFacesTest {
- private CompositeRenderer compositeRenderer;
-
- public void setUp() throws Exception {
- super.setUp();
- setupFacesRequest();
- this.compositeRenderer = new CompositeRenderer() {
- protected Class<? extends UIComponent> getComponentClass() {
- return UIComponent.class;
- }
- };
- }
-
- public void tearDown() throws Exception {
- super.tearDown();
- this.compositeRenderer = null;
- }
-
- public final void testDoDecodeFacesContextUIComponent() {
- MockDecodeContributor[] contributors = new MockDecodeContributor[5];
-
- for (int i = 0; i < contributors.length; i++) {
- contributors[i] = new MockDecodeContributor();
- compositeRenderer.addContributor(contributors[i]);
- }
-
- UIInput component = new UIInput();
-
- compositeRenderer.doDecode(facesContext, component);
-
- for (int i = 0; i < contributors.length; i++) {
- assertSame(compositeRenderer, contributors[i].getRenderer());
- assertSame(facesContext, contributors[i].getContext());
- assertSame(component, contributors[i].getComponent());
- }
- }
-
- public final void testMergeScriptOptionsScriptOptionsFacesContextUIComponent() {
- UIInput input = new UIInput();
- ScriptOptions inputOptions = new ScriptOptions(input);
-
- inputOptions.addOption("input", "1");
-
- ScriptOptions formOptions = new ScriptOptions(input);
-
- formOptions.addOption("form", "2");
-
- ScriptOptions options = new ScriptOptions(input);
-
- options.addOption("generic", "3");
-
- MockDecodeContributor inputContributor;
- MockDecodeContributor formContributor;
- MockDecodeContributor contributor;
- MockDecodeContributor nullContributor;
-
- inputContributor = new MockDecodeContributor(UIComponent.class, inputOptions);
- formContributor = new MockDecodeContributor(UIComponent.class, formOptions);
- contributor = new MockDecodeContributor(UIComponent.class, options);
- nullContributor = new MockDecodeContributor(UIComponent.class, (ScriptOptions) null);
- compositeRenderer.addContributor(contributor);
- compositeRenderer.addContributor(formContributor);
- compositeRenderer.addContributor(inputContributor);
- compositeRenderer.addContributor(nullContributor);
-
- ScriptOptions scriptOptions = new ScriptOptions(input);
-
- compositeRenderer.mergeScriptOptions(scriptOptions, facesContext, input);
-
- Map map = scriptOptions.getMap();
-
- assertEquals(3, map.size());
- assertEquals("1", map.get("input"));
- assertEquals("2", map.get("form"));
- assertEquals("3", map.get("generic"));
- }
-
- public final void testMergeScriptOptionsScriptOptionsFacesContextUIComponentClass() {
- UIInput input = new UIInput();
- ScriptOptions inputOptions = new ScriptOptions(input);
-
- inputOptions.addOption("input", "1");
-
- ScriptOptions formOptions = new ScriptOptions(input);
-
- formOptions.addOption("form", "2");
-
- ScriptOptions options = new ScriptOptions(input);
-
- options.addOption("generic", "3");
-
- MockDecodeContributor inputContributor;
- MockDecodeContributor formContributor;
- MockDecodeContributor contributor;
- MockDecodeContributor nullContributor;
-
- inputContributor = new MockDecodeContributor(UIInput.class, inputOptions);
- formContributor = new MockDecodeContributor(NamingContainer.class, formOptions);
- contributor = new MockDecodeContributor(UIComponent.class, options);
- nullContributor = new MockDecodeContributor(UIForm.class, (ScriptOptions) null);
- compositeRenderer.addContributor(contributor);
- compositeRenderer.addContributor(formContributor);
- compositeRenderer.addContributor(inputContributor);
- compositeRenderer.addContributor(nullContributor);
-
- ScriptOptions scriptOptions = new ScriptOptions(input);
-
- compositeRenderer.mergeScriptOptions(scriptOptions, facesContext, input, UIForm.class);
-
- Map map = scriptOptions.getMap();
-
- assertEquals(2, map.size());
- assertEquals("2", map.get("form"));
- assertEquals("3", map.get("generic"));
- }
-
- public final void testGetScriptContributionsStringFacesContextUIComponent() {
- MockDecodeContributor inputContributor;
- MockDecodeContributor formContributor;
- MockDecodeContributor contributor;
- MockDecodeContributor nullContributor;
-
- inputContributor = new MockDecodeContributor(UIComponent.class, ".1;");
- formContributor = new MockDecodeContributor(UIComponent.class, ".2;");
- contributor = new MockDecodeContributor(UIComponent.class, ".3;");
- nullContributor = new MockDecodeContributor(UIForm.class, (String) null);
- compositeRenderer.addContributor(contributor);
- compositeRenderer.addContributor(formContributor);
- compositeRenderer.addContributor(inputContributor);
- compositeRenderer.addContributor(nullContributor);
-
- UIInput input = new UIInput();
-
- input.getAttributes().put("test", ".testValue");
-
- String contributions = compositeRenderer.getScriptContributions("theVar", facesContext, input);
-
- assertEquals("theVar.testValue.3;theVar.testValue.2;theVar.testValue.1;", contributions);
- }
-
- public final void testGetScriptContributionsStringFacesContextUIComponentClass() {
- MockDecodeContributor inputContributor;
- MockDecodeContributor formContributor;
- MockDecodeContributor contributor;
- MockDecodeContributor nullContributor;
-
- inputContributor = new MockDecodeContributor(UIInput.class, ".input;");
- formContributor = new MockDecodeContributor(NamingContainer.class, ".namingContainer;");
- contributor = new MockDecodeContributor(UIComponent.class, ".generic;");
- nullContributor = new MockDecodeContributor(UIForm.class, (String) null);
- compositeRenderer.addContributor(contributor);
- compositeRenderer.addContributor(formContributor);
- compositeRenderer.addContributor(inputContributor);
- compositeRenderer.addContributor(nullContributor);
-
- UIInput input = new UIInput();
-
- input.getAttributes().put("test", ".testValue");
-
- String contributions = compositeRenderer.getScriptContributions("theVar", facesContext, input, UIForm.class);
-
- assertEquals("theVar.testValue.generic;theVar.testValue.namingContainer;", contributions);
- }
-
- public final void testAddContributor() {
- MockDecodeContributor[] contributors = new MockDecodeContributor[5];
-
- for (int i = 0; i < contributors.length; i++) {
- contributors[i] = new MockDecodeContributor();
- compositeRenderer.addContributor(contributors[i]);
- }
-
- assertTrue(Arrays.deepEquals(contributors, compositeRenderer.getContributors()));
- }
-
- public final void testContributorDecodeCallback() {
- MockDecodeContributor inputContributor;
- MockDecodeContributor formContributor;
-
- formContributor = new MockDecodeContributor(NamingContainer.class);
- inputContributor = new MockDecodeContributor(UIInput.class);
- compositeRenderer.addContributor(inputContributor);
- compositeRenderer.addContributor(formContributor);
-
- UIComponent component = new UIInput();
-
- compositeRenderer.doDecode(facesContext, component);
- assertSame(compositeRenderer, inputContributor.getRenderer());
- assertSame(facesContext, inputContributor.getContext());
- assertSame(component, inputContributor.getComponent());
- assertNull(formContributor.getRenderer());
- assertNull(formContributor.getContext());
- assertNull(formContributor.getComponent());
- inputContributor.reset();
- formContributor.reset();
- assertNull(inputContributor.getRenderer());
- assertNull(inputContributor.getContext());
- assertNull(inputContributor.getComponent());
- assertNull(formContributor.getRenderer());
- assertNull(formContributor.getContext());
- assertNull(formContributor.getComponent());
- component = new UIForm();
- compositeRenderer.doDecode(facesContext, component);
- assertSame(compositeRenderer, formContributor.getRenderer());
- assertSame(facesContext, formContributor.getContext());
- assertSame(component, formContributor.getComponent());
- assertNull(inputContributor.getRenderer());
- assertNull(inputContributor.getContext());
- assertNull(inputContributor.getComponent());
- }
-
- public final void testAddParameterEncoder() {
- MockAttributeParameterEncoder[] encoders = new MockAttributeParameterEncoder[5];
-
- for (int i = 0; i < encoders.length; i++) {
- encoders[i] = new MockAttributeParameterEncoder("aaa");
- compositeRenderer.addParameterEncoder(encoders[i]);
- }
-
- assertTrue(Arrays.deepEquals(encoders, compositeRenderer.getParameterEncoders()));
- }
-
- public final void testEncodeAttributeParameters() throws IOException {
- MockAttributeParameterEncoder encoder1 = new MockAttributeParameterEncoder("Attribute");
- MockAttributeParameterEncoder encoder2 = new MockAttributeParameterEncoder("MoreAttribute");
-
- compositeRenderer.addParameterEncoder(encoder1);
- compositeRenderer.addParameterEncoder(encoder2);
-
- UIInput input = new UIInput();
-
- input.getAttributes().put("Attribute", "testValue1");
- input.getAttributes().put("MoreAttribute", "testValue2");
-
- // ResponseWriter responseWriter = facesContext.getResponseWriter();
- StringWriter stringWriter = new StringWriter();
- ResponseWriter responseWriter = facesContext.getRenderKit().createResponseWriter(stringWriter, "text/html",
- "UTF8");
-
- facesContext.setResponseWriter(responseWriter);
- responseWriter.startDocument();
- responseWriter.startElement("span", input);
- compositeRenderer.encodeAttributeParameters(facesContext, input);
- responseWriter.endElement("span");
- responseWriter.endDocument();
- responseWriter.flush();
-
- String result = stringWriter.getBuffer().toString();
-
- assertTrue(result.contains("testAttribute=\"testValue1\""));
- assertTrue(result.contains("testMoreAttribute=\"testValue2\""));
- }
-}
-
-
-class MockAttributeParameterEncoder implements AttributeParametersEncoder {
- private String attributeName;
-
- public MockAttributeParameterEncoder(String attributeName) {
- super();
- this.attributeName = attributeName;
- }
-
- public void doEncode(FacesContext context, UIComponent component) throws IOException {
- context.getResponseWriter().writeAttribute("test" + attributeName,
- component.getAttributes().get(attributeName), null);
- }
-}
-
-
-class MockDecodeContributor implements RendererContributor {
- private UIComponent component;
- private Class componentClass;
- private FacesContext context;
- private ScriptOptions options;
- private CompositeRenderer renderer;
- private String scriptContribution;
- private String[] scriptDependencies;
- private String[] styleDependencies;
-
- public MockDecodeContributor() {
- this(UIComponent.class);
- }
-
- public MockDecodeContributor(Class componentClass) {
- super();
- this.componentClass = componentClass;
- }
-
- public MockDecodeContributor(Class componentClass, ScriptOptions options) {
- super();
- this.componentClass = componentClass;
- this.options = options;
- }
-
- public MockDecodeContributor(Class componentClass, String scriptContribution) {
- super();
- this.componentClass = componentClass;
- this.scriptContribution = scriptContribution;
- }
-
- public MockDecodeContributor(Class componentClass, String[] scriptDependencies, String[] styleDependencies) {
- super();
- this.componentClass = componentClass;
- this.scriptDependencies = scriptDependencies;
- this.styleDependencies = styleDependencies;
- }
-
- public void decode(FacesContext context, UIComponent component, CompositeRenderer compositeRenderer) {
- this.component = component;
- this.context = context;
- this.renderer = compositeRenderer;
- }
-
- public Class getAcceptableClass() {
- return componentClass;
- }
-
- public String getScriptContribution(FacesContext context, UIComponent component) {
- return scriptContribution != null ? component.getAttributes().get("test") + scriptContribution : null;
- }
-
- public String[] getScriptDependencies() {
- return scriptDependencies;
- }
-
- public String[] getStyleDependencies() {
- return styleDependencies;
- }
-
- public ScriptOptions buildOptions(FacesContext context, UIComponent component) {
- return options;
- }
-
- public UIComponent getComponent() {
- return component;
- }
-
- public FacesContext getContext() {
- return context;
- }
-
- public CompositeRenderer getRenderer() {
- return renderer;
- }
-
- public void reset() {
- this.component = null;
- this.context = null;
- this.renderer = null;
- }
-}
Deleted: branches/RF-7560/core/impl/src/test/java/org/richfaces/renderkit/TemplateEncoderRendererBaseTest.java
===================================================================
--- branches/RF-7560/core/impl/src/test/java/org/richfaces/renderkit/TemplateEncoderRendererBaseTest.java 2010-08-31 16:59:42 UTC (rev 19051)
+++ branches/RF-7560/core/impl/src/test/java/org/richfaces/renderkit/TemplateEncoderRendererBaseTest.java 2010-08-31 17:20:11 UTC (rev 19052)
@@ -1,110 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces - Ajax4jsf Component Library
- *
- * 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;
-
-import java.io.StringWriter;
-
-import javax.faces.component.UIComponent;
-import javax.faces.component.UIOutput;
-import javax.faces.component.html.HtmlPanelGroup;
-import javax.faces.context.ResponseWriter;
-
-import org.jboss.test.faces.AbstractFacesTest;
-
-/**
- * Created 26.10.2007
- * @author Nick Belaevski - mailto:nbelaevski@exadel.com
- * @since 3.2
- */
-public class TemplateEncoderRendererBaseTest extends AbstractFacesTest {
- @Override
- public void setUp() throws Exception {
- super.setUp();
- setupFacesRequest();
- }
-
- @Override
- public void tearDown() throws Exception {
- super.tearDown();
- }
-
- public void testEncodeNonRendered() throws Exception {
- ResponseWriter responseWriter = facesContext.getRenderKit().createResponseWriter(new StringWriter(),
- "text/html", "UTF-8");
-
- facesContext.setResponseWriter(responseWriter);
-
- TemplateEncoderRendererBase rendererBase = new TemplateEncoderRendererBase() {
- @Override
- protected Class<? extends UIComponent> getComponentClass() {
- return UIOutput.class;
- }
- };
- UIOutput output = new UIOutput();
- UIOutput c = new UIOutput();
-
- c.setRendered(false);
- c.setValue("");
- output.getChildren().add(c);
-
- // that should not fail
- rendererBase.writeScriptBody(facesContext, c, true);
- }
-
- public void testEncode() throws Exception {
- StringWriter controlWriter = new StringWriter();
- ResponseWriter responseWriter = facesContext.getRenderKit().createResponseWriter(controlWriter, "text/html",
- "UTF-8");
-
- facesContext.setResponseWriter(responseWriter);
-
- TemplateEncoderRendererBase rendererBase = new TemplateEncoderRendererBase() {
- @Override
- protected Class<? extends UIComponent> getComponentClass() {
- return UIOutput.class;
- }
- };
- HtmlPanelGroup c = new HtmlPanelGroup();
-
- for (int i = 0; i < 3; i++) {
- HtmlPanelGroup c1 = new HtmlPanelGroup();
-
- c1.setId("panel" + i);
-
- UIOutput text = new UIOutput();
-
- text.setValue("some text");
- c1.getChildren().add(text);
-
- UIOutput text2 = new UIOutput();
-
- text2.setValue("some text");
- c.getChildren().add(text2);
- c.getChildren().add(c1);
- }
-
- rendererBase.writeScriptBody(facesContext, c, false);
- System.out.println(controlWriter.toString());
- }
-}
Deleted: branches/RF-7560/core/impl/src/test/java/org/richfaces/renderkit/TemplateUtilTest.java
===================================================================
--- branches/RF-7560/core/impl/src/test/java/org/richfaces/renderkit/TemplateUtilTest.java 2010-08-31 16:59:42 UTC (rev 19051)
+++ branches/RF-7560/core/impl/src/test/java/org/richfaces/renderkit/TemplateUtilTest.java 2010-08-31 17:20:11 UTC (rev 19052)
@@ -1,46 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces - Ajax4jsf Component Library
- *
- * 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;
-
-import java.io.StringReader;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import org.richfaces.javacc.RichMacroDefinition;
-
-/**
- * @author Nick Belaevski - mailto:nbelaevski@exadel.com
- * created 17.06.2007
- *
- */
-public class TemplateUtilTest extends TestCase {
- public void testAntlr() throws Exception {
- List result = new RichMacroDefinition(new StringReader("{aa{b\\}}a}\\\\ a\\}b\\{c")).expression();
- Expression holder = (Expression) result.get(0);
-
- assertEquals("aa{b}}a", holder.getExpression());
- assertEquals("\\ a}b{c", result.get(1));
- }
-}
Copied: branches/RF-7560/ui/common/api/src/main/java/org/richfaces/component/SequenceIterationStatus.java (from rev 19038, branches/RF-7560/core/impl/src/main/java/org/richfaces/component/SequenceIterationStatus.java)
===================================================================
--- branches/RF-7560/ui/common/api/src/main/java/org/richfaces/component/SequenceIterationStatus.java (rev 0)
+++ branches/RF-7560/ui/common/api/src/main/java/org/richfaces/component/SequenceIterationStatus.java 2010-08-31 17:20:11 UTC (rev 19052)
@@ -0,0 +1,128 @@
+/*
+ * 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.component;
+
+import java.io.Serializable;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public final class SequenceIterationStatus implements Serializable {
+
+ private static final long serialVersionUID = 1968212566967489719L;
+
+ private Integer begin;
+
+ private Integer count;
+
+ private Integer end;
+
+ private int index;
+
+ private Integer rowCount;
+
+ private boolean first;
+
+ private boolean last;
+
+ private boolean even;
+
+ public SequenceIterationStatus(Integer begin, Integer end, int index, Integer rowCount) {
+ int iBegin = (begin != null ? begin.intValue() : 0);
+
+ int iRowCountEnd = (rowCount != null ? rowCount.intValue() - 1 : Integer.MAX_VALUE);
+ int iEnd = (end != null ? end.intValue() : iRowCountEnd);
+ int iLastIdx = Math.min(iEnd, iRowCountEnd);
+
+ this.begin = begin;
+ this.end = iEnd;
+ this.index = index;
+ this.rowCount = rowCount;
+
+ this.first = (index == iBegin);
+
+ this.last = (index >= iLastIdx);
+
+ this.count = (index - iBegin) + 1;
+ this.even = ((count % 2) == 0);
+ }
+
+ public Integer getBegin() {
+ return begin;
+ }
+
+ public int getCount() {
+ return count;
+ }
+
+ public Object getCurrent() {
+ return null;
+ }
+
+ public Integer getEnd() {
+ return end;
+ }
+
+ public int getIndex() {
+ return index;
+ }
+
+ public Integer getStep() {
+ return 1;
+ }
+
+ public boolean isFirst() {
+ return first;
+ }
+
+ public boolean isLast() {
+ return last;
+ }
+
+ public Integer getRowCount() {
+ return rowCount;
+ }
+
+ public boolean isEven() {
+ return even;
+ }
+
+ public boolean isOdd() {
+ return !isEven();
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("begin= " + begin);
+ sb.append(", end= " + end);
+ sb.append(", index= " + index);
+ sb.append(", count= " + count);
+ sb.append(", first= " + first);
+ sb.append(", last= " + last);
+ sb.append(", even= " + even);
+ sb.append(", rowCount= " + rowCount);
+
+ return sb.toString();
+ }
+}
Copied: branches/RF-7560/ui/common/api/src/main/java/org/richfaces/renderkit/util/EnclosingFormRequiredException.java (from rev 19038, branches/RF-7560/core/impl/src/main/java/org/richfaces/component/EnclosingFormRequiredException.java)
===================================================================
--- branches/RF-7560/ui/common/api/src/main/java/org/richfaces/renderkit/util/EnclosingFormRequiredException.java (rev 0)
+++ branches/RF-7560/ui/common/api/src/main/java/org/richfaces/renderkit/util/EnclosingFormRequiredException.java 2010-08-31 17:20:11 UTC (rev 19052)
@@ -0,0 +1,52 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * 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 javax.faces.FacesException;
+
+/**
+ * @author Filip Antonov - mailto:fantonov@exadel.com
+ * created 08.02.2007
+ */
+public class EnclosingFormRequiredException extends FacesException {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1877777524838776600L;
+
+ public EnclosingFormRequiredException() {
+ super();
+ }
+
+ public EnclosingFormRequiredException(String message) {
+ super(message);
+ }
+
+ public EnclosingFormRequiredException(Throwable cause) {
+ super(cause);
+ }
+
+ public EnclosingFormRequiredException(String message, Throwable cause) {
+ super(message, cause);
+ }
+}
Copied: branches/RF-7560/ui/common/api/src/test/java/org/richfaces/component/SequenceIterationStatusTest.java (from rev 19038, branches/RF-7560/core/impl/src/test/java/org/richfaces/component/SequenceIterationStatusTest.java)
===================================================================
--- branches/RF-7560/ui/common/api/src/test/java/org/richfaces/component/SequenceIterationStatusTest.java (rev 0)
+++ branches/RF-7560/ui/common/api/src/test/java/org/richfaces/component/SequenceIterationStatusTest.java 2010-08-31 17:20:11 UTC (rev 19052)
@@ -0,0 +1,158 @@
+/*
+ * 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.component;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class SequenceIterationStatusTest {
+
+ @Test
+ public void testBeginEnd() throws Exception {
+ SequenceIterationStatus s1 = new SequenceIterationStatus(5, 10, 5, 100);
+ assertEquals(Integer.valueOf(5), s1.getBegin());
+ assertEquals(Integer.valueOf(10), s1.getEnd());
+
+ SequenceIterationStatus s2 = new SequenceIterationStatus(null, null, 5, 100);
+ assertNull(s2.getBegin());
+ assertEquals(Integer.valueOf(99), s2.getEnd());
+
+ SequenceIterationStatus s3 = new SequenceIterationStatus(null, null, 5, null);
+ assertNull(s3.getBegin());
+ assertEquals(Integer.valueOf(Integer.MAX_VALUE), s3.getEnd());
+ }
+
+ @Test
+ public void testFirst() throws Exception {
+ SequenceIterationStatus s1 = new SequenceIterationStatus(0, 10, 0, 100);
+ assertTrue(s1.isFirst());
+ assertFalse(s1.isLast());
+
+ SequenceIterationStatus s2 = new SequenceIterationStatus(0, 10, 1, 100);
+ assertFalse(s2.isFirst());
+ assertFalse(s2.isLast());
+
+ SequenceIterationStatus s3 = new SequenceIterationStatus(0, 0, 0, 100);
+ assertTrue(s3.isFirst());
+ assertTrue(s3.isLast());
+
+ SequenceIterationStatus s4 = new SequenceIterationStatus(5, 10, 5, 100);
+ assertTrue(s4.isFirst());
+ assertFalse(s4.isLast());
+
+ SequenceIterationStatus s5 = new SequenceIterationStatus(5, 10, 6, 100);
+ assertFalse(s5.isFirst());
+ assertFalse(s5.isLast());
+
+ SequenceIterationStatus s6 = new SequenceIterationStatus(null, 10, 0, 100);
+ assertTrue(s6.isFirst());
+ assertFalse(s6.isLast());
+ }
+
+ @Test
+ public void testLast() throws Exception {
+ SequenceIterationStatus s1 = new SequenceIterationStatus(0, 9, 9, 100);
+ assertTrue(s1.isLast());
+ assertFalse(s1.isFirst());
+
+ SequenceIterationStatus s2 = new SequenceIterationStatus(0, 9, 8, 100);
+ assertFalse(s2.isLast());
+ assertFalse(s2.isFirst());
+
+ SequenceIterationStatus s3 = new SequenceIterationStatus(0, 100, 9, 10);
+ assertTrue(s3.isLast());
+ assertFalse(s3.isFirst());
+
+ SequenceIterationStatus s4 = new SequenceIterationStatus(0, 100, 8, 10);
+ assertFalse(s4.isLast());
+ assertFalse(s4.isFirst());
+
+ SequenceIterationStatus s5 = new SequenceIterationStatus(0, null, 9, 10);
+ assertTrue(s5.isLast());
+ assertFalse(s5.isFirst());
+
+ SequenceIterationStatus s6 = new SequenceIterationStatus(0, null, 8, 10);
+ assertFalse(s6.isLast());
+ assertFalse(s6.isFirst());
+ }
+
+ @Test
+ public void testIsEvenOdd() throws Exception {
+ SequenceIterationStatus s1 = new SequenceIterationStatus(0, 100, 0, 10);
+ assertTrue(s1.isOdd());
+ assertFalse(s1.isEven());
+
+ SequenceIterationStatus s2 = new SequenceIterationStatus(0, 100, 1, 10);
+ assertTrue(s2.isEven());
+ assertFalse(s2.isOdd());
+
+ SequenceIterationStatus s3 = new SequenceIterationStatus(5, 100, 7, 10);
+ assertTrue(s3.isOdd());
+ assertFalse(s3.isEven());
+
+ SequenceIterationStatus s4 = new SequenceIterationStatus(5, 100, 6, 10);
+ assertTrue(s4.isEven());
+ assertFalse(s4.isOdd());
+ }
+
+ @Test
+ public void testGetRowCount() throws Exception {
+ SequenceIterationStatus s1 = new SequenceIterationStatus(0, 100, 0, 200);
+ assertEquals(Integer.valueOf(200), s1.getRowCount());
+
+ SequenceIterationStatus s2 = new SequenceIterationStatus(0, 400, 100, 150);
+ assertEquals(Integer.valueOf(150), s2.getRowCount());
+ }
+
+ @Test
+ public void testGetIndex() throws Exception {
+ SequenceIterationStatus s1 = new SequenceIterationStatus(0, 100, 30, 200);
+ assertTrue(30 == s1.getIndex());
+
+ SequenceIterationStatus s2 = new SequenceIterationStatus(0, 400, 100, 150);
+ assertTrue(100 == s2.getIndex());
+ }
+
+ @Test
+ public void testGetCount() throws Exception {
+ SequenceIterationStatus s1 = new SequenceIterationStatus(0, 100, 0, 10);
+ assertTrue(s1.getCount() == 1);
+
+ SequenceIterationStatus s2 = new SequenceIterationStatus(0, 100, 1, 10);
+ assertTrue(s2.getCount() == 2);
+
+ SequenceIterationStatus s3 = new SequenceIterationStatus(5, 100, 7, 10);
+ assertTrue(s3.getCount() == 3);
+
+ SequenceIterationStatus s4 = new SequenceIterationStatus(5, 100, 8, 10);
+ assertTrue(s4.getCount() == 4);
+ }
+}
Copied: branches/RF-7560/ui/common/ui/src/main/java/org/richfaces/component/RowKeyContextEventWrapper.java (from rev 19038, branches/RF-7560/core/impl/src/main/java/org/richfaces/component/RowKeyContextEventWrapper.java)
===================================================================
--- branches/RF-7560/ui/common/ui/src/main/java/org/richfaces/component/RowKeyContextEventWrapper.java (rev 0)
+++ branches/RF-7560/ui/common/ui/src/main/java/org/richfaces/component/RowKeyContextEventWrapper.java 2010-08-31 17:20:11 UTC (rev 19052)
@@ -0,0 +1,74 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, 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.component;
+
+import javax.faces.component.UIComponent;
+import javax.faces.event.FacesEvent;
+import javax.faces.event.FacesListener;
+import javax.faces.event.PhaseId;
+
+/**
+ * @author Nick Belaevski
+ */
+class RowKeyContextEventWrapper extends FacesEvent {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -869970815228914529L;
+ private FacesEvent event;
+ private Object rowKey;
+
+ public RowKeyContextEventWrapper(UIComponent component, FacesEvent event, Object rowKey) {
+ super(component);
+ this.event = event;
+ this.rowKey = rowKey;
+ }
+
+ public FacesEvent getFacesEvent() {
+ return this.event;
+ }
+
+ public PhaseId getPhaseId() {
+ return this.event.getPhaseId();
+ }
+
+ public void setPhaseId(PhaseId phaseId) {
+ this.event.setPhaseId(phaseId);
+ }
+
+ public boolean isAppropriateListener(FacesListener listener) {
+ return false;
+ }
+
+ public void processListener(FacesListener listener) {
+ throw new IllegalStateException();
+ }
+
+ /**
+ * @return the rowKey
+ */
+ public Object getRowKey() {
+ return rowKey;
+ }
+}
Copied: branches/RF-7560/ui/common/ui/src/main/java/org/richfaces/component/SavedState.java (from rev 19038, branches/RF-7560/core/impl/src/main/java/org/richfaces/component/SavedState.java)
===================================================================
--- branches/RF-7560/ui/common/ui/src/main/java/org/richfaces/component/SavedState.java (rev 0)
+++ branches/RF-7560/ui/common/ui/src/main/java/org/richfaces/component/SavedState.java 2010-08-31 17:20:11 UTC (rev 19052)
@@ -0,0 +1,141 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, 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.component;
+
+import java.io.Serializable;
+
+import javax.faces.component.EditableValueHolder;
+import javax.faces.component.UIForm;
+
+import org.ajax4jsf.component.IterationStateHolder;
+
+//from RI
+
+/**
+ * This class keep values of {@link EditableValueHolder} row-sensitive
+ * fields.
+ *
+ * @author shura
+ */
+final class SavedState implements Serializable {
+
+ public static final SavedState EMPTY = new SavedState();
+
+ private static final long serialVersionUID = -1563864456074187422L;
+
+ private boolean valid = true;
+ private boolean localValueSet;
+ private boolean submitted;
+ private Object submittedValue;
+ private Object value;
+
+ private Object iterationState;
+
+ public SavedState() {
+ super();
+ }
+
+ public SavedState(EditableValueHolder evh) {
+ super();
+ this.value = evh.getLocalValue();
+ this.valid = evh.isValid();
+ this.submittedValue = evh.getSubmittedValue();
+ this.localValueSet = evh.isLocalValueSet();
+ }
+
+ public SavedState(IterationStateHolder ish) {
+ super();
+
+ this.iterationState = ish.getIterationState();
+ }
+
+ public SavedState(UIForm form) {
+ super();
+ this.submitted = form.isSubmitted();
+ }
+
+ Object getSubmittedValue() {
+ return this.submittedValue;
+ }
+
+ void setSubmittedValue(Object submittedValue) {
+ this.submittedValue = submittedValue;
+ }
+
+ boolean isValid() {
+ return this.valid;
+ }
+
+ void setValid(boolean valid) {
+ this.valid = valid;
+ }
+
+ Object getValue() {
+ return this.value;
+ }
+
+ void setValue(Object value) {
+ this.value = value;
+ }
+
+ boolean isLocalValueSet() {
+ return this.localValueSet;
+ }
+
+ void setLocalValueSet(boolean localValueSet) {
+ this.localValueSet = localValueSet;
+ }
+
+ Object getIterationState() {
+ return iterationState;
+ }
+
+ void setIterationState(Object iterationState) {
+ this.iterationState = iterationState;
+ }
+
+ @Override
+ public String toString() {
+ if (iterationState != null) {
+ return "iterationState: " + iterationState;
+ } else {
+ return "submittedValue: " + submittedValue + " value: " + value + " localValueSet: " + localValueSet
+ + " submitted: " + submitted;
+ }
+ }
+
+ public void apply(EditableValueHolder evh) {
+ evh.setValue(this.value);
+ evh.setValid(this.valid);
+ evh.setSubmittedValue(this.submittedValue);
+ evh.setLocalValueSet(this.localValueSet);
+ }
+
+ public void apply(IterationStateHolder ish) {
+ ish.setIterationState(iterationState);
+ }
+
+ public void apply(UIForm form) {
+ form.setSubmitted(this.submitted);
+ }
+}
Copied: branches/RF-7560/ui/common/ui/src/main/java/org/richfaces/component/UIDataAdaptor.java (from rev 19038, branches/RF-7560/core/impl/src/main/java/org/richfaces/component/UIDataAdaptor.java)
===================================================================
--- branches/RF-7560/ui/common/ui/src/main/java/org/richfaces/component/UIDataAdaptor.java (rev 0)
+++ branches/RF-7560/ui/common/ui/src/main/java/org/richfaces/component/UIDataAdaptor.java 2010-08-31 17:20:11 UTC (rev 19052)
@@ -0,0 +1,1516 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, 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.component;
+
+import java.io.IOException;
+import java.io.Serializable;
+import java.text.MessageFormat;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import javax.el.ValueExpression;
+import javax.faces.FacesException;
+import javax.faces.application.Application;
+import javax.faces.application.FacesMessage;
+import javax.faces.component.ContextCallback;
+import javax.faces.component.EditableValueHolder;
+import javax.faces.component.NamingContainer;
+import javax.faces.component.PartialStateHolder;
+import javax.faces.component.StateHelper;
+import javax.faces.component.StateHolder;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIComponentBase;
+import javax.faces.component.UIForm;
+import javax.faces.component.UINamingContainer;
+import javax.faces.component.UIViewRoot;
+import javax.faces.component.UniqueIdVendor;
+import javax.faces.component.visit.VisitCallback;
+import javax.faces.component.visit.VisitContext;
+import javax.faces.component.visit.VisitResult;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+import javax.faces.convert.ConverterException;
+import javax.faces.event.AbortProcessingException;
+import javax.faces.event.ComponentSystemEvent;
+import javax.faces.event.ComponentSystemEventListener;
+import javax.faces.event.FacesEvent;
+import javax.faces.event.ListenerFor;
+import javax.faces.event.PhaseId;
+import javax.faces.event.PostValidateEvent;
+import javax.faces.event.PreRenderComponentEvent;
+import javax.faces.event.PreValidateEvent;
+import javax.faces.render.Renderer;
+
+import org.ajax4jsf.component.IterationStateHolder;
+import org.ajax4jsf.model.DataComponentState;
+import org.ajax4jsf.model.DataVisitResult;
+import org.ajax4jsf.model.DataVisitor;
+import org.ajax4jsf.model.ExtendedDataModel;
+import org.ajax4jsf.model.Range;
+import org.ajax4jsf.model.SerializableDataModel;
+import org.richfaces.context.ExtendedVisitContext;
+import org.richfaces.log.Logger;
+import org.richfaces.log.RichfacesLogger;
+
+/**
+ * Base class for iterable components, like dataTable, Tomahawk dataList, Facelets repeat, tree etc., with support for
+ * partial rendering on AJAX responces for one or more selected iterations.
+ *
+ * @author shura
+ */
+@ListenerFor(systemEventClass = PreRenderComponentEvent.class)
+public abstract class UIDataAdaptor extends UIComponentBase implements NamingContainer,
+ UniqueIdVendor, IterationStateHolder, ComponentSystemEventListener {
+
+ /**
+ * <p>The standard component family for this component.</p>
+ */
+ public static final String COMPONENT_FAMILY = "org.richfaces.Data";
+
+ /**
+ * <p>The standard component type for this component.</p>
+ */
+ public static final String COMPONENT_TYPE = "org.richfaces.Data";
+
+ private static final class IterationState implements Serializable {
+
+ private static final long serialVersionUID = -3502645160277416066L;
+
+ private DataComponentState componentState;
+
+ private Object savedComponentState;
+
+ private boolean componentStateIsStateHolder;
+
+ private ExtendedDataModel<?> dataModel;
+
+ public IterationState() {
+ super();
+ }
+
+ public IterationState(DataComponentState componentState, ExtendedDataModel<?> dataModel) {
+ super();
+ this.componentState = componentState;
+ this.dataModel = dataModel;
+ }
+
+ public ExtendedDataModel<?> getDataModel() {
+ return dataModel;
+ }
+
+ public DataComponentState getComponentState() {
+ return componentState;
+ }
+
+ /**
+ * @param uiDataAdaptor
+ */
+ public void restoreComponentState(UIDataAdaptor uiDataAdaptor) {
+ if (savedComponentState != null && componentStateIsStateHolder) {
+ componentState = uiDataAdaptor.createComponentState();
+ ((StateHolder) componentState).restoreState(FacesContext.getCurrentInstance(), savedComponentState);
+ savedComponentState = null;
+ }
+ }
+
+ final Object saveState() {
+ boolean localComponentStateIsHolder = false;
+ Object localSavedComponentState = null;
+
+ if (componentState != null) {
+ if (componentState instanceof StateHolder) {
+ localComponentStateIsHolder = true;
+
+ StateHolder stateHolder = (StateHolder) componentState;
+ if (!stateHolder.isTransient()) {
+ localSavedComponentState = stateHolder.saveState(FacesContext.getCurrentInstance());
+ }
+ } else {
+ if (componentState instanceof Serializable) {
+ localSavedComponentState = componentState;
+ }
+ }
+ }
+
+ Object savedSerializableModel = null;
+
+ if (componentState != null && dataModel != null) {
+ // TODO handle model serialization - "execute" model
+ savedSerializableModel = dataModel.getSerializableModel(componentState.getRange());
+ }
+
+ if (localSavedComponentState != null || savedSerializableModel != null) {
+ return new Object[] {
+ localComponentStateIsHolder,
+ localSavedComponentState,
+ savedSerializableModel
+ };
+ } else {
+ return null;
+ }
+ }
+
+ final void restoreState(Object stateObject) {
+ if (stateObject != null) {
+ Object[] state = (Object[]) stateObject;
+ componentStateIsStateHolder = Boolean.TRUE.equals(state[0]);
+ Object localSavedComponentState = state[1];
+
+ if (componentStateIsStateHolder) {
+ savedComponentState = localSavedComponentState;
+ } else {
+ componentState = (DataComponentState) localSavedComponentState;
+ }
+
+ dataModel = (ExtendedDataModel<?>) state[2];
+ }
+ }
+
+ private void writeObject(java.io.ObjectOutputStream out)
+ throws IOException {
+
+ out.writeObject(saveState());
+ }
+
+ private void readObject(java.io.ObjectInputStream in)
+ throws IOException, ClassNotFoundException {
+
+ restoreState(in.readObject());
+ }
+ }
+
+ private static final VisitCallback STUB_CALLBACK = new VisitCallback() {
+
+ public VisitResult visit(VisitContext context, UIComponent target) {
+ return VisitResult.ACCEPT;
+ }
+ };
+
+ private static final Logger LOG = RichfacesLogger.COMPONENTS.getLogger();
+
+ /**
+ * Visitor for process decode on children components.
+ */
+ protected ComponentVisitor decodeVisitor = new ComponentVisitor() {
+ @Override
+ public void processComponent(FacesContext context, UIComponent c, Object argument) {
+ c.processDecodes(context);
+ }
+ };
+
+ /**
+ * Visitor for process validation phase
+ */
+ protected ComponentVisitor validateVisitor = new ComponentVisitor() {
+ @Override
+ public void processComponent(FacesContext context, UIComponent c, Object argument) {
+ c.processValidators(context);
+ }
+ };
+
+ /**
+ * Visitor for process update model phase.
+ */
+ protected ComponentVisitor updateVisitor = new ComponentVisitor() {
+ @Override
+ public void processComponent(FacesContext context, UIComponent c, Object argument) {
+ c.processUpdates(context);
+ }
+ };
+
+ //TODO nick - PSH support?
+ private DataComponentState componentState = null;
+ private ExtendedDataModel<?> extendedDataModel = null;
+ private Object rowKey = null;
+
+ private String clientId;
+
+ private Object originalVarValue;
+
+ private Converter rowKeyConverter;
+
+ /**
+ * @author Nick Belaevski
+ *
+ */
+ private final class DataVisitorForVisitTree implements DataVisitor {
+ /**
+ *
+ */
+ private final VisitCallback callback;
+ /**
+ *
+ */
+ private final VisitContext visitContext;
+ /**
+ *
+ */
+ private boolean visitResult;
+
+ /**
+ * @param callback
+ * @param visitContext
+ */
+ private DataVisitorForVisitTree(VisitCallback callback, VisitContext visitContext) {
+ this.callback = callback;
+ this.visitContext = visitContext;
+ }
+
+ public DataVisitResult process(FacesContext context, Object rowKey, Object argument) {
+ setRowKey(context, rowKey);
+
+ if (isRowAvailable()) {
+ VisitResult result = VisitResult.ACCEPT;
+
+ if (visitContext instanceof ExtendedVisitContext) {
+ result = visitContext.invokeVisitCallback(UIDataAdaptor.this, callback);
+ if (VisitResult.COMPLETE.equals(result)) {
+ visitResult = true;
+
+ return DataVisitResult.STOP;
+ }
+ }
+
+ if (VisitResult.ACCEPT.equals(result)) {
+ Iterator<UIComponent> dataChildrenItr = dataChildren();
+
+ while (dataChildrenItr.hasNext()) {
+ UIComponent dataChild = dataChildrenItr.next();
+
+ if (dataChild.visitTree(visitContext, callback)) {
+ visitResult = true;
+
+ return DataVisitResult.STOP;
+ }
+ }
+ }
+ }
+
+ return DataVisitResult.CONTINUE;
+ }
+
+ public boolean getVisitResult() {
+ return visitResult;
+ }
+ }
+
+ private enum PropertyKeys {
+ lastId, var, rowKeyVar, stateVar, childState, rowKeyConverter, rowKeyConverterSet, keepSaved
+ }
+
+ public UIDataAdaptor() {
+ super();
+ }
+
+ protected Map<String, Object> getVariablesMap(FacesContext facesContext) {
+ return facesContext.getExternalContext().getRequestMap();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see javax.faces.component.UIComponent#getFamily()
+ */
+ @Override
+ public String getFamily() {
+ return COMPONENT_FAMILY;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.component.AjaxChildrenEncoder#encodeAjaxChild(javax.faces.context.FacesContext,
+ * java.lang.String, java.util.Set, java.util.Set)
+ */
+ public void encodeAjaxChild(FacesContext context, String path, Set<String> ids, Set<String> renderedAreas)
+ throws IOException {
+
+ // TODO Auto-generated method stub
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see javax.faces.component.UniqueIdVendor#createUniqueId(javax.faces.context.FacesContext, java.lang.String)
+ */
+ public String createUniqueId(FacesContext context, String seed) {
+ Integer i = (Integer) getStateHelper().get(PropertyKeys.lastId);
+ int lastId = (i != null) ? i : 0;
+
+ getStateHelper().put(PropertyKeys.lastId, ++lastId);
+
+ return UIViewRoot.UNIQUE_ID_PREFIX + ((seed == null) ? lastId : seed);
+ }
+
+ /**
+ * @return the rowKey
+ */
+ public Object getRowKey() {
+ return rowKey;
+ }
+
+ /**
+ * Setup current row by key. Perform same functionality as
+ * {@link javax.faces.component.UIData#setRowIndex(int)}, but for key object - it may be not only
+ * row number in sequence data, but, for example - path to current node in
+ * tree.
+ *
+ * @param faces -
+ * current FacesContext
+ * @param key new key value.
+ */
+ public void setRowKey(FacesContext facesContext, Object rowKey) {
+ this.saveChildState(facesContext);
+ this.rowKey = rowKey;
+ this.clientId = null;
+ getExtendedDataModel().setRowKey(rowKey);
+
+ boolean rowSelected = (rowKey != null) && isRowAvailable();
+
+ setupVariable(facesContext, rowSelected);
+ this.restoreChildState(facesContext);
+ }
+
+ /**
+ * Save values of {@link EditableValueHolder} fields before change current
+ * row.
+ *
+ * @param faces
+ */
+ protected void saveChildState(FacesContext facesContext) {
+ Iterator<UIComponent> itr = dataChildren();
+
+ while (itr.hasNext()) {
+ this.saveChildState(facesContext, (UIComponent) itr.next());
+ }
+ }
+
+ /**
+ * @param facesContext
+ * @param next
+ * @param childState
+ */
+ protected void saveChildState(FacesContext facesContext, UIComponent component) {
+
+ // TODO - is it right?
+ if (component.isTransient()) {
+ return;
+ }
+
+ SavedState state = null;
+
+ if (component instanceof IterationStateHolder) {
+ IterationStateHolder ish = (IterationStateHolder) component;
+
+ state = new SavedState(ish);
+ } else if (component instanceof EditableValueHolder) {
+ EditableValueHolder evh = (EditableValueHolder) component;
+
+ state = new SavedState(evh);
+ } else if (component instanceof UIForm) {
+ UIForm form = (UIForm) component;
+
+ state = new SavedState(form);
+ }
+
+ if (state != null) {
+
+ // TODO - use local map - children save their state themselves using visitors
+ getStateHelper().put(PropertyKeys.childState, component.getClientId(facesContext), state);
+ }
+
+ if (component.getChildCount() > 0) {
+ for (UIComponent child : component.getChildren()) {
+ saveChildState(facesContext, child);
+ }
+ }
+
+ if (component.getFacetCount() > 0) {
+ for (UIComponent facet : component.getFacets().values()) {
+ saveChildState(facesContext, facet);
+ }
+ }
+ }
+
+ protected Iterator<UIComponent> dataChildren() {
+ if (getChildCount() > 0) {
+ return getChildren().iterator();
+ } else {
+ return Collections.<UIComponent>emptyList().iterator();
+ }
+ }
+
+ protected Iterator<UIComponent> fixedChildren() {
+ if (getFacetCount() > 0) {
+ return getFacets().values().iterator();
+ } else {
+ return Collections.<UIComponent>emptyList().iterator();
+ }
+ }
+
+ /**
+ * @param facesContext
+ */
+ protected void restoreChildState(FacesContext facesContext) {
+ Iterator<UIComponent> itr = dataChildren();
+
+ while (itr.hasNext()) {
+ this.restoreChildState(facesContext, (UIComponent) itr.next());
+ }
+ }
+
+ /**
+ * Restore values of {@link EditableValueHolder} fields after change current
+ * row.
+ *
+ * @param facesContext
+ * @param next
+ * @param childState
+ */
+ protected void restoreChildState(FacesContext facesContext, UIComponent component) {
+ String id = component.getId();
+
+ component.setId(id); // Forces client id to be reset
+
+ SavedState savedState = null;
+ @SuppressWarnings("unchecked")
+ Map<String, SavedState> savedStatesMap = (Map<String, SavedState>) getStateHelper()
+ .get(PropertyKeys.childState);
+
+ if (savedStatesMap != null) {
+ savedState = savedStatesMap.get(component.getClientId(facesContext));
+ }
+
+ if (savedState == null) {
+ savedState = SavedState.EMPTY;
+ }
+
+ if (component instanceof IterationStateHolder) {
+ IterationStateHolder ish = (IterationStateHolder) component;
+
+ savedState.apply(ish);
+ } else if (component instanceof EditableValueHolder) {
+ EditableValueHolder evh = (EditableValueHolder) component;
+
+ savedState.apply(evh);
+ } else if (component instanceof UIForm) {
+ UIForm form = (UIForm) component;
+
+ savedState.apply(form);
+ }
+
+ if (component.getChildCount() > 0) {
+ for (UIComponent child : component.getChildren()) {
+ restoreChildState(facesContext, child);
+ }
+ }
+
+ if (component.getFacetCount() > 0) {
+ for (UIComponent facet : component.getFacets().values()) {
+ restoreChildState(facesContext, facet);
+ }
+ }
+ }
+
+ public void setRowKey(Object rowKey) {
+ setRowKey(getFacesContext(), rowKey);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see javax.faces.component.UIComponentBase#queueEvent(javax.faces.event.FacesEvent)
+ */
+ @Override
+ public void queueEvent(FacesEvent event) {
+ super.queueEvent(new RowKeyContextEventWrapper(this, event, getRowKey()));
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see javax.faces.component.UIComponentBase#broadcast(javax.faces.event.FacesEvent)
+ */
+ @Override
+ public void broadcast(FacesEvent event) throws AbortProcessingException {
+ if (!(event instanceof RowKeyContextEventWrapper)) {
+ if (!broadcastLocal(event)) {
+ super.broadcast(event);
+ }
+
+ return;
+ }
+
+ FacesContext context = getFacesContext();
+
+ // Set up the correct context and fire our wrapped event
+ RowKeyContextEventWrapper revent = (RowKeyContextEventWrapper) event;
+ Object oldRowKey = getRowKey();
+
+ setRowKey(context, revent.getRowKey());
+
+ FacesEvent rowEvent = revent.getFacesEvent();
+ UIComponent source = rowEvent.getComponent();
+ UIComponent compositeParent = null;
+
+ try {
+ if (!UIComponent.isCompositeComponent(source)) {
+ compositeParent = UIComponent.getCompositeComponentParent(source);
+ }
+
+ if (compositeParent != null) {
+ compositeParent.pushComponentToEL(context, null);
+ }
+
+ source.pushComponentToEL(context, null);
+ source.broadcast(rowEvent);
+ } finally {
+ source.popComponentFromEL(context);
+
+ if (compositeParent != null) {
+ compositeParent.popComponentFromEL(context);
+ }
+ }
+
+ setRowKey(context, oldRowKey);
+ }
+
+ /**
+ * Process events targetted for concrete implementation. Hook method called
+ * from {@link #broadcast(FacesEvent)}
+ *
+ * @param event -
+ * processed event.
+ * @return true if event processed, false if component must continue
+ * processing.
+ */
+
+ // TODO - is it still actual?
+ protected boolean broadcastLocal(FacesEvent event) {
+ return false;
+ }
+
+ /**
+ * @return the extendedDataModel
+ */
+ protected ExtendedDataModel<?> getExtendedDataModel() {
+ if (extendedDataModel == null) {
+ extendedDataModel = createExtendedDataModel();
+ }
+
+ return extendedDataModel;
+ }
+
+ /**
+ * @return
+ */
+ protected abstract ExtendedDataModel<?> createExtendedDataModel();
+
+ /**
+ * @param extendedDataModel the extendedDataModel to set
+ */
+ protected void setExtendedDataModel(ExtendedDataModel<?> extendedDataModel) {
+ this.extendedDataModel = extendedDataModel;
+ }
+
+ public String getVar() {
+ return (String) getStateHelper().get(PropertyKeys.var);
+ }
+
+ public void setVar(String var) {
+ getStateHelper().put(PropertyKeys.var, var);
+ }
+
+ public String getRowKeyVar() {
+ return (String) getStateHelper().get(PropertyKeys.rowKeyVar);
+ }
+
+ public void setRowKeyVar(String rowKeyVar) {
+ getStateHelper().put(PropertyKeys.rowKeyVar, rowKeyVar);
+ }
+
+ public String getStateVar() {
+ return (String) getStateHelper().get(PropertyKeys.stateVar);
+ }
+
+ public void setStateVar(String stateVar) {
+ getStateHelper().put(PropertyKeys.stateVar, stateVar);
+ }
+
+ //XXX - review and probably remove - useful method, should be left
+ public int getRowCount() {
+ return getExtendedDataModel().getRowCount();
+ }
+
+ public Object getRowData() {
+ return getExtendedDataModel().getRowData();
+ }
+
+ public boolean isRowAvailable() {
+ return getExtendedDataModel().isRowAvailable();
+ }
+
+ /**
+ * Boolean attribute that defines whether this iteration component will reset saved children's state
+ * before rendering. By default state is reset if there are no faces messages with severity error or higher.
+ * @return
+ */
+ public boolean isKeepSaved() {
+ Object value = getStateHelper().eval(PropertyKeys.keepSaved);
+
+ if (value == null) {
+ return keepSaved(getFacesContext());
+ } else {
+ return Boolean.valueOf(value.toString());
+ }
+ }
+
+ public void setKeepSaved(boolean keepSaved) {
+ getStateHelper().put(PropertyKeys.keepSaved, keepSaved);
+ }
+
+ /**
+ * Setup EL variable for different iteration. Value of row data and
+ * component state will be put into request scope attributes with names
+ * given by "var" and "varState" bean properties.
+ * <p/>
+ * Changed: does not check for row availability now
+ *
+ * @param faces current faces context
+ * @param localModel
+ * @param rowSelected
+ */
+ protected void setupVariable(FacesContext faces, boolean rowSelected) {
+ Map<String, Object> attrs = getVariablesMap(faces);
+
+ if (rowSelected) {
+
+ // Current row data.
+ setupVariable(getVar(), attrs, getRowData());
+
+ // Component state variable.
+ setupVariable(getStateVar(), attrs, getComponentState());
+
+ // Row key Data variable.
+ setupVariable(getRowKeyVar(), attrs, getRowKey());
+ } else {
+ removeVariable(getVar(), attrs);
+ removeVariable(getStateVar(), attrs);
+ removeVariable(getRowKeyVar(), attrs);
+ }
+ }
+
+ /**
+ * @return
+ */
+ public DataComponentState getComponentState() {
+ if (componentState != null) {
+ return componentState;
+ }
+
+ ValueExpression componentStateExpression = getValueExpression("componentState");
+
+ if (componentStateExpression != null) {
+ componentState = (DataComponentState) componentStateExpression.getValue(getFacesContext().getELContext());
+ }
+
+ if (componentState == null) {
+ componentState = createComponentState();
+
+ if ((componentStateExpression != null)
+ && !componentStateExpression.isReadOnly(getFacesContext().getELContext())) {
+ componentStateExpression.setValue(getFacesContext().getELContext(), componentState);
+ }
+ }
+
+ return componentState;
+ }
+
+ protected abstract DataComponentState createComponentState();
+
+ /**
+ * @param var
+ * @param attrs
+ * @param rowData
+ */
+ private void setupVariable(String var, Map<String, Object> attrs, Object rowData) {
+ if (var != null) {
+ attrs.put(var, rowData);
+ }
+ }
+
+ /**
+ * @param var
+ * @param attrs
+ * @param rowData
+ */
+ private void removeVariable(String var, Map<String, Object> attrs) {
+ if (var != null) {
+ attrs.remove(var);
+ }
+ }
+
+ public Converter getRowKeyConverter() {
+ if (this.rowKeyConverter != null) {
+ return this.rowKeyConverter;
+ }
+
+ return (Converter) getStateHelper().eval(PropertyKeys.rowKeyConverter);
+ }
+
+ public void setRowKeyConverter(Converter converter) {
+ StateHelper stateHelper = getStateHelper();
+ if (initialStateMarked()) {
+ stateHelper.put(PropertyKeys.rowKeyConverterSet, Boolean.TRUE);
+ }
+
+ this.rowKeyConverter = converter;
+ }
+
+ private boolean isSetRowKeyConverter() {
+ Boolean value = (Boolean) getStateHelper().get(PropertyKeys.rowKeyConverterSet);
+ return Boolean.TRUE.equals(value);
+ }
+
+ @Override
+ public String getClientId(FacesContext facesContext) {
+ if (facesContext == null) {
+ throw new NullPointerException("context");
+ }
+
+ if (null == clientId) {
+ StringBuilder id = new StringBuilder(super.getClientId(facesContext));
+ Object rowKey = getRowKey();
+
+ if (rowKey != null) {
+
+ // Use converter to get String representation ot the row key.
+ Converter rowKeyConverter = getRowKeyConverter();
+
+ if (null == rowKeyConverter) {
+
+ // Create default converter for a row key.
+ rowKeyConverter = facesContext.getApplication().createConverter(rowKey.getClass());
+
+ // Store converter for a invokeOnComponents call.
+ if (null != rowKeyConverter) {
+ // TODO - review
+ setRowKeyConverter(rowKeyConverter);
+ }
+ }
+
+ String rowKeyString;
+
+ if (null != rowKeyConverter) {
+
+ // Temporary set clientId, to avoid infinite calls from converter.
+ clientId = id.toString();
+ rowKeyString = rowKeyConverter.getAsString(facesContext, this, rowKey);
+ } else {
+ rowKeyString = rowKey.toString();
+ }
+
+ id.append(UINamingContainer.getSeparatorChar(facesContext)).append(rowKeyString);
+ }
+
+ Renderer renderer = getRenderer(facesContext);
+
+ if (null != renderer) {
+ clientId = renderer.convertClientId(facesContext, id.toString());
+ } else {
+ clientId = id.toString();
+ }
+ }
+
+ return clientId;
+ }
+
+ /**
+ * Save current state of data variable.
+ *
+ * @param faces current faces context
+ */
+
+ // TODO move into walk() method body
+ public void captureOrigValue(FacesContext faces) {
+ String var = getVar();
+
+ if (var != null) {
+ Map<String, Object> attrs = getVariablesMap(faces);
+
+ this.originalVarValue = attrs.get(var);
+ }
+
+ // TODO add support for another variables
+ }
+
+ /**
+ * Restore value of data variable after processing phase.
+ *
+ * @param faces current faces context
+ */
+ public void restoreOrigValue(FacesContext faces) {
+ String var = getVar();
+
+ if (var != null) {
+ Map<String, Object> attrs = getVariablesMap(faces);
+
+ if (this.originalVarValue != null) {
+ attrs.put(var, this.originalVarValue);
+ } else {
+ attrs.remove(var);
+ }
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see javax.faces.component.UIComponent#setValueExpression(java.lang.String, javax.el.ValueExpression)
+ */
+ @Override
+ public void setValueExpression(String name, ValueExpression binding) {
+ if ("var".equals(name) || "rowKeyVar".equals(name) || "stateVar".equals(name)) {
+ throw new IllegalArgumentException(MessageFormat.format("{0} cannot be EL-expression", name));
+ }
+
+ super.setValueExpression(name, binding);
+ }
+
+ /**
+ * Check for validation errors on children components. If true, saved values
+ * must be keep on render phase
+ *
+ * @param context
+ * @return
+ */
+ protected boolean keepSaved(FacesContext context) {
+
+ // For an any validation errors, children components state should be preserved
+ FacesMessage.Severity sev = context.getMaximumSeverity();
+
+ return (sev != null) && (FacesMessage.SEVERITY_ERROR.compareTo(sev) >= 0);
+ }
+
+ /**
+ * Perform iteration on all children components and all data rows with given
+ * visitor.
+ *
+ * @param faces
+ * @param visitor
+ */
+ protected void iterate(FacesContext faces, ComponentVisitor visitor) {
+
+ // stop if not rendered
+ if (!this.isRendered()) {
+ return;
+ }
+
+ // reset rowIndex
+ this.captureOrigValue(faces);
+ this.setRowKey(faces, null);
+
+ try {
+ Iterator<UIComponent> fixedChildren = fixedChildren();
+
+ while (fixedChildren.hasNext()) {
+ UIComponent component = fixedChildren.next();
+
+ visitor.processComponent(faces, component, null);
+ }
+
+ walk(faces, visitor, null);
+ } catch (Exception e) {
+ throw new FacesException(e);
+ } finally {
+ this.setRowKey(faces, null);
+ this.restoreOrigValue(faces);
+ }
+ }
+
+ /**
+ * Walk ( visit ) this component on all data-aware children for each row.
+ *
+ * @param faces
+ * @param visitor
+ */
+ public void walk(FacesContext faces, DataVisitor visitor, Object argument) {
+ Object key = getRowKey();
+ captureOrigValue(faces);
+
+ Range range = null;
+ DataComponentState componentState = getComponentState();
+
+ if (componentState != null) {
+ range = componentState.getRange();
+ }
+
+ getExtendedDataModel().walk(faces, visitor, range, argument);
+
+ setRowKey(faces, key);
+ restoreOrigValue(faces);
+ }
+
+ public void processDecodes(FacesContext faces) {
+ if (!this.isRendered()) {
+ return;
+ }
+
+ pushComponentToEL(faces, this);
+ preDecode(faces);
+ this.iterate(faces, decodeVisitor);
+ this.decode(faces);
+ popComponentFromEL(faces);
+ }
+
+ public void processValidators(FacesContext faces) {
+ if (!this.isRendered()) {
+ return;
+ }
+
+ pushComponentToEL(faces, this);
+ Application app = faces.getApplication();
+ app.publishEvent(faces, PreValidateEvent.class, this);
+ preValidate(faces);
+ this.iterate(faces, validateVisitor);
+ app.publishEvent(faces, PostValidateEvent.class, this);
+ popComponentFromEL(faces);
+ }
+
+ public void processUpdates(FacesContext faces) {
+ if (!this.isRendered()) {
+ return;
+ }
+
+ pushComponentToEL(faces, this);
+ preUpdate(faces);
+ this.iterate(faces, updateVisitor);
+
+ ExtendedDataModel<?> dataModel = getExtendedDataModel();
+
+ // If no validation errors, update values for serializable model,
+ // restored from view.
+ if ((dataModel instanceof SerializableDataModel) && (!isKeepSaved())) {
+ SerializableDataModel serializableModel = (SerializableDataModel) dataModel;
+
+ serializableModel.update();
+ }
+
+ popComponentFromEL(faces);
+ }
+
+ @Override
+ public void setId(String id) {
+ super.setId(id);
+ this.clientId = null;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.ajax4jsf.component.IterationStateHolder#getIterationState()
+ */
+ public Object getIterationState() {
+ assert rowKey == null;
+
+ return new IterationState(this.componentState, this.extendedDataModel);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.component.IterationStateHolder#setIterationState(java.lang.Object)
+ */
+ public void setIterationState(Object stateObject) {
+ assert rowKey == null;
+
+ // TODO - ?
+ // restoreChildState(getFacesContext());
+ if (stateObject != null) {
+ IterationState iterationState = (IterationState) stateObject;
+ iterationState.restoreComponentState(this);
+
+ this.componentState = iterationState.getComponentState();
+ this.extendedDataModel = iterationState.getDataModel();
+ } else {
+ this.componentState = null;
+ this.extendedDataModel = null;
+ }
+ }
+
+ protected void resetDataModel() {
+ this.extendedDataModel = null;
+ }
+
+ protected void resetChildState() {
+ getStateHelper().remove(PropertyKeys.childState);
+ }
+
+ protected void preDecode(FacesContext context) {
+ resetDataModel();
+
+ Object savedChildState = getStateHelper().get(PropertyKeys.childState);
+ // TODO - verify the check for null: savedChildState == null
+ if (savedChildState == null || !isKeepSaved()) {
+ resetChildState();
+ }
+ }
+
+ // TODO - do we need this method?
+ protected void preValidate(FacesContext context) {
+ }
+
+ // TODO - do we need this method?
+ protected void preUpdate(FacesContext context) {
+ }
+
+ protected void preEncodeBegin(FacesContext context) {
+ resetDataModel();
+
+ if (!isKeepSaved()) {
+ //TODO - this also resets state for the nested iteration components - is it correct?
+ resetChildState();
+ }
+ }
+
+ @Override
+ public void markInitialState() {
+ super.markInitialState();
+
+ if (rowKeyConverter instanceof PartialStateHolder) {
+ ((PartialStateHolder) rowKeyConverter).markInitialState();
+ }
+ }
+
+ @Override
+ public void clearInitialState() {
+ super.clearInitialState();
+
+ if (rowKeyConverter instanceof PartialStateHolder) {
+ ((PartialStateHolder) rowKeyConverter).clearInitialState();
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see javax.faces.component.UIComponentBase#saveState(javax.faces.context.FacesContext)
+ */
+ @Override
+ public Object saveState(FacesContext context) {
+ Object parentState = super.saveState(context);
+ Object savedComponentState = new IterationState(componentState, extendedDataModel).saveState();
+
+ Object converterState = null;
+ boolean nullDelta = true;
+
+ boolean converterHasPartialState = false;
+
+ if (initialStateMarked()) {
+ if (!isSetRowKeyConverter() && rowKeyConverter != null && rowKeyConverter instanceof PartialStateHolder) {
+ // Delta
+ StateHolder holder = (StateHolder) rowKeyConverter;
+ if (!holder.isTransient()) {
+ Object attachedState = holder.saveState(context);
+ if (attachedState != null) {
+ nullDelta = false;
+ converterState = attachedState;
+ }
+ converterHasPartialState = true;
+ } else {
+ converterState = null;
+ }
+ } else if (isSetRowKeyConverter() || rowKeyConverter != null) {
+ // Full
+ converterState = saveAttachedState(context, rowKeyConverter);
+ nullDelta = false;
+ }
+
+ if (parentState == null && savedComponentState == null && nullDelta) {
+ // No values
+ return null;
+ }
+ } else {
+ converterState = saveAttachedState(context, rowKeyConverter);
+ }
+
+ return new Object[] {
+ parentState,
+ savedComponentState,
+ converterHasPartialState,
+ converterState
+ };
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.component.UIComponentBase#restoreState(javax.faces.context.FacesContext, java.lang.Object)
+ */
+ @Override
+ public void restoreState(FacesContext context, Object stateObject) {
+ if (stateObject == null) {
+ return ;
+ }
+
+ Object[] state = (Object[]) stateObject;
+
+ super.restoreState(context, state[0]);
+
+ if (state[1] != null) {
+ IterationState iterationState = new IterationState();
+ iterationState.restoreState(state[1]);
+ iterationState.restoreComponentState(this);
+
+ // TODO update state model binding
+ componentState = iterationState.getComponentState();
+ extendedDataModel = iterationState.getDataModel();
+ }
+
+ boolean converterHasPartialState = Boolean.TRUE.equals(state[2]);
+ Object savedConverterState = state[3];
+ if (converterHasPartialState) {
+ ((StateHolder) rowKeyConverter).restoreState(context, savedConverterState);
+ } else {
+ rowKeyConverter = (Converter) UIComponentBase.restoreAttachedState(context, savedConverterState);
+ }
+ }
+
+ private boolean matchesBaseId(String clientId, String baseId, char separatorChar) {
+ if (clientId.equals(baseId)) {
+ return true;
+ }
+
+ // if clientId.startsWith(baseId + separatorChar)
+ if (clientId.startsWith(baseId) && (clientId.length() > baseId.length())
+ && (clientId.charAt(baseId.length()) == separatorChar)) {
+ return true;
+ }
+
+ return false;
+ }
+
+ @Override
+ public boolean invokeOnComponent(FacesContext context, String clientId, ContextCallback callback)
+ throws FacesException {
+
+ if ((null == context) || (null == clientId) || (null == callback)) {
+ throw new NullPointerException();
+ }
+
+ String baseId = super.getClientId(context);
+
+ if (!matchesBaseId(clientId, baseId, UINamingContainer.getSeparatorChar(context))) {
+ return false;
+ }
+
+ boolean found = false;
+ Object oldRowKey = getRowKey();
+
+ // TODO - this does not seem right
+ captureOrigValue(context);
+
+ try {
+
+ // TODO - ?
+ // if (null != oldRowKey) {
+ setRowKey(context, null);
+
+ // }
+ if (clientId.equals(baseId)) {
+ callback.invokeContextCallback(context, this);
+ found = true;
+ } else {
+ Iterator<UIComponent> fixedChildrenItr = fixedChildren();
+
+ while (fixedChildrenItr.hasNext() && !found) {
+ UIComponent fixedChild = fixedChildrenItr.next();
+
+ found = fixedChild.invokeOnComponent(context, clientId, callback);
+ }
+ }
+
+ if (!found) {
+ Object newRowKey = null;
+
+ // Call for a child component - try to detect row key
+ // baseId.length() + 1 expression skips SEPARATOR_CHAR
+ //TODO - convertKeyString
+ String rowKeyString = extractKeySegment(context, clientId.substring(baseId.length() + 1));
+
+ if (rowKeyString != null) {
+ Converter keyConverter = getRowKeyConverter();
+
+ if (null != keyConverter) {
+ try {
+ //TODO: review
+ newRowKey = keyConverter.getAsObject(context, this, rowKeyString);
+ } catch (ConverterException e) {
+
+ // TODO: LOG error
+ }
+ }
+ }
+
+ setRowKey(context, newRowKey);
+
+ if (isRowAvailable()) {
+ Iterator<UIComponent> dataChildrenItr = dataChildren();
+
+ while (dataChildrenItr.hasNext() && !found) {
+ UIComponent dataChild = dataChildrenItr.next();
+
+ found = dataChild.invokeOnComponent(context, clientId, callback);
+ }
+ }
+ }
+ } catch (Exception e) {
+ throw new FacesException(e);
+ } finally {
+
+ // if (null != oldRowKey) {
+ try {
+ setRowKey(context, oldRowKey);
+ restoreOrigValue(context);
+ } catch (Exception e) {
+ LOG.error(e.getMessage(), e);
+ }
+
+ // }
+ }
+
+ return found;
+ }
+
+ // Tests whether we need to visit our children as part of
+ // a tree visit
+ private boolean doVisitChildren(VisitContext context, boolean visitRows) {
+
+ // Just need to check whether there are any ids under this
+ // subtree. Make sure row index is cleared out since
+ // getSubtreeIdsToVisit() needs our row-less client id.
+
+ // TODO check this
+ if (visitRows) {
+ setRowKey(context.getFacesContext(), null);
+ }
+
+ // TODO optimize for returned IDs
+ Collection<String> idsToVisit = context.getSubtreeIdsToVisit(this);
+
+ assert idsToVisit != null;
+
+ if (idsToVisit == VisitContext.ALL_IDS) {
+ // TODO
+ }
+
+ // All ids or non-empty collection means we need to visit our children.
+ return !idsToVisit.isEmpty();
+ }
+
+ private boolean visitComponents(Iterator<UIComponent> components, VisitContext context, VisitCallback callback) {
+
+ while (components.hasNext()) {
+ UIComponent nextChild = components.next();
+
+ if (nextChild.visitTree(context, callback)) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ protected boolean visitFixedChildren(VisitContext visitContext, VisitCallback callback) {
+
+ return visitComponents(fixedChildren(), visitContext, callback);
+ }
+
+ protected boolean visitDataChildren(VisitContext visitContext, VisitCallback callback, boolean visitRows) {
+
+ if (visitRows) {
+ FacesContext facesContext = visitContext.getFacesContext();
+
+ DataVisitorForVisitTree dataVisitor = new DataVisitorForVisitTree(callback, visitContext);
+ this.walk(facesContext, dataVisitor, null);
+
+ return dataVisitor.getVisitResult();
+ } else {
+ return visitComponents(dataChildren(), visitContext, callback);
+ }
+ }
+
+ @Override
+ public boolean visitTree(VisitContext visitContext, VisitCallback callback) {
+
+ // First check to see whether we are visitable. If not
+ // short-circuit out of this subtree, though allow the
+ // visit to proceed through to other subtrees.
+ if (!isVisitable(visitContext)) {
+ return false;
+ }
+
+ // Clear out the row index is one is set so that
+ // we start from a clean slate.
+ FacesContext facesContext = visitContext.getFacesContext();
+
+ // NOTE: that the visitRows local will be obsolete once the
+ // appropriate visit hints have been added to the API
+ boolean visitRows = requiresRowIteration(facesContext);
+
+ Object oldRowKey = null;
+ if (visitRows) {
+ captureOrigValue(facesContext);
+ oldRowKey = getRowKey();
+ setRowKey(facesContext, null);
+ }
+
+ // Push ourselves to EL
+ pushComponentToEL(facesContext, null);
+
+ try {
+
+ // Visit ourselves. Note that we delegate to the
+ // VisitContext to actually perform the visit.
+ VisitResult result = visitContext.invokeVisitCallback(this, callback);
+
+ // If the visit is complete, short-circuit out and end the visit
+ if (result == VisitResult.COMPLETE) {
+ return true;
+ }
+
+ // Visit children, short-circuiting as necessary
+ if ((result == VisitResult.ACCEPT) && doVisitChildren(visitContext, visitRows)) {
+ if (visitRows) {
+ setRowKey(facesContext, null);
+ }
+
+ if (visitFixedChildren(visitContext, callback)) {
+ return true;
+ }
+
+ if (visitContext instanceof ExtendedVisitContext) {
+ ExtendedVisitContext extendedVisitContext = (ExtendedVisitContext) visitContext;
+
+ Collection<String> directSubtreeIdsToVisit = extendedVisitContext.getDirectSubtreeIdsToVisit(this);
+ if (directSubtreeIdsToVisit != VisitContext.ALL_IDS) {
+ if (directSubtreeIdsToVisit.isEmpty()) {
+ return false;
+ } else {
+ VisitContext directChildrenVisitContext =
+ extendedVisitContext.createNamingContainerVisitContext(this, directSubtreeIdsToVisit);
+
+ if (visitRows) {
+ setRowKey(facesContext, null);
+ }
+ if (visitFixedChildren(directChildrenVisitContext, STUB_CALLBACK)) {
+ return false;
+ }
+ }
+ }
+ }
+
+ if (visitDataChildren(visitContext, callback, visitRows)) {
+ return true;
+ }
+ }
+ } finally {
+
+ // Clean up - pop EL and restore old row index
+ popComponentFromEL(facesContext);
+
+ if (visitRows) {
+ try {
+ setRowKey(facesContext, oldRowKey);
+ restoreOrigValue(facesContext);
+ } catch (Exception e) {
+
+ // TODO: handle exception
+ LOG.error(e.getMessage(), e);
+ }
+ }
+ }
+
+ // Return false to allow the visit to continue
+ return false;
+ }
+
+ /**
+ * @param facesContext
+ * @return
+ */
+ private boolean requiresRowIteration(FacesContext context) {
+ return (!PhaseId.RESTORE_VIEW.equals(context.getCurrentPhaseId()));
+ }
+
+ /**
+ * @param context
+ * @param substring
+ * @return
+ */
+ // TODO review!
+ protected String extractKeySegment(FacesContext context, String substring) {
+ char separatorChar = UINamingContainer.getSeparatorChar(context);
+ int separatorIndex = substring.indexOf(separatorChar);
+
+ if (separatorIndex < 0) {
+ return substring;
+ } else {
+ return substring.substring(0, separatorIndex);
+ }
+ }
+
+ /**
+ * Base class for visit data model at phases decode, validation and update model
+ *
+ * @author shura
+ */
+ protected abstract class ComponentVisitor implements DataVisitor {
+ public DataVisitResult process(FacesContext context, Object rowKey, Object argument) {
+ setRowKey(context, rowKey);
+
+ if (isRowAvailable()) {
+ Iterator<UIComponent> childIterator = dataChildren();
+
+ while (childIterator.hasNext()) {
+ UIComponent component = childIterator.next();
+
+ processComponent(context, component, argument);
+ }
+ }
+
+ return DataVisitResult.CONTINUE;
+ }
+
+ public abstract void processComponent(FacesContext context, UIComponent c, Object argument);
+ }
+
+ @Override
+ public void processEvent(ComponentSystemEvent event) throws AbortProcessingException {
+ super.processEvent(event);
+
+ if (event instanceof PreRenderComponentEvent) {
+ preEncodeBegin(getFacesContext());
+ }
+ }
+
+ protected DataComponentState getLocalComponentState() {
+ return componentState;
+ }
+}
Copied: branches/RF-7560/ui/common/ui/src/main/java/org/richfaces/component/UISequence.java (from rev 19038, branches/RF-7560/core/impl/src/main/java/org/richfaces/component/UISequence.java)
===================================================================
--- branches/RF-7560/ui/common/ui/src/main/java/org/richfaces/component/UISequence.java (rev 0)
+++ branches/RF-7560/ui/common/ui/src/main/java/org/richfaces/component/UISequence.java 2010-08-31 17:20:11 UTC (rev 19052)
@@ -0,0 +1,305 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, 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.component;
+
+import java.sql.ResultSet;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+import javax.el.ValueExpression;
+import javax.faces.component.UINamingContainer;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+import javax.faces.model.ArrayDataModel;
+import javax.faces.model.DataModel;
+import javax.faces.model.ListDataModel;
+import javax.faces.model.ResultDataModel;
+import javax.faces.model.ResultSetDataModel;
+import javax.faces.model.ScalarDataModel;
+import javax.servlet.jsp.jstl.sql.Result;
+
+import org.ajax4jsf.model.DataComponentState;
+import org.ajax4jsf.model.ExtendedDataModel;
+import org.ajax4jsf.model.Range;
+import org.ajax4jsf.model.SequenceDataModel;
+import org.ajax4jsf.model.SequenceRange;
+import org.ajax4jsf.model.SequenceState;
+
+/**
+ * @author Nick Belaevski
+ */
+public class UISequence extends UIDataAdaptor {
+
+ private Object iterationStatusVarObject;
+
+ protected enum PropertyKeys {
+ first, rows, value, iterationStatusVar
+ }
+
+ protected void updateState(SequenceState state) {
+ state.setFirst(getActualFirst());
+ state.setRows(getActualRows());
+ }
+
+ protected void updateState() {
+ DataComponentState localState = getLocalComponentState();
+ if (localState instanceof SequenceState) {
+ updateState((SequenceState) localState);
+ }
+ }
+
+ protected int getActualFirst() {
+ return getFirst();
+ }
+
+ protected int getActualRows() {
+ return getRows();
+ }
+
+ @SuppressWarnings("unchecked")
+ protected DataModel<?> createFacesModel(Object value) {
+ DataModel<?> model = null;
+
+ if (value == null) {
+ model = new ListDataModel(Collections.EMPTY_LIST);
+ } else if (value instanceof DataModel) {
+ model = (DataModel) value;
+ } else if (value instanceof List) {
+ model = new ListDataModel((List) value);
+ } else if (Object[].class.isAssignableFrom(value.getClass())) {
+ model = new ArrayDataModel((Object[]) value);
+ } else if (value instanceof ResultSet) {
+ model = new ResultSetDataModel((ResultSet) value);
+ } else if (value instanceof Result) {
+ model = new ResultDataModel((Result) value);
+ } else {
+ model = new ScalarDataModel(value);
+ }
+
+ return model;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ protected ExtendedDataModel<?> createExtendedDataModel() {
+ ExtendedDataModel<?> model = null;
+
+ // Synthesize a DataModel around our current value if possible
+ Object value = getValue();
+
+ if (value instanceof ExtendedDataModel<?>) {
+ model = (ExtendedDataModel<?>) value;
+ } else {
+ model = new SequenceDataModel(createFacesModel(value));
+ }
+
+ return model;
+ }
+
+ @Override
+ protected DataComponentState createComponentState() {
+ SequenceState state = new SequenceState();
+
+ updateState(state);
+
+ return state;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.richfaces.component.UIDataAdaptor#getRowKeyConverter()
+ */
+
+ // TODO make this a property of model
+
+ @Override
+ public Converter getRowKeyConverter() {
+ return getFacesContext().getApplication().createConverter(Integer.class);
+ }
+
+ public int getFirst() {
+ return (Integer) getStateHelper().eval(PropertyKeys.first, 0);
+ }
+
+ public void setFirst(int first) {
+ getStateHelper().put(PropertyKeys.first, first);
+ updateState();
+ }
+
+ public int getRows() {
+ return (Integer) getStateHelper().eval(PropertyKeys.rows, 0);
+ }
+
+ public void setRows(int rows) {
+ getStateHelper().put(PropertyKeys.rows, rows);
+ updateState();
+ }
+
+ public Object getValue() {
+ return getStateHelper().eval(PropertyKeys.value);
+ }
+
+ public void setValue(Object value) {
+ resetDataModel();
+ getStateHelper().put(PropertyKeys.value, value);
+ }
+
+ public String getIterationStatusVar() {
+ return (String) getStateHelper().get(PropertyKeys.iterationStatusVar);
+ }
+
+ public void setIterationStatusVar(String iterationStatusVar) {
+ getStateHelper().put(PropertyKeys.iterationStatusVar, iterationStatusVar);
+ }
+
+ public int getRowIndex() {
+ return getExtendedDataModel().getRowIndex();
+ }
+
+ @Override
+ public void captureOrigValue(FacesContext faces) {
+ super.captureOrigValue(faces);
+
+ String iterationStatusVar = getIterationStatusVar();
+ if (iterationStatusVar != null) {
+ Map<String, Object> variablesMap = getVariablesMap(faces);
+
+ iterationStatusVarObject = variablesMap.get(iterationStatusVar);
+ }
+ }
+
+ @Override
+ public void restoreOrigValue(FacesContext faces) {
+ super.restoreOrigValue(faces);
+
+ String iterationStatusVar = getIterationStatusVar();
+ if (iterationStatusVar != null) {
+ Map<String, Object> variablesMap = getVariablesMap(faces);
+
+ if (iterationStatusVarObject != null) {
+ variablesMap.put(iterationStatusVar, iterationStatusVarObject);
+ } else {
+ variablesMap.remove(iterationStatusVar);
+ }
+ }
+ }
+
+ @Override
+ protected void setupVariable(FacesContext faces, boolean rowSelected) {
+ super.setupVariable(faces, rowSelected);
+
+ //TODO nick - should iterationStatus be available out of iteration?
+ // if yes, better name than "iterationStatusVar" is required
+ String iterationStatusVar = getIterationStatusVar();
+ if (iterationStatusVar != null) {
+ Map<String, Object> requestMap = getVariablesMap(faces);
+
+ if (rowSelected) {
+ Integer begin = null;
+ Integer end = null;
+
+ Range range = getComponentState().getRange();
+ if (range instanceof SequenceRange) {
+ SequenceRange sequenceRange = (SequenceRange) range;
+
+ begin = sequenceRange.getFirstRow();
+ int iRows = sequenceRange.getRows();
+
+ if (iRows > 0) {
+ // end is zero-based
+ end = begin + iRows - 1;
+ }
+ }
+
+ SequenceIterationStatus iterationStatus = new SequenceIterationStatus(begin, end,
+ getRowIndex(), getRowCount());
+
+ requestMap.put(iterationStatusVar, iterationStatus);
+ } else {
+ requestMap.remove(iterationStatusVar);
+ }
+ }
+ }
+
+ @SuppressWarnings("deprecation")
+ @Override
+ public void setValueBinding(String name, javax.faces.el.ValueBinding binding) {
+ if ("value".equals(name)) {
+ resetDataModel();
+ } else if ("first".equals(name) || "rows".equals(name)) {
+ updateState();
+ }
+
+ super.setValueBinding(name, binding);
+ }
+
+ @Override
+ public void setValueExpression(String name, ValueExpression binding) {
+ if ("value".equals(name)) {
+ resetDataModel();
+ } else if ("first".equals(name) || "rows".equals(name)) {
+ updateState();
+ }
+
+ super.setValueExpression(name, binding);
+ }
+
+ @Override
+ protected void preEncodeBegin(FacesContext context) {
+ super.preEncodeBegin(context);
+
+ updateState();
+ }
+
+ public int getRelativeRowIndex() {
+ int rowIndex = getRowIndex();
+ int rows = getRows();
+
+ if (rows > 1) {
+ return rowIndex % rows;
+ }
+
+ return rowIndex;
+ }
+
+ public String getRelativeClientId(FacesContext facesContext) {
+
+ //save current rowKey
+ Object savedRowKey = getRowKey();
+
+ setRowKey(null);
+
+ //retrieve base client id without rowkey part
+ StringBuilder baseId = new StringBuilder(getClientId(facesContext));
+
+ //restore rowKey
+ setRowKey(savedRowKey);
+
+ String result = baseId.append(UINamingContainer.getSeparatorChar(facesContext)).append(getRelativeRowIndex())
+ .toString();
+
+ return result;
+ }
+}
Copied: branches/RF-7560/ui/common/ui/src/main/java/org/richfaces/renderkit/AjaxChildrenRenderer.java (from rev 19038, branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/renderkit/AjaxChildrenRenderer.java)
===================================================================
--- branches/RF-7560/ui/common/ui/src/main/java/org/richfaces/renderkit/AjaxChildrenRenderer.java (rev 0)
+++ branches/RF-7560/ui/common/ui/src/main/java/org/richfaces/renderkit/AjaxChildrenRenderer.java 2010-08-31 17:20:11 UTC (rev 19052)
@@ -0,0 +1,222 @@
+/**
+ * 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;
+
+import java.io.IOException;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import javax.faces.component.NamingContainer;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.Messages;
+import org.ajax4jsf.component.AjaxChildrenEncoder;
+import org.ajax4jsf.component.AjaxOutput;
+import org.ajax4jsf.context.AjaxContext;
+import org.ajax4jsf.renderkit.AjaxRenderer;
+import org.richfaces.log.Logger;
+import org.richfaces.log.RichfacesLogger;
+
+/**
+ * @author shura
+ */
+public abstract class AjaxChildrenRenderer extends AjaxComponentRendererBase implements AjaxRenderer {
+ public static final String[] SPECIAL_COMPONENTS_TYPES = {"org.ajax4jsf.Bundle" /* UILoadBundle.COMPONENT_TYPE */,
+ "org.apache.myfaces.AliasBean", "org.apache.myfaces.AliasBeansScope"};
+
+ private static final String SPECIAL_TYPES_PARAMETER = "org.ajax4jsf.CONTROL_COMPONENTS";
+ private static final Logger LOG = RichfacesLogger.RENDERKIT.getLogger();
+
+ private Set<String> specialComponentTypes = null;
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.ajax4jsf.renderkit.AjaxRenderer#encodeAjaxChildren(javax.faces.context
+ * .FacesContext, javax.faces.component.UIComponent, java.lang.String,
+ * java.util.Set, java.util.Set)
+ */
+ public void encodeAjaxChildren(FacesContext context, UIComponent component, String path, Set<String> ids,
+ Set<String> renderedAreas) throws IOException {
+
+ if (LOG.isDebugEnabled()) {
+ LOG.debug(Messages.getMessage(Messages.ENCODE_CHILD_AJAX_INFO, path, component.getId()));
+ }
+
+ String currentPath = path;
+
+ if (component instanceof NamingContainer) {
+ currentPath += component.getId() + NamingContainer.SEPARATOR_CHAR;
+
+ // Do not check children if we have no id to render under naming
+ // container.
+ if (AjaxContext.getCurrentInstance(context).isLimitToList() && noIdUnderPath(path, ids)) {
+ return;
+ }
+ }
+
+ for (Iterator<UIComponent> it = component.getFacetsAndChildren(); it.hasNext();) {
+ UIComponent element = (UIComponent) it.next();
+
+ encodeAjaxComponent(context, element, currentPath, ids, renderedAreas);
+ }
+ }
+
+ private boolean noIdUnderPath(String path, Set<String> ids) {
+
+ // Do we have an any component for the rendering under that container ?
+ boolean noSuchId = true;
+
+ for (String id : ids) {
+ if ((null != id) && id.startsWith(path)) {
+ noSuchId = false;
+
+ break;
+ }
+ }
+
+ return noSuchId;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.ajax4jsf.renderkit.AjaxRenderer#encodeAjaxComponent(javax.faces.context
+ * .FacesContext, javax.faces.component.UIComponent, java.lang.String,
+ * java.util.Set, java.util.Set)
+ */
+ public void encodeAjaxComponent(FacesContext context, UIComponent component, String currentPath, Set<String> ids,
+ Set<String> renderedAreas) throws IOException {
+
+ if (component.isRendered()) { // skip not-rendered components.
+ boolean found = false;
+ boolean limitToList = AjaxContext.getCurrentInstance(context).isLimitToList();
+ String elementId = component.getId();
+ String absoluteId = currentPath + elementId;
+
+ if (!ids.isEmpty()) {
+
+ // list for rendering may contains absolute id ( best ),
+ // component Id or client ID
+ // String clientId = element.getClientId(context);
+ if (ids.contains(absoluteId) || ids.contains(elementId)) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug(Messages.getMessage(Messages.RENDER_AJAX_AREA_INFO, absoluteId));
+ }
+
+ // renderChild(context, element);
+ found = true;
+ }
+ }
+
+ //
+ if (!found && limitToList && (component instanceof NamingContainer)
+ && noIdUnderPath(absoluteId + NamingContainer.SEPARATOR_CHAR, ids)) {
+ return;
+ }
+
+ if (!found && !limitToList && (component instanceof AjaxOutput)) {
+ if (((AjaxOutput) component).isAjaxRendered()) {
+
+ // renderChild(context, element);
+ found = true;
+ }
+ }
+
+ if (!found) {
+ if (component instanceof AjaxChildrenEncoder) {
+ ((AjaxChildrenEncoder) component).encodeAjaxChild(context, currentPath, ids, renderedAreas);
+ } else {
+
+ // Special case - for control components, not produced
+ // html code - such as message bundles loaders,
+ // MyFaces aliases etc. we call encodeBegin/end methods
+ // even if components not in rendered areas.
+ boolean special = isSpecialElement(context, component);
+
+ if (special) {
+ component.encodeBegin(context);
+ }
+
+ encodeAjaxChildren(context, component, currentPath, ids, renderedAreas);
+
+ if (special) {
+ component.encodeEnd(context);
+ }
+ }
+ } else {
+ renderedAreas.add(component.getClientId(context));
+ component.encodeAll(context);
+ }
+ }
+ }
+
+ /**
+ * Detect component as special control case - such as messages bundle
+ * loader, alias bean components etc. Type of component get by reflection
+ * from static field COMPONENT_TYPE
+ *
+ * @param context
+ * @param component
+ * @return true if encode methods must be called for this component even in
+ * not-rendered parts.
+ */
+ private boolean isSpecialElement(FacesContext context, UIComponent component) {
+ if (specialComponentTypes == null) {
+ specialComponentTypes = new HashSet<String>(10);
+
+ for (int i = 0; i < SPECIAL_COMPONENTS_TYPES.length; i++) {
+ specialComponentTypes.add(SPECIAL_COMPONENTS_TYPES[i]);
+ }
+
+ String special = context.getExternalContext().getInitParameter(SPECIAL_TYPES_PARAMETER);
+
+ if (null != special) {
+ String[] split = special.split(",");
+
+ for (int i = 0; i < split.length; i++) {
+ specialComponentTypes.add(split[i]);
+ }
+ }
+ }
+
+ boolean result;
+
+ try {
+ String componentType = (String) component.getClass().getField("COMPONENT_TYPE").get(null);
+
+ result = specialComponentTypes.contains(componentType);
+ } catch (Exception e) {
+
+ // exception occurs if component not have accesible COMPONENT_TYPE
+ // constant
+ // we assume that component not in special types.
+ result = false;
+ }
+
+ return result;
+ }
+}
Copied: branches/RF-7560/ui/common/ui/src/main/java/org/richfaces/renderkit/AjaxComponentRendererBase.java (from rev 19038, branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/renderkit/AjaxComponentRendererBase.java)
===================================================================
--- branches/RF-7560/ui/common/ui/src/main/java/org/richfaces/renderkit/AjaxComponentRendererBase.java (rev 0)
+++ branches/RF-7560/ui/common/ui/src/main/java/org/richfaces/renderkit/AjaxComponentRendererBase.java 2010-08-31 17:20:11 UTC (rev 19052)
@@ -0,0 +1,33 @@
+/**
+ * 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;
+
+
+/**
+ * Base class for all Ajax enabled components. Perform common task -
+ * output javasript for component.
+ *
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:58:49 $
+ */
+public abstract class AjaxComponentRendererBase extends RendererBase {
+}
Copied: branches/RF-7560/ui/common/ui/src/main/java/org/richfaces/renderkit/ComponentAttribute.java (from rev 19038, branches/RF-7560/core/commons/src/main/java/org/richfaces/renderkit/ComponentAttribute.java)
===================================================================
--- branches/RF-7560/ui/common/ui/src/main/java/org/richfaces/renderkit/ComponentAttribute.java (rev 0)
+++ branches/RF-7560/ui/common/ui/src/main/java/org/richfaces/renderkit/ComponentAttribute.java 2010-08-31 17:20:11 UTC (rev 19052)
@@ -0,0 +1,142 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, 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 java.util.Map;
+import java.util.TreeMap;
+
+/**
+ * @author Nick Belaevski
+ */
+public class ComponentAttribute implements Comparable<ComponentAttribute> {
+
+ public enum Kind {
+ BOOL,
+ GENERIC,
+ URI
+ }
+
+ private final String htmlAttributeName;
+
+ private String componentAttributeName;
+
+ private Object defaultValue;
+
+ private String[] eventNames = {};
+
+ private Kind kind = Kind.GENERIC;
+
+ //TODO handling for aliases: "styleClass" -> "class"
+
+ public ComponentAttribute(String htmlAttributeName) {
+ super();
+ this.htmlAttributeName = htmlAttributeName;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the defaultValue
+ */
+ public Object getDefaultValue() {
+ return this.defaultValue;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param defaultValue the defaultValue to set
+ */
+ public void setDefaultValue(Object dafaultValue) {
+ this.defaultValue = dafaultValue;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the kind
+ */
+ public Kind getKind() {
+ return this.kind;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @param kind the kind to set
+ */
+ public void setKind(Kind kind) {
+ this.kind = kind;
+ }
+
+ public static final Map<String, ComponentAttribute> createMap(ComponentAttribute... attributes) {
+ Map<String,ComponentAttribute> result = new TreeMap<String, ComponentAttribute>();
+
+ for (ComponentAttribute componentAttribute : attributes) {
+ result.put(componentAttribute.getComponentAttributeName(), componentAttribute);
+ }
+
+ return result;
+ }
+
+ /**
+ * @return the name
+ */
+ public String getHtmlAttributeName() {
+ return htmlAttributeName;
+ }
+
+ /**
+ * @return the componentAttributeName
+ */
+ public String getComponentAttributeName() {
+ return (componentAttributeName == null) ? htmlAttributeName : componentAttributeName;
+ }
+
+ /**
+ * @param componentAttributeName the componentAttributeName to set
+ * @return
+ */
+ public ComponentAttribute setComponentAttributeName(String componentAttributeName) {
+ this.componentAttributeName = componentAttributeName;
+
+ return this;
+ }
+
+ /**
+ * @return the eventNames
+ */
+ public String[] getEventNames() {
+ return eventNames;
+ }
+
+ /**
+ * @param eventNames the eventNames to set
+ * @return
+ */
+ public ComponentAttribute setEventNames(String... eventNames) {
+ this.eventNames = eventNames;
+
+ return this;
+ }
+
+ public int compareTo(ComponentAttribute o) {
+ return getHtmlAttributeName().compareTo(o.getHtmlAttributeName());
+ }
+}
Copied: branches/RF-7560/ui/common/ui/src/main/java/org/richfaces/renderkit/RenderKitUtils.java (from rev 19038, branches/RF-7560/core/commons/src/main/java/org/richfaces/renderkit/RenderKitUtils.java)
===================================================================
--- branches/RF-7560/ui/common/ui/src/main/java/org/richfaces/renderkit/RenderKitUtils.java (rev 0)
+++ branches/RF-7560/ui/common/ui/src/main/java/org/richfaces/renderkit/RenderKitUtils.java 2010-08-31 17:20:11 UTC (rev 19052)
@@ -0,0 +1,468 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, 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 java.io.IOException;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeSet;
+
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIComponentBase;
+import javax.faces.component.behavior.ClientBehavior;
+import javax.faces.component.behavior.ClientBehaviorContext;
+import javax.faces.component.behavior.ClientBehaviorHint;
+import javax.faces.component.behavior.ClientBehaviorHolder;
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+
+import org.richfaces.renderkit.ComponentAttribute.Kind;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public final class RenderKitUtils {
+
+ /**
+ *
+ */
+ static final String BEHAVIOR_SOURCE_ID = "javax.faces.source";
+
+ /**
+ *
+ */
+ static final String BEHAVIOR_EVENT_NAME = "javax.faces.behavior.event";
+
+ /**
+ *
+ */
+ private static final String XHTML_ATTRIBUTE_PREFIX = "xml:";
+
+ /**
+ *
+ */
+ private static final String XHTML_CONTENT_TYPE = "application/xhtml+xml";
+
+ // TODO - check what's in MyFaces
+ private static final String ATTRIBUTES_THAT_ARE_SET = UIComponentBase.class.getName() + ".attributesThatAreSet";
+
+ private static final String[] BOOLEAN_ATTRIBUTE_NAMES = { "checked", "compact", "declare", "defer", "disabled",
+ "ismap", "multiple", "nohref", "noshade", "nowrap", "readonly", "selected" };
+
+ private static final String[] URI_ATTRIBUTE_NAMES = { "action", "background", "cite", "classid", "codebase",
+ "data", "href", "longdesc", "profile", "src", "usemap" };
+
+ private static final String[] XHTML_ATTRIBUTE_NAMES = { "lang" };
+
+ private static final String DISABLED_ATTRIBUTE_NAME = "disabled";
+
+ private RenderKitUtils() {
+ // utility constructor
+ }
+
+ private static Map<String, List<ClientBehavior>> getClientBehaviorsMap(UIComponent component) {
+ Map<String, List<ClientBehavior>> result;
+ if (component instanceof ClientBehaviorHolder) {
+ ClientBehaviorHolder clientBehaviorHolder = (ClientBehaviorHolder) component;
+
+ result = clientBehaviorHolder.getClientBehaviors();
+ } else {
+ result = Collections.emptyMap();
+ }
+ return result;
+ }
+
+ static boolean isDisabled(UIComponent component) {
+ Object disabledAttributeValue = component.getAttributes().get(DISABLED_ATTRIBUTE_NAME);
+ if (disabledAttributeValue == null) {
+ return false;
+ }
+
+ if (disabledAttributeValue instanceof Boolean) {
+ return Boolean.TRUE.equals(disabledAttributeValue);
+ }
+
+ return Boolean.valueOf(disabledAttributeValue.toString());
+ }
+
+ static String escape(String s) {
+ StringBuilder sb = new StringBuilder(s.length());
+ int start = 0;
+ int end;
+
+ while ((end = s.indexOf('\'', start)) >= 0) {
+ sb.append(s, start, end);
+ sb.append("\\'");
+
+ start = end + 1;
+ }
+
+ sb.append(s, start, s.length());
+
+ return sb.toString();
+ }
+
+ static boolean chain(StringBuilder sb, Object object, boolean isChained) {
+ if (object != null) {
+ String objectString = object.toString().trim();
+ if (objectString.length() != 0) {
+ final boolean localIsChained;
+
+ if (!isChained && sb.length() != 0) {
+ // extract previously stored handler
+ String previousHandlerString = sb.toString();
+ // clear builder object
+ sb.setLength(0);
+
+ // append escaped handler
+ sb.append("'");
+ sb.append(escape(previousHandlerString));
+ sb.append("'");
+
+ localIsChained = true;
+ } else {
+ // use passed in value of chained indicator
+ localIsChained = isChained;
+ }
+
+ if (localIsChained) {
+ sb.append(",'");
+ sb.append(escape(objectString));
+ sb.append("'");
+
+ return true;
+ } else {
+ sb.append(objectString);
+ return false;
+ }
+ }
+ }
+
+ // no changes, pass chained indicator we initially used
+ return isChained;
+ }
+
+ private static Object createBehaviorsChain(Object inlineHandlerValue, ClientBehaviorContext behaviorContext,
+ List<ClientBehavior> behaviors) {
+
+ boolean isChained = false;
+ StringBuilder result = new StringBuilder();
+
+ isChained = chain(result, inlineHandlerValue, isChained);
+ for (ClientBehavior behavior : behaviors) {
+ isChained = chain(result, behavior.getScript(behaviorContext), isChained);
+
+ if (behavior.getHints().contains(ClientBehaviorHint.SUBMITTING)) {
+ break;
+ }
+ }
+
+ if (result.length() == 0) {
+ return null;
+ }
+
+ if (isChained) {
+ result.insert(0, "jsf.util.chain(");
+ result.append(")");
+ }
+
+ return result.toString();
+ }
+
+ public static boolean shouldRenderAttribute(Object attributeValue) {
+ if (attributeValue == null) {
+ return false;
+ } else if (attributeValue instanceof String) {
+ return ((String) attributeValue).length() > 0;
+ } else if (attributeValue instanceof Boolean && Boolean.FALSE.equals(attributeValue)) {
+ return false;
+ } else if (attributeValue instanceof Integer && (Integer) attributeValue == Integer.MIN_VALUE) {
+ return false;
+ } else if (attributeValue instanceof Double && (Double) attributeValue == Double.MIN_VALUE) {
+ return false;
+ } else if (attributeValue instanceof Character && (Character) attributeValue == Character.MIN_VALUE) {
+ return false;
+ } else if (attributeValue instanceof Float && (Float) attributeValue == Float.MIN_VALUE) {
+ return false;
+ } else if (attributeValue instanceof Short && (Short) attributeValue == Short.MIN_VALUE) {
+ return false;
+ } else if (attributeValue instanceof Byte && (Byte) attributeValue == Byte.MIN_VALUE) {
+ return false;
+ } else if (attributeValue instanceof Long && (Long) attributeValue == Long.MIN_VALUE) {
+ return false;
+ }
+
+ return attributeValue.toString().length() > 0;
+ }
+
+ public static String prefixAttributeName(String attributeName, boolean isXhtmlMode) {
+ if (isXhtmlMode) {
+ if (Arrays.binarySearch(XHTML_ATTRIBUTE_NAMES, attributeName) >= 0) {
+ return XHTML_ATTRIBUTE_PREFIX + attributeName;
+ }
+ }
+
+ return attributeName;
+ }
+
+ public static String prefixAttributeName(String attributeName, ResponseWriter responseWriter) {
+ return prefixAttributeName(attributeName, XHTML_CONTENT_TYPE.equals(responseWriter.getContentType()));
+ }
+
+ public static void renderAttribute(FacesContext facesContext, String attributeName, Object attributeValue)
+ throws IOException {
+
+ if (!shouldRenderAttribute(attributeValue)) {
+ return;
+ }
+
+ ResponseWriter writer = facesContext.getResponseWriter();
+
+ String prefixedAttributeName = prefixAttributeName(attributeName, writer);
+
+ if (Arrays.binarySearch(URI_ATTRIBUTE_NAMES, attributeName) >= 0) {
+ writer.writeURIAttribute(prefixedAttributeName, attributeValue, null);
+ } else if (Arrays.binarySearch(BOOLEAN_ATTRIBUTE_NAMES, attributeName) >= 0) {
+ boolean booleanAttributeValue = Boolean.valueOf(String.valueOf(attributeValue));
+ if (booleanAttributeValue) {
+ // TODO - is passing in Boolean.TRUE value documented somewhere?
+ writer.writeAttribute(prefixedAttributeName, Boolean.TRUE, null);
+ }
+ } else {
+ writer.writeAttribute(prefixedAttributeName, attributeValue, null);
+ }
+ }
+
+ public static Object getAttributeAndBehaviorsValue(FacesContext facesContext, UIComponent component,
+ ComponentAttribute componentAttribute) {
+ if (facesContext == null) {
+ throw new NullPointerException("facesContext");
+ }
+
+ if (component == null) {
+ throw new NullPointerException("component");
+ }
+
+ if (componentAttribute == null) {
+ throw new NullPointerException("componentAttribute");
+ }
+
+ String componentAttributeName = componentAttribute.getComponentAttributeName();
+ Object attributeValue = component.getAttributes().get(componentAttributeName);
+
+ String[] eventNames = componentAttribute.getEventNames();
+ if (eventNames.length > 0) {
+ Map<String, List<ClientBehavior>> behaviorsMap = getClientBehaviorsMap(component);
+ if (behaviorsMap.size() > 0) {
+ for (String eventName : eventNames) {
+ if (behaviorsMap.containsKey(eventName)) {
+ List<ClientBehavior> behaviorsList = behaviorsMap.get(eventName);
+ if (!behaviorsList.isEmpty()) {
+ // TODO - parameters handling
+ ClientBehaviorContext behaviorContext =
+ ClientBehaviorContext.createClientBehaviorContext(facesContext, component, eventName,
+ null, null);
+ attributeValue = createBehaviorsChain(attributeValue, behaviorContext, behaviorsList);
+ }
+ break;
+ }
+ }
+ }
+ }
+ return attributeValue;
+ }
+
+ public static void renderAttributeAndBehaviors(FacesContext facesContext, UIComponent component,
+ ComponentAttribute componentAttribute) throws IOException {
+ Object attributeValue = getAttributeAndBehaviorsValue(facesContext, component, componentAttribute);
+ renderAttribute(facesContext, componentAttribute.getHtmlAttributeName(), attributeValue);
+ }
+
+ public static void renderPassThroughAttributesOptimized(FacesContext context, UIComponent component,
+ Map<String, ComponentAttribute> knownAttributesMap) throws IOException {
+
+ boolean disabled = isDisabled(component);
+ Set<String> handledAttributes = new HashSet<String>(knownAttributesMap.size());
+ Object attributesThatAreSetObject = component.getAttributes().get(ATTRIBUTES_THAT_ARE_SET);
+ if (attributesThatAreSetObject instanceof Collection<?>) {
+ Collection<?> attributesThatAreSet = (Collection<?>) attributesThatAreSetObject;
+ for (Object attributeNameObject : attributesThatAreSet) {
+ if (attributeNameObject == null) {
+ continue;
+ }
+
+ String attributeName = attributeNameObject.toString();
+
+ ComponentAttribute knownAttribute = knownAttributesMap.get(attributeName);
+ if (knownAttribute != null) {
+ handledAttributes.add(knownAttribute.getHtmlAttributeName());
+
+ if (disabled && knownAttribute.getEventNames() != null) {
+ continue;
+ }
+
+ renderAttributeAndBehaviors(context, component, knownAttribute);
+ }
+ }
+
+ // render attributes that haven't been processed yet - there can be behaviors
+ for (ComponentAttribute knownAttribute : knownAttributesMap.values()) {
+
+ if (handledAttributes.contains(knownAttribute.getHtmlAttributeName())) {
+ continue;
+ }
+
+ renderAttributeAndBehaviors(context, component, knownAttribute);
+ }
+ } else {
+ // switch to unoptimized mode
+ renderPassThroughAttributes(context, component, knownAttributesMap);
+ }
+ }
+
+ public static void renderPassThroughAttributes(FacesContext context, UIComponent component,
+ Map<String, ComponentAttribute> knownAttributesMap) throws IOException {
+ Collection<ComponentAttribute> attributes = knownAttributesMap.values();
+
+ renderPassThroughAttributes(context, component, attributes);
+ }
+
+ public static void renderPassThroughAttributes(FacesContext context, UIComponent component, Collection<ComponentAttribute> attributes)
+ throws IOException {
+ boolean disabled = isDisabled(component);
+ for (ComponentAttribute knownAttribute : attributes) {
+ if (!disabled || knownAttribute.getEventNames().length == 0) {
+ renderAttributeAndBehaviors(context, component, knownAttribute);
+ }
+ }
+ }
+
+ public static String decodeBehaviors(FacesContext context, UIComponent component) {
+ if (!(component instanceof ClientBehaviorHolder)) {
+ return null;
+ }
+
+ ClientBehaviorHolder holder = (ClientBehaviorHolder) component;
+ Map<String, List<ClientBehavior>> behaviors = holder.getClientBehaviors();
+
+ if (behaviors == null || behaviors.isEmpty()) {
+ return null;
+ }
+
+ ExternalContext externalContext = context.getExternalContext();
+ Map<String, String> parametersMap = externalContext.getRequestParameterMap();
+ String behaviorEvent = parametersMap.get(BEHAVIOR_EVENT_NAME);
+
+ if (behaviorEvent == null) {
+ return null;
+ }
+
+ List<ClientBehavior> behaviorsForEvent = behaviors.get(behaviorEvent);
+ String behaviorSource = parametersMap.get(BEHAVIOR_SOURCE_ID);
+ String clientId = component.getClientId(context);
+
+ if (behaviorSource != null && behaviorSource.equals(clientId)) {
+ if (behaviorsForEvent != null && !behaviorsForEvent.isEmpty()) {
+ for (ClientBehavior behavior : behaviorsForEvent) {
+ behavior.decode(context, component);
+ }
+
+ return behaviorEvent;
+ }
+ }
+
+ return null;
+ }
+
+ public static Attributes attributes() {
+ return new Attributes();
+ }
+
+ public static Attributes attributes(Enum<?> ... attrs) {
+ Attributes res = new Attributes();
+ for (Enum<?> attr : attrs) {
+ res.generic(attr.toString(), attr.toString());
+ }
+
+ return res;
+ }
+
+ public static Attributes attributes(String ... attrs) {
+ Attributes res = new Attributes();
+ for (String attr : attrs) {
+ res.generic(attr, attr);
+ }
+
+ return res;
+ }
+
+ @SuppressWarnings("serial")
+ public static final class Attributes extends TreeSet<ComponentAttribute> {
+
+ private ComponentAttribute last;
+
+ public void render(FacesContext context, UIComponent component) throws IOException {
+ renderPassThroughAttributes(context, component, this);
+ }
+
+ public Attributes generic(String name, String componentAttribute, String... events) {
+ ComponentAttribute attribute = createAttribute(name, componentAttribute);
+ attribute.setEventNames(events);
+ attribute.setKind(Kind.GENERIC);
+ return this;
+ }
+
+ private ComponentAttribute createAttribute(String name, String componentAttribute) {
+ ComponentAttribute attribute = new ComponentAttribute(name);
+ attribute.setComponentAttributeName(componentAttribute);
+ add(attribute);
+ last = attribute;
+ return attribute;
+ }
+
+ public Attributes uri(String name, String componentAttribute) {
+ ComponentAttribute attribute = createAttribute(name, componentAttribute);
+ attribute.setKind(Kind.URI);
+ return this;
+ }
+
+ public Attributes bool(String name, String componentAttribute) {
+ ComponentAttribute attribute = createAttribute(name, componentAttribute);
+ attribute.setKind(Kind.BOOL);
+ return this;
+ }
+
+ public Attributes defaultValue(Object value){
+ last.setDefaultValue(value);
+ return this;
+ }
+
+ }
+
+}
Copied: branches/RF-7560/ui/common/ui/src/main/java/org/richfaces/renderkit/RendererBase.java (from rev 19044, branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/renderkit/RendererBase.java)
===================================================================
--- branches/RF-7560/ui/common/ui/src/main/java/org/richfaces/renderkit/RendererBase.java (rev 0)
+++ branches/RF-7560/ui/common/ui/src/main/java/org/richfaces/renderkit/RendererBase.java 2010-08-31 17:20:11 UTC (rev 19052)
@@ -0,0 +1,284 @@
+/**
+ * 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;
+
+import java.io.IOException;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+import javax.faces.render.Renderer;
+
+import org.ajax4jsf.Messages;
+import org.ajax4jsf.renderkit.RendererUtils;
+import org.richfaces.log.Logger;
+import org.richfaces.log.RichfacesLogger;
+import org.richfaces.skin.Skin;
+import org.richfaces.skin.SkinFactory;
+
+/**
+ * Base Renderer for all chameleon Skin's and components.
+ * At most, make all common procedures and realise concrete work in "template" methods.
+ *
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:58:51 $
+ */
+public abstract class RendererBase extends Renderer {
+
+ private static final Logger LOG = RichfacesLogger.RENDERKIT.getLogger();
+ private static final RendererUtils UTILS = RendererUtils.getInstance();
+
+ private SkinFactory skinFactory = null;
+
+ /*
+ * (non-Javadoc)
+ * @see javax.faces.render.Renderer#decode(javax.faces.context.FacesContext, javax.faces.component.UIComponent)
+ */
+ @Override
+ public void decode(FacesContext context, UIComponent component) {
+
+ // Test for correct parameters.
+ checkNull(context, component, "decode");
+
+ if (!getComponentClass().isInstance(component)) {
+ throw new IllegalArgumentException(Messages.getMessage(Messages.COMPONENT_CLASS_ERROR, "",
+ getComponentClass().getName()));
+ }
+
+ if (LOG.isDebugEnabled()) {
+ LOG.debug(Messages.getMessage(Messages.START_DECODING_COMPONENT_INFO, component.getClientId(context),
+ component.getClass().getName()));
+ }
+
+ preDecode(context, component);
+
+ // TODO - create set od common decoders ( UIInput, ActionSource etc. ) for process decoding.
+ if (component.isRendered()) {
+ String behaviorEventName = RenderKitUtils.decodeBehaviors(context, component);
+ if (behaviorEventName != null) {
+ queueComponentEventForBehaviorEvent(context, component, behaviorEventName);
+ }
+
+ doDecode(context, component);
+ }
+ }
+
+ protected void queueComponentEventForBehaviorEvent(FacesContext context, UIComponent component, String eventName) {
+
+ }
+
+ protected void preDecode(FacesContext context, UIComponent component) {
+ }
+
+ protected void preEncodeBegin(FacesContext context, UIComponent component) throws IOException {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see javax.faces.render.Renderer#encodeBegin(javax.faces.context.FacesContext, javax.faces.component.UIComponent)
+ */
+ @Override
+ public void encodeBegin(FacesContext context, UIComponent component) throws IOException {
+
+ // Test for correct parameters.
+ checkForCorrectParams(context, component, "encodeBegin");
+
+ if (LOG.isDebugEnabled()) {
+ LOG.debug(Messages.getMessage(Messages.START_ENCODING_COMPONENT_INFO, component.getClientId(context),
+ component.getClass().getName()));
+ }
+
+ preEncodeBegin(context, component);
+
+ if (component.isRendered()) {
+ ResponseWriter writer = context.getResponseWriter();
+
+ doEncodeBegin(writer, context, component);
+ }
+ }
+
+ private void checkForCorrectParams(FacesContext context, UIComponent component, String exceptionMessageParam) {
+ checkNull(context, component, exceptionMessageParam);
+
+ if (!getComponentClass().isInstance(component)) {
+ throw new IllegalArgumentException(Messages.getMessage(Messages.COMPONENT_CLASS_ERROR,
+ component.getClientId(context), getComponentClass().getName()));
+ }
+ }
+
+ private void checkNull(Object context, Object component, String exceptionMessageParam) {
+ if (context == null) {
+ throw new NullPointerException(Messages.getMessage(Messages.CONTEXT_NULL_ERROR, exceptionMessageParam));
+ }
+
+ if (component == null) {
+ throw new NullPointerException(Messages.getMessage(Messages.COMPONENT_NULL_ERROR, exceptionMessageParam));
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see javax.faces.render.Renderer#encodeChildren(javax.faces.context.FacesContext, javax.faces.component.UIComponent)
+ */
+ @Override
+ public void encodeChildren(FacesContext context, UIComponent component) throws IOException {
+
+ // Test for correct parameters.
+ checkForCorrectParams(context, component, "encodeBegin");
+
+ if (LOG.isDebugEnabled()) {
+ LOG.debug(Messages.getMessage(Messages.CHILDREN_ENCODING_COMPONENT_INFO, component.getClientId(context),
+ component.getClass().getName()));
+ }
+
+ preEncodeBegin(context, component);
+
+ if (component.isRendered()) {
+ ResponseWriter writer = context.getResponseWriter();
+
+ doEncodeChildren(writer, context, component);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see javax.faces.render.Renderer#encodeEnd(javax.faces.context.FacesContext, javax.faces.component.UIComponent)
+ */
+ @Override
+ public void encodeEnd(FacesContext context, UIComponent component) throws IOException {
+
+ // Test for correct parameters.
+ checkForCorrectParams(context, component, "encodeEnd");
+
+ if (component.isRendered()) {
+ ResponseWriter writer = context.getResponseWriter();
+
+ doEncodeEnd(writer, context, component);
+ }
+
+ if (LOG.isDebugEnabled()) {
+ LOG.debug(Messages.getMessage(Messages.FINISH_ENCODING_COMPONENT_INFO, component.getClientId(context),
+ component.getClass().getName()));
+ }
+ }
+
+ // ==========================================================
+ // Protected common methods - for all Renderer's
+
+ /**
+ * Calculate current Skin for rendering.
+ *
+ * @param context - current {@link FacesContext }
+ * @return
+ */
+ protected Skin getSkin(FacesContext context) {
+ if (skinFactory == null) {
+ skinFactory = SkinFactory.getInstance();
+ }
+
+ return skinFactory.getSkin(context);
+ }
+
+ /**
+ * Due to big number of common utility methods, base renderer divide to 2 classes - renderer and utils.
+ * since use static methods of utility class breack object paradigm, we use getter for concrete util instance.
+ * Developer can override any utility metod in 2 stages :
+ * 1) Create subclass of {@link RendererUtils} and override utility method.
+ * 2) Override this method for return instance of such subclass.
+ *
+ * @return Returns the utils.
+ */
+ public RendererUtils getUtils() {
+ return UTILS;
+ }
+
+ /**
+ * Get base component slass , targetted for this renderer. Used for check arguments in decode/encode.
+ *
+ * @return
+ */
+ protected Class<? extends UIComponent> getComponentClass() {
+ //TODO - do we need this function?
+ return UIComponent.class;
+ }
+
+ /**
+ * Template method for custom decoding of concrete renderer.
+ * All parameters checking if performed in original {@see decode } method.
+ *
+ * @param context
+ * @param component
+ */
+ protected void doDecode(FacesContext context, UIComponent component) {
+ }
+
+ /**
+ * Template method for custom start encoding of concrete renderer.
+ * All parameters checking and writer is performed in original {@link encodeBegin } method.
+ *
+ * @param writer
+ * @param context
+ * @param component
+ */
+ protected void doEncodeBegin(ResponseWriter writer, FacesContext context, UIComponent component)
+ throws IOException {
+ }
+
+ /**
+ * @param writer
+ * @param context
+ * @param component
+ */
+ protected void doEncodeChildren(ResponseWriter writer, FacesContext context, UIComponent component)
+ throws IOException {
+
+ // Hook method, must be overriden in renderers with special children processing
+ }
+
+ /**
+ * Template method for custom finish encoding of concrete renderer.
+ * All parameters checking and writer is performed in original {@link encodeEnd } method.
+ *
+ * @param writer
+ * @param context
+ * @param component
+ * @throws IOException
+ */
+ protected void doEncodeEnd(ResponseWriter writer, FacesContext context, UIComponent component) throws IOException {
+ }
+
+ /**
+ * Render all children for given component.
+ *
+ * @param facesContext
+ * @param component
+ * @throws IOException
+ */
+ public void renderChildren(FacesContext facesContext, UIComponent component) throws IOException {
+ if (component.getChildCount() > 0) {
+ for (UIComponent child : component.getChildren()) {
+ child.encodeAll(facesContext);
+ }
+ }
+ }
+
+}
Copied: branches/RF-7560/ui/common/ui/src/main/java/org/richfaces/renderkit/SequenceRendererHelper.java (from rev 19038, branches/RF-7560/core/impl/src/main/java/org/richfaces/renderkit/SequenceRendererHelper.java)
===================================================================
--- branches/RF-7560/ui/common/ui/src/main/java/org/richfaces/renderkit/SequenceRendererHelper.java (rev 0)
+++ branches/RF-7560/ui/common/ui/src/main/java/org/richfaces/renderkit/SequenceRendererHelper.java 2010-08-31 17:20:11 UTC (rev 19052)
@@ -0,0 +1,100 @@
+/*
+ * 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.richfaces.component.UISequence;
+import org.richfaces.component.util.HtmlUtil;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class SequenceRendererHelper {
+
+ private UISequence sequence;
+
+ private int rowIndex = -1;
+
+ private int columnIndex = 0;
+
+ private String[] rowClasses = null;
+
+ private String[] columnClasses = null;
+
+ public SequenceRendererHelper(UISequence sequence) {
+ super();
+ this.sequence = sequence;
+
+ this.rowClasses = splitClassesString((String) sequence.getAttributes().get("rowClasses"));
+ this.columnClasses = splitClassesString((String) sequence.getAttributes().get("columnClasses"));
+ }
+
+ private static String[] splitClassesString(String s) {
+ if (s != null) {
+ return s.split(",");
+ }
+
+ return null;
+ }
+
+ private static String getCorrespondingArrayItem(String[] strings, int idx) {
+ if (strings != null && strings.length > 0) {
+ return strings[idx % strings.length];
+ }
+
+ return null;
+ }
+
+ public UISequence getSequence() {
+ return sequence;
+ }
+
+ private void initialize() {
+ rowIndex = sequence.getRowIndex();
+ }
+
+ public void nextRow() {
+ if (rowIndex == -1) {
+ initialize();
+ }
+
+ rowIndex++;
+ columnIndex = 0;
+ }
+
+ public void nextColumn() {
+ columnIndex++;
+ }
+
+ public String getRowClass() {
+ String rowClass = (String) sequence.getAttributes().get("rowClass");
+ return HtmlUtil.concatClasses(getCorrespondingArrayItem(rowClasses, rowIndex), rowClass);
+ }
+
+ public String getColumnClass() {
+ return getCorrespondingArrayItem(columnClasses, columnIndex);
+ }
+
+ public boolean hasWalkedOverRows() {
+ return rowIndex != -1;
+ }
+}
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-08-31 16:59:42 UTC (rev 19051)
+++ branches/RF-7560/ui/common/ui/src/main/java/org/richfaces/renderkit/util/FormUtil.java 2010-08-31 17:20:11 UTC (rev 19052)
@@ -22,7 +22,6 @@
package org.richfaces.renderkit.util;
import org.ajax4jsf.renderkit.RendererUtils;
-import org.richfaces.component.EnclosingFormRequiredException;
import org.richfaces.component.SwitchType;
import javax.faces.component.UIComponent;
Copied: branches/RF-7560/ui/common/ui/src/main/java/org/richfaces/view/facelets/EmptyHandler.java (from rev 19038, branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/webapp/taglib/EmptyHandler.java)
===================================================================
--- branches/RF-7560/ui/common/ui/src/main/java/org/richfaces/view/facelets/EmptyHandler.java (rev 0)
+++ branches/RF-7560/ui/common/ui/src/main/java/org/richfaces/view/facelets/EmptyHandler.java 2010-08-31 17:20:11 UTC (rev 19052)
@@ -0,0 +1,53 @@
+/**
+ * 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;
+
+import javax.el.ELException;
+import javax.faces.FacesException;
+import javax.faces.component.UIComponent;
+import javax.faces.view.facelets.FaceletContext;
+import javax.faces.view.facelets.FaceletException;
+import javax.faces.view.facelets.TagConfig;
+import javax.faces.view.facelets.TagHandler;
+import java.io.IOException;
+
+/**
+ * This if "empty" facelets tag handler stub. This handler used to ignore tags on a page.
+ * At most, it used to bypass <jsp:root> and other tags, so we can use same markup for an facelets an jsp pages.
+ *
+ * @author asmirnov
+ */
+public class EmptyHandler extends TagHandler {
+ public EmptyHandler(TagConfig config) {
+ super(config);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see com.sun.facelets.FaceletHandler#apply(com.sun.facelets.FaceletContext, javax.faces.component.UIComponent)
+ */
+ public void apply(FaceletContext ctx, UIComponent parent)
+ throws IOException, FacesException, FaceletException, ELException {
+
+ this.nextHandler.apply(ctx, parent);
+ }
+}
Copied: branches/RF-7560/ui/common/ui/src/main/java/org/richfaces/view/facelets/RowKeyConverterRule.java (from rev 19038, branches/RF-7560/core/impl/src/main/java/org/ajax4jsf/webapp/taglib/RowKeyConverterRule.java)
===================================================================
--- branches/RF-7560/ui/common/ui/src/main/java/org/richfaces/view/facelets/RowKeyConverterRule.java (rev 0)
+++ branches/RF-7560/ui/common/ui/src/main/java/org/richfaces/view/facelets/RowKeyConverterRule.java 2010-08-31 17:20:11 UTC (rev 19052)
@@ -0,0 +1,94 @@
+/**
+ * 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;
+
+import org.richfaces.component.UIDataAdaptor;
+
+import javax.faces.convert.Converter;
+import javax.faces.view.facelets.FaceletContext;
+import javax.faces.view.facelets.MetaRule;
+import javax.faces.view.facelets.Metadata;
+import javax.faces.view.facelets.MetadataTarget;
+import javax.faces.view.facelets.TagAttribute;
+
+/**
+ * Apply rowKeyConverter to component
+ *
+ * @author Maksim Kaszynski
+ * @since 3.3.1
+ */
+public class RowKeyConverterRule extends MetaRule {
+ public static final RowKeyConverterRule INSTANCE = new RowKeyConverterRule();
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.sun.facelets.tag.MetaRule#applyRule(java.lang.String,
+ * com.sun.facelets.tag.TagAttribute,
+ * com.sun.facelets.tag.MetadataTarget)
+ */
+ @Override
+ public Metadata applyRule(String name, TagAttribute attribute, MetadataTarget meta) {
+ if (meta.isTargetInstanceOf(UIDataAdaptor.class)) {
+ if ("rowKeyConverter".equals(name)) {
+ if (attribute.isLiteral()) {
+ return new StaticConverterMetadata(attribute.getValue());
+ } else {
+ return new DynamicConverterMetaData(attribute);
+ }
+ }
+ }
+
+ return null;
+ }
+
+ static final class DynamicConverterMetaData extends Metadata {
+ private final TagAttribute attribute;
+
+ public DynamicConverterMetaData(TagAttribute attribute) {
+ super();
+ this.attribute = attribute;
+ }
+
+ @Override
+ public void applyMetadata(FaceletContext ctx, Object instance) {
+ ((UIDataAdaptor) instance).setValueExpression("rowKeyConverter",
+ attribute.getValueExpression(ctx, Converter.class));
+ }
+ }
+
+ static final class StaticConverterMetadata extends Metadata {
+ private final String converterId;
+
+ public StaticConverterMetadata(String converterId) {
+ super();
+ this.converterId = converterId;
+ }
+
+ @Override
+ public void applyMetadata(FaceletContext ctx, Object instance) {
+ Converter converter = ctx.getFacesContext().getApplication().createConverter(converterId);
+
+ ((UIDataAdaptor) instance).setRowKeyConverter(converter);
+ }
+ }
+}
Copied: branches/RF-7560/ui/common/ui/src/test/java/org/richfaces/component/DataAdaptorTestCase.java (from rev 19038, branches/RF-7560/core/impl/src/test/java/org/richfaces/component/DataAdaptorTestCase.java)
===================================================================
--- branches/RF-7560/ui/common/ui/src/test/java/org/richfaces/component/DataAdaptorTestCase.java (rev 0)
+++ branches/RF-7560/ui/common/ui/src/test/java/org/richfaces/component/DataAdaptorTestCase.java 2010-08-31 17:20:11 UTC (rev 19052)
@@ -0,0 +1,503 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, 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.component;
+
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.EnumSet;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import javax.faces.component.ContextCallback;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIComponentBase;
+import javax.faces.component.UINamingContainer;
+import javax.faces.component.html.HtmlForm;
+import javax.faces.component.html.HtmlInputText;
+import javax.faces.component.html.HtmlOutputText;
+import javax.faces.component.visit.VisitCallback;
+import javax.faces.component.visit.VisitContext;
+import javax.faces.component.visit.VisitHint;
+import javax.faces.component.visit.VisitResult;
+import javax.faces.context.FacesContext;
+import javax.faces.event.AbortProcessingException;
+import javax.faces.event.PhaseId;
+import javax.faces.event.ValueChangeEvent;
+import javax.faces.event.ValueChangeListener;
+import javax.faces.model.ListDataModel;
+
+import org.ajax4jsf.component.IterationStateHolder;
+import org.ajax4jsf.model.ExtendedDataModel;
+import org.ajax4jsf.model.SequenceDataModel;
+import org.jboss.test.faces.AbstractFacesTest;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class DataAdaptorTestCase extends AbstractFacesTest {
+
+ private static final String VAR_NAME = "item";
+
+ private static class TestCallback {
+
+ private int value;
+
+ public void handle() {
+
+ }
+
+ public void reset() {
+ value = 0;
+ }
+
+ public int getAndIncrement() {
+ return value++;
+ }
+
+ public int get() {
+ return value;
+ }
+ }
+
+ private MockDataAdaptor mockDataAdaptor;
+
+ private List<String> data;
+
+ private ExtendedDataModel<String> createDataModel() {
+ return new SequenceDataModel<String>(new ListDataModel<String>(new ArrayList<String>(data)));
+ }
+
+ private Object getVarValue() {
+ return facesContext.getApplication().evaluateExpressionGet(facesContext,
+ MessageFormat.format("#'{'{0}'}'", VAR_NAME), Object.class);
+ }
+
+ @Override
+ public void setUp() throws Exception {
+ super.setUp();
+
+ data = Arrays.asList("a", "b", "c", "d");
+
+ setupFacesRequest();
+
+ mockDataAdaptor = new MockDataAdaptor();
+ mockDataAdaptor.setDataModel(createDataModel());
+ mockDataAdaptor.setVar(VAR_NAME);
+
+ facesContext.getViewRoot().getChildren().add(mockDataAdaptor);
+ }
+
+ @Override
+ public void tearDown() throws Exception {
+ super.tearDown();
+
+ data = null;
+ mockDataAdaptor = null;
+ }
+
+ private void resetCallbacks(TestCallback... callbacks) {
+ for (TestCallback callback : callbacks) {
+ callback.reset();
+ assertEquals(0, callback.get());
+ }
+ }
+
+ private UIComponent createCallbackComponent(final TestCallback callback) throws Exception {
+ return new HtmlOutputText() {
+
+ private void notifyCallbacks() {
+ callback.handle();
+ }
+
+ @Override
+ public void processDecodes(FacesContext context) {
+ super.processDecodes(context);
+ notifyCallbacks();
+ }
+
+ @Override
+ public void processValidators(FacesContext context) {
+ super.processValidators(context);
+ notifyCallbacks();
+ }
+
+ @Override
+ public void processUpdates(FacesContext context) {
+ super.processUpdates(context);
+ notifyCallbacks();
+ }
+ };
+ }
+
+ public void testProcessChildren() throws Exception {
+
+ TestCallback childCallback = new TestCallback() {
+ @Override
+ public void handle() {
+ assertEquals(getVarValue(), data.get(getAndIncrement()));
+ }
+ };
+ UIComponent child = createCallbackComponent(childCallback);
+ child.setId("child");
+
+ TestCallback facetCallback = new TestCallback() {
+ @Override
+ public void handle() {
+ assertEquals(getVarValue(), data.get(getAndIncrement()));
+ }
+ };
+ UIComponent facet = createCallbackComponent(facetCallback);
+ child.getFacets().put("f", facet);
+ facet.setId("facet");
+
+ TestCallback immediateFacetCallback = new TestCallback() {
+ @Override
+ public void handle() {
+ getAndIncrement();
+ assertNull(getVarValue());
+ }
+ };
+ UIComponent immediateFacet = createCallbackComponent(immediateFacetCallback);
+ immediateFacet.setId("immediateFacet");
+
+ mockDataAdaptor.getChildren().add(child);
+ mockDataAdaptor.getFacets().put("facet", immediateFacet);
+
+ mockDataAdaptor.processDecodes(facesContext);
+
+ assertEquals(data.size(), facetCallback.get());
+ assertEquals(data.size(), childCallback.get());
+ assertEquals(1, immediateFacetCallback.get());
+
+ resetCallbacks(childCallback, facetCallback, immediateFacetCallback);
+
+ mockDataAdaptor.processValidators(facesContext);
+
+ assertEquals(data.size(), facetCallback.get());
+ assertEquals(data.size(), childCallback.get());
+ assertEquals(1, immediateFacetCallback.get());
+
+ resetCallbacks(childCallback, facetCallback, immediateFacetCallback);
+
+ mockDataAdaptor.processUpdates(facesContext);
+
+ assertEquals(data.size(), facetCallback.get());
+ assertEquals(data.size(), childCallback.get());
+ assertEquals(1, immediateFacetCallback.get());
+
+ resetCallbacks(childCallback, facetCallback, immediateFacetCallback);
+ }
+
+ public void testSaveRestoreChildrenState() throws Exception {
+ HtmlForm form = new HtmlForm();
+ HtmlInputText input = new HtmlInputText();
+ IterationStateHolderComponent stateHolder = new IterationStateHolderComponent();
+
+ List<UIComponent> children = mockDataAdaptor.getChildren();
+ children.add(form);
+ form.getChildren().add(input);
+ form.getFacets().put("facet", stateHolder);
+
+ mockDataAdaptor.setRowKey(facesContext, Integer.valueOf(0));
+
+ assertFalse(form.isSubmitted());
+ assertNull(input.getSubmittedValue());
+ assertNull(input.getLocalValue());
+ assertTrue(input.isValid());
+ assertFalse(input.isLocalValueSet());
+ assertNull(stateHolder.getIterationState());
+
+ form.setSubmitted(true);
+ input.setSubmittedValue("user input");
+ input.setValue("component value");
+ input.setValid(false);
+ input.setLocalValueSet(true);
+ stateHolder.setIterationState("state");
+
+ mockDataAdaptor.setRowKey(facesContext, Integer.valueOf(1));
+
+ assertFalse(form.isSubmitted());
+ assertNull(input.getSubmittedValue());
+ assertNull(input.getLocalValue());
+ assertTrue(input.isValid());
+ assertFalse(input.isLocalValueSet());
+ assertNull(stateHolder.getIterationState());
+
+ input.setSubmittedValue("another input from user");
+ input.setValue("123");
+ assertTrue(input.isLocalValueSet());
+ stateHolder.setIterationState("456");
+
+ mockDataAdaptor.setRowKey(facesContext, Integer.valueOf(0));
+ assertTrue(form.isSubmitted());
+ assertEquals("user input", input.getSubmittedValue());
+ assertEquals("component value", input.getLocalValue());
+ assertFalse(input.isValid());
+ assertTrue(input.isLocalValueSet());
+ assertEquals("state", stateHolder.getIterationState());
+
+ mockDataAdaptor.setRowKey(facesContext, Integer.valueOf(1));
+ assertFalse(form.isSubmitted());
+ assertEquals("another input from user", input.getSubmittedValue());
+ assertEquals("123", input.getLocalValue());
+ assertTrue(input.isValid());
+ assertTrue(input.isLocalValueSet());
+ assertEquals("456", stateHolder.getIterationState());
+
+ mockDataAdaptor.setRowKey(facesContext, null);
+ assertFalse(form.isSubmitted());
+ assertNull(input.getSubmittedValue());
+ assertNull(input.getLocalValue());
+ assertTrue(input.isValid());
+ assertFalse(input.isLocalValueSet());
+ assertNull(stateHolder.getIterationState());
+ }
+
+ public void testSaveRestoreChildrenStateNestedDataAdaptors() throws Exception {
+ MockDataAdaptor childAdaptor = new MockDataAdaptor();
+ childAdaptor.setDataModel(createDataModel());
+
+ HtmlInputText input = new HtmlInputText();
+
+ mockDataAdaptor.getChildren().add(childAdaptor);
+ childAdaptor.getChildren().add(input);
+
+ Integer rowKey = Integer.valueOf(2);
+ Integer childKey = Integer.valueOf(1);
+
+ mockDataAdaptor.setRowKey(facesContext, rowKey);
+ childAdaptor.setRowKey(facesContext, childKey);
+
+ assertNull(input.getSubmittedValue());
+ assertNull(input.getLocalValue());
+ assertTrue(input.isValid());
+ assertFalse(input.isLocalValueSet());
+
+ input.setSubmittedValue("submittedValue");
+ input.setValue("value");
+
+ childAdaptor.setRowKey(facesContext, null);
+ mockDataAdaptor.setRowKey(facesContext, Integer.valueOf(3));
+ childAdaptor.setRowKey(facesContext, Integer.valueOf(0));
+
+ assertNull(input.getSubmittedValue());
+ assertNull(input.getLocalValue());
+ assertFalse(input.isLocalValueSet());
+
+ childAdaptor.setRowKey(facesContext, null);
+ mockDataAdaptor.setRowKey(facesContext, rowKey);
+ childAdaptor.setRowKey(facesContext, childKey);
+
+ assertEquals("submittedValue", input.getSubmittedValue());
+ assertEquals("value", input.getLocalValue());
+ assertTrue(input.isValid());
+ assertTrue(input.isLocalValueSet());
+ }
+
+ public void testEventsQueueing() throws Exception {
+ HtmlInputText input = new HtmlInputText();
+
+ final TestCallback testCallback = new TestCallback();
+ input.addValueChangeListener(new ValueChangeListener() {
+
+ public void processValueChange(ValueChangeEvent event) throws AbortProcessingException {
+ testCallback.getAndIncrement();
+ assertEquals(data.get(1), getVarValue());
+ }
+ });
+
+ mockDataAdaptor.getChildren().add(input);
+ mockDataAdaptor.setRowKey(facesContext, Integer.valueOf(1));
+ assertEquals(data.get(1), getVarValue());
+
+ new ValueChangeEvent(input, null, "testValue").queue();
+ mockDataAdaptor.setRowKey(facesContext, null);
+
+ facesContext.getViewRoot().broadcastEvents(facesContext, PhaseId.PROCESS_VALIDATIONS);
+ assertEquals(1, testCallback.get());
+ }
+
+ public void testInvokeOnComponent() throws Exception {
+ final HtmlInputText facet = new HtmlInputText();
+ final HtmlInputText child = new HtmlInputText();
+
+ mockDataAdaptor.getFacets().put("facet", facet);
+ mockDataAdaptor.getChildren().add(child);
+
+ mockDataAdaptor.setId("_data");
+ facet.setId("_facet");
+ child.setId("_child");
+
+ boolean invocationResult;
+ final TestCallback callback = new TestCallback();
+ invocationResult = mockDataAdaptor.invokeOnComponent(facesContext, "_data", new ContextCallback() {
+
+ public void invokeContextCallback(FacesContext context, UIComponent target) {
+ callback.getAndIncrement();
+ assertEquals(mockDataAdaptor, target);
+ assertEquals("_data", target.getClientId());
+ }
+ });
+
+ assertTrue(invocationResult);
+ assertEquals(1, callback.get());
+ callback.reset();
+
+ final char separatorChar = UINamingContainer.getSeparatorChar(facesContext);
+ invocationResult = mockDataAdaptor.invokeOnComponent(facesContext, "_data" + separatorChar + "_facet",
+ new ContextCallback() {
+
+ public void invokeContextCallback(FacesContext context, UIComponent target) {
+ callback.getAndIncrement();
+ assertEquals(facet, target);
+ assertEquals("_data" + separatorChar + "_facet", target.getClientId());
+ }
+ });
+
+ assertTrue(invocationResult);
+ assertEquals(1, callback.get());
+ callback.reset();
+
+ invocationResult = mockDataAdaptor.invokeOnComponent(facesContext, "_data" + separatorChar + "2"
+ + separatorChar + "_child", new ContextCallback() {
+
+ public void invokeContextCallback(FacesContext context, UIComponent target) {
+ callback.getAndIncrement();
+ assertEquals(child, target);
+ assertEquals(data.get(2), getVarValue());
+ assertEquals("_data" + separatorChar + "2" + separatorChar + "_child", target.getClientId());
+ }
+ });
+
+ assertTrue(invocationResult);
+ assertEquals(1, callback.get());
+ callback.reset();
+
+ invocationResult = mockDataAdaptor.invokeOnComponent(facesContext, "_data" + separatorChar + "100"
+ + separatorChar + "_child", new ContextCallback() {
+
+ public void invokeContextCallback(FacesContext context, UIComponent target) {
+ fail();
+ }
+ });
+ assertFalse(invocationResult);
+
+ invocationResult = mockDataAdaptor.invokeOnComponent(facesContext, "_data" + separatorChar
+ + "nonExistentComponent", new ContextCallback() {
+
+ public void invokeContextCallback(FacesContext context, UIComponent target) {
+ fail();
+ }
+ });
+ assertFalse(invocationResult);
+ }
+
+ public void testVisitChildren() throws Exception {
+ final HtmlInputText facet = new HtmlInputText();
+ final HtmlInputText child = new HtmlInputText();
+
+ mockDataAdaptor.getFacets().put("facet", facet);
+ mockDataAdaptor.getChildren().add(child);
+
+ mockDataAdaptor.setId("_data");
+ facet.setId("_facet");
+ child.setId("_child");
+
+ VisitContext fullVisitContext = VisitContext.createVisitContext(facesContext);
+
+ final char separatorChar = UINamingContainer.getSeparatorChar(facesContext);
+ final Set<String> idsToVisit = new HashSet<String>();
+ idsToVisit.add("_data" + separatorChar + "_facet");
+ idsToVisit.add("_data" + separatorChar + "0" + separatorChar + "_child");
+ idsToVisit.add("_data" + separatorChar + "2" + separatorChar + "_child");
+
+ VisitContext partialVisitContext = VisitContext.createVisitContext(facesContext, idsToVisit, EnumSet
+ .of(VisitHint.SKIP_UNRENDERED));
+
+ final TestCallback callback = new TestCallback();
+ mockDataAdaptor.visitTree(fullVisitContext, new VisitCallback() {
+
+ public VisitResult visit(VisitContext context, UIComponent target) {
+ callback.getAndIncrement();
+ assertNotNull(target);
+
+ return VisitResult.ACCEPT;
+ }
+ });
+
+ assertEquals(1 /* adaptor itself */+ 1 /* facet */+ data.size(), callback.get());
+
+ callback.reset();
+
+ mockDataAdaptor.visitTree(partialVisitContext, new VisitCallback() {
+
+ public VisitResult visit(VisitContext context, UIComponent target) {
+ callback.getAndIncrement();
+ assertNotNull(target);
+ assertTrue(idsToVisit.contains(target.getClientId()));
+ return VisitResult.ACCEPT;
+ }
+ });
+
+ assertEquals(idsToVisit.size(), callback.get());
+
+ callback.reset();
+
+ mockDataAdaptor.visitTree(fullVisitContext, new VisitCallback() {
+
+ public VisitResult visit(VisitContext context, UIComponent target) {
+ callback.getAndIncrement();
+
+ if (child.equals(target)
+ && child.getClientId().equals("_data" + separatorChar + "1" + separatorChar + "_child")) {
+ return VisitResult.COMPLETE;
+ }
+
+ return VisitResult.ACCEPT;
+ }
+ });
+
+ assertEquals(1 /* data adaptor */+ 1 /* facet */+ 2 /* [0..1] children */, callback.get());
+ }
+}
+
+class IterationStateHolderComponent extends UIComponentBase implements IterationStateHolder {
+
+ private Object iterationState;
+
+ @Override
+ public String getFamily() {
+ return "test.Component";
+ }
+
+ public Object getIterationState() {
+ return iterationState;
+ }
+
+ public void setIterationState(Object state) {
+ iterationState = state;
+ }
+
+}
Copied: branches/RF-7560/ui/common/ui/src/test/java/org/richfaces/component/MockDataAdaptor.java (from rev 19038, branches/RF-7560/core/impl/src/test/java/org/richfaces/component/MockDataAdaptor.java)
===================================================================
--- branches/RF-7560/ui/common/ui/src/test/java/org/richfaces/component/MockDataAdaptor.java (rev 0)
+++ branches/RF-7560/ui/common/ui/src/test/java/org/richfaces/component/MockDataAdaptor.java 2010-08-31 17:20:11 UTC (rev 19052)
@@ -0,0 +1,66 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, 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.component;
+
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+
+import org.ajax4jsf.model.DataComponentState;
+import org.ajax4jsf.model.ExtendedDataModel;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class MockDataAdaptor extends UIDataAdaptor {
+
+ private ExtendedDataModel<?> dataModel;
+
+ @Override
+ protected DataComponentState createComponentState() {
+ return new MockDataAdaptorComponentState();
+ }
+
+ @Override
+ protected ExtendedDataModel<?> createExtendedDataModel() {
+ return dataModel;
+ }
+
+ public ExtendedDataModel<?> getDataModel() {
+ return dataModel;
+ }
+
+ public void setDataModel(ExtendedDataModel<?> dataModel) {
+ this.dataModel = dataModel;
+ }
+
+ /* (non-Javadoc)
+ * @see org.richfaces.component.UIDataAdaptor#getRowKeyConverter()
+ */
+ @Override
+ public Converter getRowKeyConverter() {
+ // TODO Auto-generated method stub
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ return facesContext.getApplication().createConverter(Integer.class);
+ }
+
+}
Copied: branches/RF-7560/ui/common/ui/src/test/java/org/richfaces/component/MockDataAdaptorComponentState.java (from rev 19038, branches/RF-7560/core/impl/src/test/java/org/richfaces/component/MockDataAdaptorComponentState.java)
===================================================================
--- branches/RF-7560/ui/common/ui/src/test/java/org/richfaces/component/MockDataAdaptorComponentState.java (rev 0)
+++ branches/RF-7560/ui/common/ui/src/test/java/org/richfaces/component/MockDataAdaptorComponentState.java 2010-08-31 17:20:11 UTC (rev 19052)
@@ -0,0 +1,39 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, 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.component;
+
+import org.ajax4jsf.model.DataComponentState;
+import org.ajax4jsf.model.Range;
+import org.ajax4jsf.model.SequenceRange;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class MockDataAdaptorComponentState implements DataComponentState {
+
+ private Range range = new SequenceRange(0, -1);
+
+ public Range getRange() {
+ return range;
+ }
+}
Copied: branches/RF-7560/ui/common/ui/src/test/java/org/richfaces/renderkit/MockClientBehaviorHolder.java (from rev 19038, branches/RF-7560/core/commons/src/test/java/org/richfaces/renderkit/MockClientBehaviorHolder.java)
===================================================================
--- branches/RF-7560/ui/common/ui/src/test/java/org/richfaces/renderkit/MockClientBehaviorHolder.java (rev 0)
+++ branches/RF-7560/ui/common/ui/src/test/java/org/richfaces/renderkit/MockClientBehaviorHolder.java 2010-08-31 17:20:11 UTC (rev 19052)
@@ -0,0 +1,58 @@
+/*
+ * 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 static org.jboss.test.faces.mock.FacesMockController.invokeCurrent;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+
+import javax.faces.component.behavior.ClientBehavior;
+import javax.faces.component.behavior.ClientBehaviorHolder;
+
+import org.easymock.IMocksControl;
+import org.jboss.test.faces.mock.component.MockUIComponent;
+
+public class MockClientBehaviorHolder extends MockUIComponent implements ClientBehaviorHolder {
+
+ public MockClientBehaviorHolder(IMocksControl control, String name) {
+ super(control, name);
+ }
+
+ public void addClientBehavior(String eventName, ClientBehavior behavior) {
+ invokeCurrent(this, eventName, behavior);
+ }
+
+ public Map<String, List<ClientBehavior>> getClientBehaviors() {
+ return invokeCurrent(this);
+ }
+
+ public String getDefaultEventName() {
+ return invokeCurrent(this);
+ }
+
+ public Collection<String> getEventNames() {
+ return invokeCurrent(this);
+ }
+
+}
Copied: branches/RF-7560/ui/common/ui/src/test/java/org/richfaces/renderkit/RenderKitUtilsMocksTest.java (from rev 19038, branches/RF-7560/core/commons/src/test/java/org/richfaces/renderkit/RenderKitUtilsMocksTest.java)
===================================================================
--- branches/RF-7560/ui/common/ui/src/test/java/org/richfaces/renderkit/RenderKitUtilsMocksTest.java (rev 0)
+++ branches/RF-7560/ui/common/ui/src/test/java/org/richfaces/renderkit/RenderKitUtilsMocksTest.java 2010-08-31 17:20:11 UTC (rev 19052)
@@ -0,0 +1,377 @@
+/*
+ * 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 static org.easymock.EasyMock.eq;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.expectLastCall;
+import static org.easymock.EasyMock.same;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import java.text.MessageFormat;
+import java.util.Arrays;
+import java.util.EnumSet;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeMap;
+
+import javax.faces.component.UIComponent;
+import javax.faces.component.behavior.ClientBehavior;
+import javax.faces.component.behavior.ClientBehaviorContext;
+import javax.faces.component.behavior.ClientBehaviorHint;
+import javax.faces.component.behavior.ClientBehaviorHolder;
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+
+import org.easymock.EasyMock;
+import org.jboss.test.faces.mock.MockFacesEnvironment;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class RenderKitUtilsMocksTest {
+
+ /**
+ *
+ */
+ private static final String CLIENT_ID = "submittedId";
+
+ private MockFacesEnvironment facesEnvironment;
+
+ private ResponseWriter responseWriter;
+
+ private FacesContext facesContext;
+
+ private ExternalContext externalContext;
+
+ private Map<String, Object> componentAttributes;
+
+ private Map<String, List<ClientBehavior>> behaviorsMap;
+
+ private Map<String, ComponentAttribute> knownAttributes;
+
+ @Before
+ public void setUp() throws Exception {
+ facesEnvironment = MockFacesEnvironment.createEnvironment().withExternalContext();
+
+ facesContext = facesEnvironment.getFacesContext();
+ externalContext = facesEnvironment.getExternalContext();
+
+ responseWriter = facesEnvironment.createMock(ResponseWriter.class);
+ expect(facesContext.getResponseWriter()).andStubReturn(responseWriter);
+ expect(responseWriter.getContentType()).andStubReturn("application/xhtml+xml");
+
+ componentAttributes = new HashMap<String, Object>();
+ behaviorsMap = new HashMap<String, List<ClientBehavior>>();
+ knownAttributes = new TreeMap<String, ComponentAttribute>();
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ this.facesEnvironment.verify();
+ this.facesEnvironment.release();
+
+ this.facesEnvironment = null;
+ this.responseWriter = null;
+ this.facesContext = null;
+ this.externalContext = null;
+ this.componentAttributes = null;
+ this.behaviorsMap = null;
+ this.knownAttributes = null;
+ }
+
+ private UIComponent createMockComponent() {
+ UIComponent component = facesEnvironment.createMock(UIComponent.class);
+ expect(component.getAttributes()).andStubReturn(componentAttributes);
+ expect(component.getClientId(same(facesContext))).andStubReturn(CLIENT_ID);
+ return component;
+ }
+
+ private ClientBehaviorHolder createMockClientBehaviorHolder() {
+ UIComponent component = facesEnvironment.createMock(MockClientBehaviorHolder.class);
+ expect(component.getClientId(same(facesContext))).andStubReturn(CLIENT_ID);
+ expect(component.getAttributes()).andStubReturn(componentAttributes);
+ ClientBehaviorHolder behaviorHolder = (ClientBehaviorHolder) component;
+ expect(behaviorHolder.getClientBehaviors()).andStubReturn(behaviorsMap);
+ expect(behaviorHolder.getEventNames()).andStubReturn(
+ Arrays.asList("click", "action", "mousemove", "keypress", "blur", "contextmenu"));
+ return behaviorHolder;
+ }
+
+ @Test
+ public void testRenderPassThroughAttributes() throws Exception {
+ knownAttributes.put("disabled", new ComponentAttribute("disabled"));
+ knownAttributes.put("checked", new ComponentAttribute("checked"));
+ knownAttributes.put("style", new ComponentAttribute("style"));
+ knownAttributes.put("src", new ComponentAttribute("src"));
+ knownAttributes.put("lang", new ComponentAttribute("lang"));
+ knownAttributes.put("class", new ComponentAttribute("class").setComponentAttributeName("styleClass"));
+
+ componentAttributes.put("disabled", Boolean.TRUE);
+ componentAttributes.put("checked", Boolean.FALSE);
+ componentAttributes.put("style", "color:red");
+ componentAttributes.put("src", "urn:abc");
+ componentAttributes.put("facelets.Mark", 123);
+ componentAttributes.put("lang", "ru");
+ componentAttributes.put("styleClass", "rich-component");
+
+ UIComponent component = createMockComponent();
+
+ responseWriter.writeAttribute(eq("disabled"), eq(Boolean.TRUE), EasyMock.<String>isNull());
+ // checked attribute shouldn't be rendered - it's 'false'
+ responseWriter.writeAttribute(eq("style"), eq("color:red"), EasyMock.<String>isNull());
+ responseWriter.writeURIAttribute(eq("src"), eq("urn:abc"), EasyMock.<String>isNull());
+ // facelets.Mark shouldn't be rendered - it's unknown
+ responseWriter.writeAttribute(eq("xml:lang"), eq("ru"), EasyMock.<String>isNull());
+ responseWriter.writeAttribute(eq("class"), eq("rich-component"), EasyMock.<String>isNull());
+
+ facesEnvironment.replay();
+
+ RenderKitUtils.renderPassThroughAttributes(facesContext, component, knownAttributes);
+ }
+
+ private ClientBehavior createClientBehavior(String handlerData, Set<ClientBehaviorHint> hints) {
+ ClientBehavior behavior = facesEnvironment.createMock(ClientBehavior.class);
+ expect(behavior.getScript(EasyMock.<ClientBehaviorContext> notNull())).andStubReturn(
+ MessageFormat.format("prompt({0})", handlerData));
+
+ expect(behavior.getHints()).andStubReturn(hints);
+ return behavior;
+ }
+
+ @Test
+ public void testBehaviors() throws Exception {
+ knownAttributes.put("onclick", new ComponentAttribute("onclick")
+ .setEventNames(new String[] { "click", "action" }));
+ knownAttributes.put("onmousemove", new ComponentAttribute("onmousemove")
+ .setEventNames(new String[] { "mousemove" }));
+ knownAttributes.put("onkeypress", new ComponentAttribute("onkeypress")
+ .setEventNames(new String[] { "keypress" }));
+ knownAttributes.put("oncontextmenu", new ComponentAttribute("oncontextmenu")
+ .setEventNames(new String[] { "contextmenu" }));
+
+ componentAttributes.put("onkeypress", "alert(keypress)");
+ componentAttributes.put("onmousemove", "alert(mousemove)");
+ componentAttributes.put("onclick", "alert(click)");
+
+ Set<ClientBehaviorHint> emptyHintsSet = EnumSet.noneOf(ClientBehaviorHint.class);
+ Set<ClientBehaviorHint> submittingHintsSet = EnumSet.of(ClientBehaviorHint.SUBMITTING);
+
+ ClientBehavior keypressBehavior = createClientBehavior("keypress", emptyHintsSet);
+ ClientBehavior actionBehavior1 = createClientBehavior("action1", emptyHintsSet);
+ ClientBehavior actionBehavior2 = createClientBehavior("action2", submittingHintsSet);
+ ClientBehavior actionBehavior3 = createClientBehavior("action3", emptyHintsSet);
+ ClientBehavior contextmenuBehavior = createClientBehavior("contextmenu", emptyHintsSet);
+
+ behaviorsMap.put("keypress", Arrays.asList(keypressBehavior));
+ behaviorsMap.put("action", Arrays.asList(actionBehavior1, actionBehavior2, actionBehavior3));
+ behaviorsMap.put("contextmenu", Arrays.asList(contextmenuBehavior));
+
+ ClientBehaviorHolder behaviorHolder = createMockClientBehaviorHolder();
+ UIComponent component = (UIComponent) behaviorHolder;
+
+ responseWriter.writeAttribute(eq("onkeypress"), eq("jsf.util.chain('alert(keypress)','prompt(keypress)')"),
+ EasyMock.<String>isNull());
+ responseWriter.writeAttribute(eq("onclick"),
+ eq("jsf.util.chain('alert(click)','prompt(action1)','prompt(action2)')"), EasyMock.<String>isNull());
+ responseWriter.writeAttribute(eq("onmousemove"), eq("alert(mousemove)"), EasyMock.<String>isNull());
+ responseWriter.writeAttribute(eq("oncontextmenu"), eq("prompt(contextmenu)"), EasyMock.<String>isNull());
+
+ facesEnvironment.replay();
+
+ RenderKitUtils.renderPassThroughAttributes(facesContext, component, knownAttributes);
+ }
+
+ private UIComponent setupBehaviorsTestForDisabledComponent() throws IOException {
+ knownAttributes.put("style", new ComponentAttribute("style"));
+ knownAttributes.put("onclick", new ComponentAttribute("onclick")
+ .setEventNames(new String[] { "click", "action" }));
+ knownAttributes.put("onmousemove", new ComponentAttribute("onmousemove")
+ .setEventNames(new String[] { "mousemove" }));
+
+ componentAttributes.put("onmousemove", "alert(mousemove)");
+ componentAttributes.put("onclick", "alert(click)");
+ componentAttributes.put("style", "color:green");
+
+ Set<ClientBehaviorHint> emptyHintsSet = EnumSet.noneOf(ClientBehaviorHint.class);
+
+ ClientBehavior actionBehavior1 = createClientBehavior("action1", emptyHintsSet);
+ behaviorsMap.put("action", Arrays.asList(actionBehavior1));
+
+ ClientBehaviorHolder behaviorHolder = createMockClientBehaviorHolder();
+ UIComponent component = (UIComponent) behaviorHolder;
+ return component;
+ }
+
+ @Test
+ public void testBehaviorsForDisabledComponent() throws Exception {
+ componentAttributes.put("disabled", Boolean.TRUE);
+ UIComponent component = setupBehaviorsTestForDisabledComponent();
+
+ responseWriter.writeAttribute(eq("style"), eq("color:green"), EasyMock.<String>isNull());
+
+ facesEnvironment.replay();
+
+ RenderKitUtils.renderPassThroughAttributes(facesContext, component, knownAttributes);
+ }
+
+ @Test
+ public void testBehaviorsForNonDisabledComponent() throws Exception {
+ componentAttributes.put("disabled", Boolean.FALSE);
+ UIComponent component = setupBehaviorsTestForDisabledComponent();
+
+ responseWriter.writeAttribute(eq("onclick"), eq("jsf.util.chain('alert(click)','prompt(action1)')"),
+ EasyMock.<String>isNull());
+ responseWriter.writeAttribute(eq("onmousemove"),
+ eq("alert(mousemove)"), EasyMock.<String>isNull());
+ responseWriter.writeAttribute(eq("style"), eq("color:green"), EasyMock.<String>isNull());
+
+ facesEnvironment.replay();
+
+ RenderKitUtils.renderPassThroughAttributes(facesContext, component, knownAttributes);
+ }
+
+ public void checkDisabled(Object attributeValue, boolean expectedValue) throws Exception {
+ componentAttributes.put("disabled", attributeValue);
+
+ UIComponent component = createMockComponent();
+ facesEnvironment.replay();
+ assertTrue(expectedValue == RenderKitUtils.isDisabled(component));
+ }
+
+ @Test
+ public void testIsDisabled() throws Exception {
+ checkDisabled(Boolean.TRUE, true);
+ }
+
+ @Test
+ public void testIsDisabledString() throws Exception {
+ checkDisabled("true", true);
+ }
+
+ @Test
+ public void testIsNonDisabled() throws Exception {
+ checkDisabled(Boolean.FALSE, false);
+ }
+
+ @Test
+ public void testIsNonDisabledString() throws Exception {
+ checkDisabled("false", false);
+ }
+
+ @Test
+ public void testIsNonDisabledNull() throws Exception {
+ checkDisabled(null, false);
+ }
+
+ private UIComponent setupTestDecodeBehaviors(String behaviorSourceId, String behaviorEventName) throws Exception {
+ ClientBehaviorHolder behaviorHolder = createMockClientBehaviorHolder();
+ UIComponent component = (UIComponent) behaviorHolder;
+
+ Map<String, String> requestParameterMap = new HashMap<String, String>();
+ requestParameterMap.put(RenderKitUtils.BEHAVIOR_SOURCE_ID, behaviorSourceId);
+ requestParameterMap.put(RenderKitUtils.BEHAVIOR_EVENT_NAME, behaviorEventName);
+ expect(externalContext.getRequestParameterMap()).andStubReturn(requestParameterMap);
+
+ ClientBehavior actionBehavior = createClientBehavior("action1", EnumSet.of(ClientBehaviorHint.SUBMITTING));
+ ClientBehavior actionBehavior1 = createClientBehavior("action2", EnumSet.of(ClientBehaviorHint.SUBMITTING));
+ behaviorsMap.put("action", Arrays.asList(actionBehavior, actionBehavior1));
+
+ ClientBehavior blurBehavior = createClientBehavior("blur1", EnumSet.of(ClientBehaviorHint.SUBMITTING));
+ behaviorsMap.put("blur", Arrays.asList(blurBehavior));
+
+ return component;
+ }
+
+ @Test
+ public void testDecodeActionBehaviors() throws Exception {
+ UIComponent component = setupTestDecodeBehaviors(CLIENT_ID, "action");
+
+ List<ClientBehavior> behaviors = behaviorsMap.get("action");
+ for (ClientBehavior clientBehavior : behaviors) {
+ clientBehavior.decode(same(facesContext), same(component));
+ expectLastCall();
+ }
+
+ facesEnvironment.replay();
+
+ assertEquals("action", RenderKitUtils.decodeBehaviors(facesContext, component));
+ }
+
+ @Test
+ public void testDecodeBlurBehaviors() throws Exception {
+ UIComponent component = setupTestDecodeBehaviors(CLIENT_ID, "blur");
+
+ List<ClientBehavior> behaviors = behaviorsMap.get("blur");
+ for (ClientBehavior clientBehavior : behaviors) {
+ clientBehavior.decode(same(facesContext), same(component));
+ expectLastCall();
+ }
+
+ facesEnvironment.replay();
+
+ assertEquals("blur", RenderKitUtils.decodeBehaviors(facesContext, component));
+ }
+
+ @Test
+ public void testDecodeNonMatchingClientId() throws Exception {
+ UIComponent component = setupTestDecodeBehaviors("wrongId", "action");
+
+ //nothing should be called - clientId is not matched
+
+ facesEnvironment.replay();
+
+ assertNull(RenderKitUtils.decodeBehaviors(facesContext, component));
+ }
+
+ @Test
+ public void testDecodeNoSubmittedBehavior() throws Exception {
+ UIComponent component = setupTestDecodeBehaviors(CLIENT_ID, null);
+
+ //nothing should be called - no behavior event information was submitted
+
+ facesEnvironment.replay();
+
+ assertNull(RenderKitUtils.decodeBehaviors(facesContext, component));
+ }
+
+ @Test
+ public void testDecodeContextMenuBehaviors() throws Exception {
+ UIComponent component = setupTestDecodeBehaviors(CLIENT_ID, "contextmenu");
+
+ //nothing should be called - no context menu behaviors were created
+
+ facesEnvironment.replay();
+
+ assertNull(RenderKitUtils.decodeBehaviors(facesContext, component));
+ }
+}
\ No newline at end of file
Copied: branches/RF-7560/ui/common/ui/src/test/java/org/richfaces/renderkit/RenderKitUtilsTest.java (from rev 19038, branches/RF-7560/core/commons/src/test/java/org/richfaces/renderkit/RenderKitUtilsTest.java)
===================================================================
--- branches/RF-7560/ui/common/ui/src/test/java/org/richfaces/renderkit/RenderKitUtilsTest.java (rev 0)
+++ branches/RF-7560/ui/common/ui/src/test/java/org/richfaces/renderkit/RenderKitUtilsTest.java 2010-08-31 17:20:11 UTC (rev 19052)
@@ -0,0 +1,110 @@
+/*
+ * 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 static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class RenderKitUtilsTest {
+
+ @Test
+ public void testEscape() throws Exception {
+ assertEquals("", RenderKitUtils.escape(""));
+ assertEquals("abcd", RenderKitUtils.escape("abcd"));
+ assertEquals("\\'abcd", RenderKitUtils.escape("'abcd"));
+ assertEquals("abcd\\'", RenderKitUtils.escape("abcd'"));
+ assertEquals("ab\\'cd", RenderKitUtils.escape("ab'cd"));
+ assertEquals("ab\\'\\'cd", RenderKitUtils.escape("ab''cd"));
+ assertEquals("ab\\'c\\'d", RenderKitUtils.escape("ab'c'd"));
+ }
+
+ @Test
+ public void testChain() throws Exception {
+ StringBuilder sb = new StringBuilder();
+
+ assertFalse(RenderKitUtils.chain(sb, "", false));
+ assertTrue(sb.length() == 0);
+ assertFalse(RenderKitUtils.chain(sb, null, false));
+ assertTrue(sb.length() == 0);
+
+ assertFalse(RenderKitUtils.chain(sb, "test", false));
+ assertEquals("test", sb.toString());
+
+ assertFalse(RenderKitUtils.chain(sb, "", false));
+ assertEquals("test", sb.toString());
+
+ assertTrue(RenderKitUtils.chain(sb, "another'object", false));
+ assertEquals("'test','another\\'object'", sb.toString());
+
+ assertTrue(RenderKitUtils.chain(sb, "one more", true));
+ assertEquals("'test','another\\'object','one more'", sb.toString());
+ }
+
+ @Test
+ public void testShouldRenderAttribute() throws Exception {
+ assertFalse(RenderKitUtils.shouldRenderAttribute(null));
+
+ assertFalse(RenderKitUtils.shouldRenderAttribute(""));
+ assertTrue(RenderKitUtils.shouldRenderAttribute("test"));
+
+ assertTrue(RenderKitUtils.shouldRenderAttribute(new Object()));
+
+ assertTrue(RenderKitUtils.shouldRenderAttribute(Long.valueOf(10)));
+ assertTrue(RenderKitUtils.shouldRenderAttribute(Long.valueOf(0)));
+ assertFalse(RenderKitUtils.shouldRenderAttribute(Long.MIN_VALUE));
+
+ assertTrue(RenderKitUtils.shouldRenderAttribute(Integer.valueOf(10)));
+ assertTrue(RenderKitUtils.shouldRenderAttribute(Integer.valueOf(0)));
+ assertFalse(RenderKitUtils.shouldRenderAttribute(Integer.MIN_VALUE));
+
+ assertTrue(RenderKitUtils.shouldRenderAttribute(Short.valueOf((short) 10)));
+ assertTrue(RenderKitUtils.shouldRenderAttribute(Short.valueOf((short) 0)));
+ assertFalse(RenderKitUtils.shouldRenderAttribute(Short.MIN_VALUE));
+
+ assertTrue(RenderKitUtils.shouldRenderAttribute(Character.valueOf('a')));
+ assertTrue(RenderKitUtils.shouldRenderAttribute(Character.valueOf((char) 13)));
+ assertFalse(RenderKitUtils.shouldRenderAttribute(Character.MIN_VALUE));
+
+ assertTrue(RenderKitUtils.shouldRenderAttribute(Byte.valueOf((byte) 10)));
+ assertTrue(RenderKitUtils.shouldRenderAttribute(Byte.valueOf((byte) 0)));
+ assertFalse(RenderKitUtils.shouldRenderAttribute(Byte.MIN_VALUE));
+
+ assertTrue(RenderKitUtils.shouldRenderAttribute(Double.valueOf(10)));
+ assertTrue(RenderKitUtils.shouldRenderAttribute(Double.valueOf(0)));
+ assertFalse(RenderKitUtils.shouldRenderAttribute(Double.MIN_VALUE));
+
+ assertTrue(RenderKitUtils.shouldRenderAttribute(Float.valueOf(10)));
+ assertTrue(RenderKitUtils.shouldRenderAttribute(Float.valueOf(0)));
+ assertFalse(RenderKitUtils.shouldRenderAttribute(Float.MIN_VALUE));
+
+ assertTrue(RenderKitUtils.shouldRenderAttribute(Boolean.TRUE));
+ assertFalse(RenderKitUtils.shouldRenderAttribute(Boolean.FALSE));
+ }
+
+}
\ No newline at end of file
Modified: branches/RF-7560/ui/common/ui/src/test/java/org/richfaces/renderkit/util/FormUtilTest.java
===================================================================
--- branches/RF-7560/ui/common/ui/src/test/java/org/richfaces/renderkit/util/FormUtilTest.java 2010-08-31 16:59:42 UTC (rev 19051)
+++ branches/RF-7560/ui/common/ui/src/test/java/org/richfaces/renderkit/util/FormUtilTest.java 2010-08-31 17:20:11 UTC (rev 19052)
@@ -27,7 +27,6 @@
import javax.faces.component.UIViewRoot;
import org.jboss.test.faces.AbstractFacesTest;
-import org.richfaces.component.EnclosingFormRequiredException;
import org.richfaces.component.SwitchType;
/**
Modified: branches/RF-7560/ui/core/ui/src/main/java/org/richfaces/renderkit/AjaxCommandRendererBase.java
===================================================================
--- branches/RF-7560/ui/core/ui/src/main/java/org/richfaces/renderkit/AjaxCommandRendererBase.java 2010-08-31 16:59:42 UTC (rev 19051)
+++ branches/RF-7560/ui/core/ui/src/main/java/org/richfaces/renderkit/AjaxCommandRendererBase.java 2010-08-31 17:20:11 UTC (rev 19052)
@@ -32,7 +32,6 @@
import javax.faces.event.ActionEvent;
import org.ajax4jsf.renderkit.HandlersChain;
-import org.ajax4jsf.renderkit.RendererBase;
import org.richfaces.log.RichfacesLogger;
import org.richfaces.log.Logger;
Modified: branches/RF-7560/ui/core/ui/src/main/java/org/richfaces/renderkit/LogRendererBase.java
===================================================================
--- branches/RF-7560/ui/core/ui/src/main/java/org/richfaces/renderkit/LogRendererBase.java 2010-08-31 16:59:42 UTC (rev 19051)
+++ branches/RF-7560/ui/core/ui/src/main/java/org/richfaces/renderkit/LogRendererBase.java 2010-08-31 17:20:11 UTC (rev 19052)
@@ -21,7 +21,6 @@
*/
package org.richfaces.renderkit;
-import org.ajax4jsf.renderkit.RendererBase;
import org.richfaces.component.LogMode;
/**
Modified: branches/RF-7560/ui/core/ui/src/main/java/org/richfaces/renderkit/html/AjaxOutputPanelRenderer.java
===================================================================
--- branches/RF-7560/ui/core/ui/src/main/java/org/richfaces/renderkit/html/AjaxOutputPanelRenderer.java 2010-08-31 16:59:42 UTC (rev 19051)
+++ branches/RF-7560/ui/core/ui/src/main/java/org/richfaces/renderkit/html/AjaxOutputPanelRenderer.java 2010-08-31 17:20:11 UTC (rev 19052)
@@ -30,10 +30,10 @@
import javax.faces.context.ResponseWriter;
import org.ajax4jsf.context.AjaxContext;
-import org.ajax4jsf.renderkit.RendererBase;
import org.ajax4jsf.renderkit.RendererUtils.HTML;
import org.richfaces.cdk.annotations.JsfRenderer;
import org.richfaces.component.AbstractOutputPanel;
+import org.richfaces.renderkit.RendererBase;
/**
* @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
Modified: branches/RF-7560/ui/core/ui/src/main/java/org/richfaces/renderkit/html/AjaxPollRenderer.java
===================================================================
--- branches/RF-7560/ui/core/ui/src/main/java/org/richfaces/renderkit/html/AjaxPollRenderer.java 2010-08-31 16:59:42 UTC (rev 19051)
+++ branches/RF-7560/ui/core/ui/src/main/java/org/richfaces/renderkit/html/AjaxPollRenderer.java 2010-08-31 17:20:11 UTC (rev 19052)
@@ -37,10 +37,10 @@
import org.ajax4jsf.javascript.JSFunctionDefinition;
import org.ajax4jsf.javascript.JSReference;
import org.ajax4jsf.renderkit.HandlersChain;
-import org.ajax4jsf.renderkit.RendererBase;
import org.ajax4jsf.renderkit.RendererUtils.HTML;
import org.richfaces.cdk.annotations.JsfRenderer;
import org.richfaces.component.AbstractPoll;
+import org.richfaces.renderkit.RendererBase;
/**
* @author shura
Modified: branches/RF-7560/ui/core/ui/src/main/java/org/richfaces/renderkit/html/AjaxPushRenderer.java
===================================================================
--- branches/RF-7560/ui/core/ui/src/main/java/org/richfaces/renderkit/html/AjaxPushRenderer.java 2010-08-31 16:59:42 UTC (rev 19051)
+++ branches/RF-7560/ui/core/ui/src/main/java/org/richfaces/renderkit/html/AjaxPushRenderer.java 2010-08-31 17:20:11 UTC (rev 19052)
@@ -36,10 +36,10 @@
import org.ajax4jsf.javascript.JSFunctionDefinition;
import org.ajax4jsf.javascript.JSReference;
import org.ajax4jsf.renderkit.HandlersChain;
-import org.ajax4jsf.renderkit.RendererBase;
import org.ajax4jsf.renderkit.RendererUtils.HTML;
import org.richfaces.cdk.annotations.JsfRenderer;
import org.richfaces.component.AbstractPush;
+import org.richfaces.renderkit.RendererBase;
import org.richfaces.resource.PushResource;
/**
Modified: branches/RF-7560/ui/core/ui/src/main/java/org/richfaces/renderkit/html/AjaxStatusRenderer.java
===================================================================
--- branches/RF-7560/ui/core/ui/src/main/java/org/richfaces/renderkit/html/AjaxStatusRenderer.java 2010-08-31 16:59:42 UTC (rev 19051)
+++ branches/RF-7560/ui/core/ui/src/main/java/org/richfaces/renderkit/html/AjaxStatusRenderer.java 2010-08-31 17:20:11 UTC (rev 19052)
@@ -33,13 +33,13 @@
import org.ajax4jsf.javascript.JSFunction;
import org.ajax4jsf.renderkit.HandlersChain;
-import org.ajax4jsf.renderkit.RendererBase;
import org.ajax4jsf.renderkit.RendererUtils;
import org.ajax4jsf.renderkit.RendererUtils.HTML;
import org.ajax4jsf.renderkit.RendererUtils.ScriptHashVariableWrapper;
import org.richfaces.cdk.annotations.JsfRenderer;
import org.richfaces.component.AbstractAjaxStatus;
import org.richfaces.component.util.HtmlUtil;
+import org.richfaces.renderkit.RendererBase;
/**
* @author Nick Belaevski
Modified: branches/RF-7560/ui/core/ui/src/main/java/org/richfaces/renderkit/html/MediaOutputRenderer.java
===================================================================
--- branches/RF-7560/ui/core/ui/src/main/java/org/richfaces/renderkit/html/MediaOutputRenderer.java 2010-08-31 16:59:42 UTC (rev 19051)
+++ branches/RF-7560/ui/core/ui/src/main/java/org/richfaces/renderkit/html/MediaOutputRenderer.java 2010-08-31 17:20:11 UTC (rev 19052)
@@ -34,10 +34,10 @@
import javax.faces.context.ResponseWriter;
import org.ajax4jsf.Messages;
-import org.ajax4jsf.renderkit.RendererBase;
import org.ajax4jsf.renderkit.RendererUtils.HTML;
import org.richfaces.cdk.annotations.JsfRenderer;
import org.richfaces.component.AbstractMediaOutput;
+import org.richfaces.renderkit.RendererBase;
/**
* @author shura
Copied: branches/RF-7560/ui/input/ui/src/main/java/org/richfaces/renderkit/InputRendererBase.java (from rev 19038, branches/RF-7560/core/impl/src/main/java/org/richfaces/renderkit/InputRendererBase.java)
===================================================================
--- branches/RF-7560/ui/input/ui/src/main/java/org/richfaces/renderkit/InputRendererBase.java (rev 0)
+++ branches/RF-7560/ui/input/ui/src/main/java/org/richfaces/renderkit/InputRendererBase.java 2010-08-31 17:20:11 UTC (rev 19052)
@@ -0,0 +1,83 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * 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;
+
+import org.ajax4jsf.util.SelectUtils;
+
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIInput;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+import javax.faces.convert.ConverterException;
+import java.util.Map;
+
+/**
+ * @author Nick Belaevski - nbelaevski(a)exadel.com
+ * created 23.01.2007
+ */
+public class InputRendererBase extends AjaxComponentRendererBase {
+ protected Class getComponentClass() {
+ return UIInput.class;
+ }
+
+ protected void doDecode(FacesContext context, UIComponent component) {
+ String clientId = component.getClientId(context);
+ Map requestParameterMap = context.getExternalContext().getRequestParameterMap();
+ String newValue = (String) requestParameterMap.get(clientId);
+
+ if (null != newValue) {
+ UIInput input = (UIInput) component;
+
+ input.setSubmittedValue(newValue);
+ }
+ }
+
+ public Object getConvertedValue(FacesContext context, UIComponent component, Object val) throws ConverterException {
+ return SelectUtils.getConvertedUIInputValue(context, (UIInput) component, (String) val);
+ }
+
+ public String getInputValue(FacesContext context, UIComponent component) {
+ UIInput input = (UIInput) component;
+ String value = (String) input.getSubmittedValue();
+
+ if (value == null) {
+ Object curVal = input.getValue();
+ Converter converter = SelectUtils.getConverterForProperty(context, input, "value");
+
+ if (converter != null) {
+ value = converter.getAsString(context, input, curVal);
+ } else {
+ if (curVal == null) {
+ value = "";
+ } else {
+ value = curVal.toString();
+ }
+ }
+ }
+
+ if (value == null) {
+ value = "";
+ }
+
+ return value;
+ }
+}
Modified: branches/RF-7560/ui/iteration/ui/src/main/java/org/richfaces/renderkit/AbstractRowsRenderer.java
===================================================================
--- branches/RF-7560/ui/iteration/ui/src/main/java/org/richfaces/renderkit/AbstractRowsRenderer.java 2010-08-31 16:59:42 UTC (rev 19051)
+++ branches/RF-7560/ui/iteration/ui/src/main/java/org/richfaces/renderkit/AbstractRowsRenderer.java 2010-08-31 17:20:11 UTC (rev 19052)
@@ -33,7 +33,6 @@
import org.ajax4jsf.model.DataVisitResult;
import org.ajax4jsf.model.DataVisitor;
-import org.ajax4jsf.renderkit.RendererBase;
import org.richfaces.component.Row;
/**
Modified: branches/RF-7560/ui/iteration/ui/src/main/java/org/richfaces/renderkit/DataScrollerBaseRenderer.java
===================================================================
--- branches/RF-7560/ui/iteration/ui/src/main/java/org/richfaces/renderkit/DataScrollerBaseRenderer.java 2010-08-31 16:59:42 UTC (rev 19051)
+++ branches/RF-7560/ui/iteration/ui/src/main/java/org/richfaces/renderkit/DataScrollerBaseRenderer.java 2010-08-31 17:20:11 UTC (rev 19052)
@@ -39,7 +39,6 @@
import org.ajax4jsf.javascript.JSReference;
import org.ajax4jsf.renderkit.AjaxEventOptions;
import org.ajax4jsf.renderkit.AjaxRendererUtils;
-import org.ajax4jsf.renderkit.RendererBase;
import org.ajax4jsf.renderkit.RendererUtils.HTML;
import org.richfaces.component.AbstractDataScroller;
import org.richfaces.event.DataScrollerEvent;
Modified: branches/RF-7560/ui/iteration/ui/src/main/java/org/richfaces/renderkit/SubTableToggleControlRendererBase.java
===================================================================
--- branches/RF-7560/ui/iteration/ui/src/main/java/org/richfaces/renderkit/SubTableToggleControlRendererBase.java 2010-08-31 16:59:42 UTC (rev 19051)
+++ branches/RF-7560/ui/iteration/ui/src/main/java/org/richfaces/renderkit/SubTableToggleControlRendererBase.java 2010-08-31 17:20:11 UTC (rev 19052)
@@ -33,7 +33,6 @@
import javax.faces.context.ResponseWriter;
import org.ajax4jsf.javascript.JSFunction;
-import org.ajax4jsf.renderkit.RendererBase;
import org.ajax4jsf.renderkit.RendererUtils.HTML;
import org.richfaces.cdk.annotations.JsfRenderer;
import org.richfaces.component.AbstractSubTable;
Modified: branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/renderkit/html/DivPanelRenderer.java
===================================================================
--- branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/renderkit/html/DivPanelRenderer.java 2010-08-31 16:59:42 UTC (rev 19051)
+++ branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/renderkit/html/DivPanelRenderer.java 2010-08-31 17:20:11 UTC (rev 19052)
@@ -22,10 +22,10 @@
package org.richfaces.renderkit.html;
-import org.ajax4jsf.renderkit.RendererBase;
import org.ajax4jsf.renderkit.RendererUtils.HTML;
import org.richfaces.component.AbstractDivPanel;
import org.richfaces.renderkit.RenderKitUtils;
+import org.richfaces.renderkit.RendererBase;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
Modified: branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/renderkit/html/PanelBaseRenderer.java
===================================================================
--- branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/renderkit/html/PanelBaseRenderer.java 2010-08-31 16:59:42 UTC (rev 19051)
+++ branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/renderkit/html/PanelBaseRenderer.java 2010-08-31 17:20:11 UTC (rev 19052)
@@ -27,8 +27,8 @@
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
-import org.ajax4jsf.renderkit.RendererBase;
import org.richfaces.component.UIPanel;
+import org.richfaces.renderkit.RendererBase;
/**
* @author amarkhel
Modified: branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/renderkit/html/PopupPanelBaseRenderer.java
===================================================================
--- branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/renderkit/html/PopupPanelBaseRenderer.java 2010-08-31 16:59:42 UTC (rev 19051)
+++ branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/renderkit/html/PopupPanelBaseRenderer.java 2010-08-31 17:20:11 UTC (rev 19052)
@@ -16,11 +16,11 @@
import javax.faces.context.FacesContext;
import org.ajax4jsf.javascript.ScriptUtils;
-import org.ajax4jsf.renderkit.RendererBase;
import org.ajax4jsf.renderkit.RendererUtils;
import org.richfaces.component.AbstractPopupPanel;
import org.richfaces.json.JSONException;
import org.richfaces.json.JSONMap;
+import org.richfaces.renderkit.RendererBase;
//TODO nick - JSF have concept of library, it should be used instead of '/' in resource names
@ResourceDependencies( { @ResourceDependency(name = "jquery.js"), @ResourceDependency(name = "richfaces.js"),
14 years, 3 months
JBoss Rich Faces SVN: r19051 - in modules/docs/trunk: Component_Development_Kit_Guide and 4 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: jbalunas(a)redhat.com
Date: 2010-08-31 12:59:42 -0400 (Tue, 31 Aug 2010)
New Revision: 19051
Modified:
modules/docs/trunk/Component_Development_Kit_Guide/pom.xml
modules/docs/trunk/Component_Reference/pom.xml
modules/docs/trunk/Developer_Guide/pom.xml
modules/docs/trunk/Migration_Guide/pom.xml
modules/docs/trunk/parent/pom.xml
modules/docs/trunk/pom.xml
Log:
[maven-release-plugin] prepare for next development iteration
Modified: modules/docs/trunk/Component_Development_Kit_Guide/pom.xml
===================================================================
--- modules/docs/trunk/Component_Development_Kit_Guide/pom.xml 2010-08-31 16:59:33 UTC (rev 19050)
+++ modules/docs/trunk/Component_Development_Kit_Guide/pom.xml 2010-08-31 16:59:42 UTC (rev 19051)
@@ -4,14 +4,14 @@
<groupId>org.richfaces.docs</groupId>
<artifactId>richfaces-cdk-guide</artifactId>
- <version>4.0.0.20100831-M2</version>
+ <version>4.0.0-SNAPSHOT</version>
<packaging>jdocbook</packaging>
<name>RichFaces CDK Guide</name>
<parent>
<groupId>org.richfaces.docs</groupId>
<artifactId>docs-parent</artifactId>
- <version>4.0.0.20100831-M2</version>
+ <version>4.0.0-SNAPSHOT</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
@@ -106,9 +106,9 @@
</profiles>
<scm>
- <connection>scm:svn:http://anonsvn.jboss.org/repos/richfaces/modules/docs/tags/4.0.0....</connection>
- <developerConnection>scm:svn:https://svn.jboss.org/repos/richfaces/modules/docs/tags/4.0.0.201...</developerConnection>
- <url>http://fisheye.jboss.org/browse/richfaces/modules/docs/tags/4.0.0.2010083...</url>
+ <connection>scm:svn:http://anonsvn.jboss.org/repos/richfaces/modules/docs/trunk/Compo...</connection>
+ <developerConnection>scm:svn:https://svn.jboss.org/repos/richfaces/modules/docs/trunk/Componen...</developerConnection>
+ <url>http://fisheye.jboss.org/browse/richfaces/modules/docs/trunk/Component_De...</url>
</scm>
</project>
Modified: modules/docs/trunk/Component_Reference/pom.xml
===================================================================
--- modules/docs/trunk/Component_Reference/pom.xml 2010-08-31 16:59:33 UTC (rev 19050)
+++ modules/docs/trunk/Component_Reference/pom.xml 2010-08-31 16:59:42 UTC (rev 19051)
@@ -4,14 +4,14 @@
<groupId>org.richfaces.docs</groupId>
<artifactId>richfaces-component-reference</artifactId>
- <version>4.0.0.20100831-M2</version>
+ <version>4.0.0-SNAPSHOT</version>
<packaging>jdocbook</packaging>
<name>RichFaces Component Reference</name>
<parent>
<groupId>org.richfaces.docs</groupId>
<artifactId>docs-parent</artifactId>
- <version>4.0.0.20100831-M2</version>
+ <version>4.0.0-SNAPSHOT</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
@@ -106,9 +106,9 @@
</profiles>
<scm>
- <connection>scm:svn:http://anonsvn.jboss.org/repos/richfaces/modules/docs/tags/4.0.0....</connection>
- <developerConnection>scm:svn:https://svn.jboss.org/repos/richfaces/modules/docs/tags/4.0.0.201...</developerConnection>
- <url>http://fisheye.jboss.org/browse/richfaces/modules/docs/tags/4.0.0.2010083...</url>
+ <connection>scm:svn:http://anonsvn.jboss.org/repos/richfaces/modules/docs/trunk/Compo...</connection>
+ <developerConnection>scm:svn:https://svn.jboss.org/repos/richfaces/modules/docs/trunk/Componen...</developerConnection>
+ <url>http://fisheye.jboss.org/browse/richfaces/modules/docs/trunk/Component_Re...</url>
</scm>
</project>
Modified: modules/docs/trunk/Developer_Guide/pom.xml
===================================================================
--- modules/docs/trunk/Developer_Guide/pom.xml 2010-08-31 16:59:33 UTC (rev 19050)
+++ modules/docs/trunk/Developer_Guide/pom.xml 2010-08-31 16:59:42 UTC (rev 19051)
@@ -4,14 +4,14 @@
<groupId>org.richfaces.docs</groupId>
<artifactId>richfaces-developer-guide</artifactId>
- <version>4.0.0.20100831-M2</version>
+ <version>4.0.0-SNAPSHOT</version>
<packaging>jdocbook</packaging>
<name>RichFaces Developer Guide</name>
<parent>
<groupId>org.richfaces.docs</groupId>
<artifactId>docs-parent</artifactId>
- <version>4.0.0.20100831-M2</version>
+ <version>4.0.0-SNAPSHOT</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
@@ -107,9 +107,9 @@
</profiles>
<scm>
- <connection>scm:svn:http://anonsvn.jboss.org/repos/richfaces/modules/docs/tags/4.0.0....</connection>
- <developerConnection>scm:svn:https://svn.jboss.org/repos/richfaces/modules/docs/tags/4.0.0.201...</developerConnection>
- <url>http://fisheye.jboss.org/browse/richfaces/modules/docs/tags/4.0.0.2010083...</url>
+ <connection>scm:svn:http://anonsvn.jboss.org/repos/richfaces/modules/docs/trunk/Devel...</connection>
+ <developerConnection>scm:svn:https://svn.jboss.org/repos/richfaces/modules/docs/trunk/Develope...</developerConnection>
+ <url>http://fisheye.jboss.org/browse/richfaces/modules/docs/trunk/Developer_Gu...</url>
</scm>
</project>
Modified: modules/docs/trunk/Migration_Guide/pom.xml
===================================================================
--- modules/docs/trunk/Migration_Guide/pom.xml 2010-08-31 16:59:33 UTC (rev 19050)
+++ modules/docs/trunk/Migration_Guide/pom.xml 2010-08-31 16:59:42 UTC (rev 19051)
@@ -4,14 +4,14 @@
<groupId>org.richfaces.docs</groupId>
<artifactId>richfaces-migration-guide</artifactId>
- <version>4.0.0.20100831-M2</version>
+ <version>4.0.0-SNAPSHOT</version>
<packaging>jdocbook</packaging>
<name>RichFaces Migration Guide</name>
<parent>
<groupId>org.richfaces.docs</groupId>
<artifactId>docs-parent</artifactId>
- <version>4.0.0.20100831-M2</version>
+ <version>4.0.0-SNAPSHOT</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
@@ -107,9 +107,9 @@
</profiles>
<scm>
- <connection>scm:svn:http://anonsvn.jboss.org/repos/richfaces/modules/docs/tags/4.0.0....</connection>
- <developerConnection>scm:svn:https://svn.jboss.org/repos/richfaces/modules/docs/tags/4.0.0.201...</developerConnection>
- <url>http://fisheye.jboss.org/browse/richfaces/modules/docs/tags/4.0.0.2010083...</url>
+ <connection>scm:svn:http://anonsvn.jboss.org/repos/richfaces/modules/docs/trunk/Migra...</connection>
+ <developerConnection>scm:svn:https://svn.jboss.org/repos/richfaces/modules/docs/trunk/Migratio...</developerConnection>
+ <url>http://fisheye.jboss.org/browse/richfaces/modules/docs/trunk/Migration_Guide</url>
</scm>
</project>
Modified: modules/docs/trunk/parent/pom.xml
===================================================================
--- modules/docs/trunk/parent/pom.xml 2010-08-31 16:59:33 UTC (rev 19050)
+++ modules/docs/trunk/parent/pom.xml 2010-08-31 16:59:42 UTC (rev 19051)
@@ -28,7 +28,7 @@
<groupId>org.richfaces.docs</groupId>
<artifactId>docs-parent</artifactId>
- <version>4.0.0.20100831-M2</version>
+ <version>4.0.0-SNAPSHOT</version>
<name>Richfaces Docs: Parent</name>
<packaging>pom</packaging>
<url>http://richfaces.org</url>
@@ -218,8 +218,8 @@
-->
<scm>
- <connection>scm:svn:http://anonsvn.jboss.org/repos/richfaces/modules/docs/tags/4.0.0....</connection>
- <developerConnection>scm:svn:https://svn.jboss.org/repos/richfaces/modules/docs/tags/4.0.0.201...</developerConnection>
- <url>http://fisheye.jboss.org/browse/richfaces/modules/docs/tags/4.0.0.2010083...</url>
+ <connection>scm:svn:http://anonsvn.jboss.org/repos/richfaces/modules/docs/trunk/parent</connection>
+ <developerConnection>scm:svn:https://svn.jboss.org/repos/richfaces/modules/docs/trunk/parent</developerConnection>
+ <url>http://fisheye.jboss.org/browse/richfaces/modules/docs/trunk/parent</url>
</scm>
</project>
Modified: modules/docs/trunk/pom.xml
===================================================================
--- modules/docs/trunk/pom.xml 2010-08-31 16:59:33 UTC (rev 19050)
+++ modules/docs/trunk/pom.xml 2010-08-31 16:59:42 UTC (rev 19051)
@@ -9,7 +9,7 @@
<groupId>org.richfaces.docs</groupId>
<artifactId>docs-aggregator</artifactId>
- <version>4.0.0.20100831-M2</version>
+ <version>4.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>RichFaces Document Aggregator</name>
@@ -22,9 +22,9 @@
</modules>
<scm>
- <connection>scm:svn:http://anonsvn.jboss.org/repos/richfaces/modules/docs/tags/4.0.0....</connection>
- <developerConnection>scm:svn:https://svn.jboss.org/repos/richfaces/modules/docs/tags/4.0.0.201...</developerConnection>
- <url>http://fisheye.jboss.org/browse/richfaces/modules/doc/tags/4.0.0.20100831-M2</url>
+ <connection>scm:svn:http://anonsvn.jboss.org/repos/richfaces/modules/docs/trunk</connection>
+ <developerConnection>scm:svn:https://svn.jboss.org/repos/richfaces/modules/docs/trunk</developerConnection>
+ <url>http://fisheye.jboss.org/browse/richfaces/modules/doc/trunk/</url>
</scm>
</project>
14 years, 3 months
JBoss Rich Faces SVN: r19050 - modules/docs/tags.
by richfaces-svn-commits@lists.jboss.org
Author: jbalunas(a)redhat.com
Date: 2010-08-31 12:59:33 -0400 (Tue, 31 Aug 2010)
New Revision: 19050
Added:
modules/docs/tags/4.0.0.20100831-M2/
Log:
[maven-scm] copy for tag 4.0.0.20100831-M2
Copied: modules/docs/tags/4.0.0.20100831-M2 (from rev 19049, modules/docs/trunk)
14 years, 3 months
JBoss Rich Faces SVN: r19049 - in modules/docs/trunk: Component_Development_Kit_Guide and 4 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: jbalunas(a)redhat.com
Date: 2010-08-31 12:59:19 -0400 (Tue, 31 Aug 2010)
New Revision: 19049
Modified:
modules/docs/trunk/Component_Development_Kit_Guide/pom.xml
modules/docs/trunk/Component_Reference/pom.xml
modules/docs/trunk/Developer_Guide/pom.xml
modules/docs/trunk/Migration_Guide/pom.xml
modules/docs/trunk/parent/pom.xml
modules/docs/trunk/pom.xml
Log:
[maven-release-plugin] prepare release 4.0.0.20100831-M2
Modified: modules/docs/trunk/Component_Development_Kit_Guide/pom.xml
===================================================================
--- modules/docs/trunk/Component_Development_Kit_Guide/pom.xml 2010-08-31 16:57:07 UTC (rev 19048)
+++ modules/docs/trunk/Component_Development_Kit_Guide/pom.xml 2010-08-31 16:59:19 UTC (rev 19049)
@@ -4,14 +4,14 @@
<groupId>org.richfaces.docs</groupId>
<artifactId>richfaces-cdk-guide</artifactId>
- <version>4.0.0-SNAPSHOT</version>
+ <version>4.0.0.20100831-M2</version>
<packaging>jdocbook</packaging>
<name>RichFaces CDK Guide</name>
<parent>
<groupId>org.richfaces.docs</groupId>
<artifactId>docs-parent</artifactId>
- <version>4.0.0-SNAPSHOT</version>
+ <version>4.0.0.20100831-M2</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
@@ -106,9 +106,9 @@
</profiles>
<scm>
- <connection>scm:svn:http://anonsvn.jboss.org/repos/richfaces/modules/docs/trunk/Compo...</connection>
- <developerConnection>scm:svn:https://svn.jboss.org/repos/richfaces/modules/docs/trunk/Componen...</developerConnection>
- <url>http://fisheye.jboss.org/browse/richfaces/modules/docs/trunk/Component_De...</url>
+ <connection>scm:svn:http://anonsvn.jboss.org/repos/richfaces/modules/docs/tags/4.0.0....</connection>
+ <developerConnection>scm:svn:https://svn.jboss.org/repos/richfaces/modules/docs/tags/4.0.0.201...</developerConnection>
+ <url>http://fisheye.jboss.org/browse/richfaces/modules/docs/tags/4.0.0.2010083...</url>
</scm>
</project>
Modified: modules/docs/trunk/Component_Reference/pom.xml
===================================================================
--- modules/docs/trunk/Component_Reference/pom.xml 2010-08-31 16:57:07 UTC (rev 19048)
+++ modules/docs/trunk/Component_Reference/pom.xml 2010-08-31 16:59:19 UTC (rev 19049)
@@ -4,14 +4,14 @@
<groupId>org.richfaces.docs</groupId>
<artifactId>richfaces-component-reference</artifactId>
- <version>4.0.0-SNAPSHOT</version>
+ <version>4.0.0.20100831-M2</version>
<packaging>jdocbook</packaging>
<name>RichFaces Component Reference</name>
<parent>
<groupId>org.richfaces.docs</groupId>
<artifactId>docs-parent</artifactId>
- <version>4.0.0-SNAPSHOT</version>
+ <version>4.0.0.20100831-M2</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
@@ -106,9 +106,9 @@
</profiles>
<scm>
- <connection>scm:svn:http://anonsvn.jboss.org/repos/richfaces/modules/docs/trunk/Compo...</connection>
- <developerConnection>scm:svn:https://svn.jboss.org/repos/richfaces/modules/docs/trunk/Componen...</developerConnection>
- <url>http://fisheye.jboss.org/browse/richfaces/modules/docs/trunk/Component_Re...</url>
+ <connection>scm:svn:http://anonsvn.jboss.org/repos/richfaces/modules/docs/tags/4.0.0....</connection>
+ <developerConnection>scm:svn:https://svn.jboss.org/repos/richfaces/modules/docs/tags/4.0.0.201...</developerConnection>
+ <url>http://fisheye.jboss.org/browse/richfaces/modules/docs/tags/4.0.0.2010083...</url>
</scm>
</project>
Modified: modules/docs/trunk/Developer_Guide/pom.xml
===================================================================
--- modules/docs/trunk/Developer_Guide/pom.xml 2010-08-31 16:57:07 UTC (rev 19048)
+++ modules/docs/trunk/Developer_Guide/pom.xml 2010-08-31 16:59:19 UTC (rev 19049)
@@ -4,14 +4,14 @@
<groupId>org.richfaces.docs</groupId>
<artifactId>richfaces-developer-guide</artifactId>
- <version>4.0.0-SNAPSHOT</version>
+ <version>4.0.0.20100831-M2</version>
<packaging>jdocbook</packaging>
<name>RichFaces Developer Guide</name>
<parent>
<groupId>org.richfaces.docs</groupId>
<artifactId>docs-parent</artifactId>
- <version>4.0.0-SNAPSHOT</version>
+ <version>4.0.0.20100831-M2</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
@@ -107,9 +107,9 @@
</profiles>
<scm>
- <connection>scm:svn:http://anonsvn.jboss.org/repos/richfaces/modules/docs/trunk/Devel...</connection>
- <developerConnection>scm:svn:https://svn.jboss.org/repos/richfaces/modules/docs/trunk/Develope...</developerConnection>
- <url>http://fisheye.jboss.org/browse/richfaces/modules/docs/trunk/Developer_Gu...</url>
+ <connection>scm:svn:http://anonsvn.jboss.org/repos/richfaces/modules/docs/tags/4.0.0....</connection>
+ <developerConnection>scm:svn:https://svn.jboss.org/repos/richfaces/modules/docs/tags/4.0.0.201...</developerConnection>
+ <url>http://fisheye.jboss.org/browse/richfaces/modules/docs/tags/4.0.0.2010083...</url>
</scm>
</project>
Modified: modules/docs/trunk/Migration_Guide/pom.xml
===================================================================
--- modules/docs/trunk/Migration_Guide/pom.xml 2010-08-31 16:57:07 UTC (rev 19048)
+++ modules/docs/trunk/Migration_Guide/pom.xml 2010-08-31 16:59:19 UTC (rev 19049)
@@ -4,14 +4,14 @@
<groupId>org.richfaces.docs</groupId>
<artifactId>richfaces-migration-guide</artifactId>
- <version>4.0.0-SNAPSHOT</version>
+ <version>4.0.0.20100831-M2</version>
<packaging>jdocbook</packaging>
<name>RichFaces Migration Guide</name>
<parent>
<groupId>org.richfaces.docs</groupId>
<artifactId>docs-parent</artifactId>
- <version>4.0.0-SNAPSHOT</version>
+ <version>4.0.0.20100831-M2</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
@@ -107,9 +107,9 @@
</profiles>
<scm>
- <connection>scm:svn:http://anonsvn.jboss.org/repos/richfaces/modules/docs/trunk/Migra...</connection>
- <developerConnection>scm:svn:https://svn.jboss.org/repos/richfaces/modules/docs/trunk/Migratio...</developerConnection>
- <url>http://fisheye.jboss.org/browse/richfaces/modules/docs/trunk/Migration_Guide</url>
+ <connection>scm:svn:http://anonsvn.jboss.org/repos/richfaces/modules/docs/tags/4.0.0....</connection>
+ <developerConnection>scm:svn:https://svn.jboss.org/repos/richfaces/modules/docs/tags/4.0.0.201...</developerConnection>
+ <url>http://fisheye.jboss.org/browse/richfaces/modules/docs/tags/4.0.0.2010083...</url>
</scm>
</project>
Modified: modules/docs/trunk/parent/pom.xml
===================================================================
--- modules/docs/trunk/parent/pom.xml 2010-08-31 16:57:07 UTC (rev 19048)
+++ modules/docs/trunk/parent/pom.xml 2010-08-31 16:59:19 UTC (rev 19049)
@@ -28,7 +28,7 @@
<groupId>org.richfaces.docs</groupId>
<artifactId>docs-parent</artifactId>
- <version>4.0.0-SNAPSHOT</version>
+ <version>4.0.0.20100831-M2</version>
<name>Richfaces Docs: Parent</name>
<packaging>pom</packaging>
<url>http://richfaces.org</url>
@@ -218,8 +218,8 @@
-->
<scm>
- <connection>scm:svn:http://anonsvn.jboss.org/repos/richfaces/modules/docs/trunk/parent</connection>
- <developerConnection>scm:svn:https://svn.jboss.org/repos/richfaces/modules/docs/trunk/parent</developerConnection>
- <url>http://fisheye.jboss.org/browse/richfaces/modules/docs/trunk/parent</url>
+ <connection>scm:svn:http://anonsvn.jboss.org/repos/richfaces/modules/docs/tags/4.0.0....</connection>
+ <developerConnection>scm:svn:https://svn.jboss.org/repos/richfaces/modules/docs/tags/4.0.0.201...</developerConnection>
+ <url>http://fisheye.jboss.org/browse/richfaces/modules/docs/tags/4.0.0.2010083...</url>
</scm>
</project>
Modified: modules/docs/trunk/pom.xml
===================================================================
--- modules/docs/trunk/pom.xml 2010-08-31 16:57:07 UTC (rev 19048)
+++ modules/docs/trunk/pom.xml 2010-08-31 16:59:19 UTC (rev 19049)
@@ -9,7 +9,7 @@
<groupId>org.richfaces.docs</groupId>
<artifactId>docs-aggregator</artifactId>
- <version>4.0.0-SNAPSHOT</version>
+ <version>4.0.0.20100831-M2</version>
<packaging>pom</packaging>
<name>RichFaces Document Aggregator</name>
@@ -22,9 +22,9 @@
</modules>
<scm>
- <connection>scm:svn:http://anonsvn.jboss.org/repos/richfaces/modules/docs/trunk</connection>
- <developerConnection>scm:svn:https://svn.jboss.org/repos/richfaces/modules/docs/trunk</developerConnection>
- <url>http://fisheye.jboss.org/browse/richfaces/modules/doc/trunk/</url>
+ <connection>scm:svn:http://anonsvn.jboss.org/repos/richfaces/modules/docs/tags/4.0.0....</connection>
+ <developerConnection>scm:svn:https://svn.jboss.org/repos/richfaces/modules/docs/tags/4.0.0.201...</developerConnection>
+ <url>http://fisheye.jboss.org/browse/richfaces/modules/doc/tags/4.0.0.20100831-M2</url>
</scm>
</project>
14 years, 3 months
JBoss Rich Faces SVN: r19048 - in modules/docs/trunk: Component_Development_Kit_Guide and 4 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: jbalunas(a)redhat.com
Date: 2010-08-31 12:57:07 -0400 (Tue, 31 Aug 2010)
New Revision: 19048
Removed:
modules/docs/trunk/trunk/
Modified:
modules/docs/trunk/Component_Development_Kit_Guide/pom.xml
modules/docs/trunk/Component_Reference/pom.xml
modules/docs/trunk/Developer_Guide/pom.xml
modules/docs/trunk/Migration_Guide/pom.xml
modules/docs/trunk/parent/pom.xml
modules/docs/trunk/pom.xml
Log:
Updated for document release
Modified: modules/docs/trunk/Component_Development_Kit_Guide/pom.xml
===================================================================
--- modules/docs/trunk/Component_Development_Kit_Guide/pom.xml 2010-08-31 16:37:21 UTC (rev 19047)
+++ modules/docs/trunk/Component_Development_Kit_Guide/pom.xml 2010-08-31 16:57:07 UTC (rev 19048)
@@ -2,12 +2,11 @@
<modelVersion>4.0.0</modelVersion>
- <groupId>org.richfaces.cdk-guide</groupId>
+ <groupId>org.richfaces.docs</groupId>
<artifactId>richfaces-cdk-guide</artifactId>
<version>4.0.0-SNAPSHOT</version>
<packaging>jdocbook</packaging>
<name>RichFaces CDK Guide</name>
- <url>http://www.jboss.org/richfaces</url>
<parent>
<groupId>org.richfaces.docs</groupId>
@@ -107,9 +106,9 @@
</profiles>
<scm>
- <connection>scm:svn:http://anonsvn.jboss.org/repos/richfaces/trunk/cdk/docs/guide</connection>
- <developerConnection>scm:svn:https://svn.jboss.org/repos/richfaces/trunk/cdk/docs/guide</developerConnection>
- <url>http://fisheye.jboss.org/browse/richfaces/</url>
+ <connection>scm:svn:http://anonsvn.jboss.org/repos/richfaces/modules/docs/trunk/Compo...</connection>
+ <developerConnection>scm:svn:https://svn.jboss.org/repos/richfaces/modules/docs/trunk/Componen...</developerConnection>
+ <url>http://fisheye.jboss.org/browse/richfaces/modules/docs/trunk/Component_De...</url>
</scm>
</project>
Modified: modules/docs/trunk/Component_Reference/pom.xml
===================================================================
--- modules/docs/trunk/Component_Reference/pom.xml 2010-08-31 16:37:21 UTC (rev 19047)
+++ modules/docs/trunk/Component_Reference/pom.xml 2010-08-31 16:57:07 UTC (rev 19048)
@@ -7,7 +7,6 @@
<version>4.0.0-SNAPSHOT</version>
<packaging>jdocbook</packaging>
<name>RichFaces Component Reference</name>
- <url>http://www.jboss.org/richfaces</url>
<parent>
<groupId>org.richfaces.docs</groupId>
@@ -107,9 +106,9 @@
</profiles>
<scm>
- <connection>scm:svn:http://anonsvn.jboss.org/repos/richfaces/trunk/docs/Component_Ref...</connection>
- <developerConnection>scm:svn:https://svn.jboss.org/repos/richfaces/trunk/docs/Component_Reference</developerConnection>
- <url>http://fisheye.jboss.org/browse/richfaces/trunk/</url>
+ <connection>scm:svn:http://anonsvn.jboss.org/repos/richfaces/modules/docs/trunk/Compo...</connection>
+ <developerConnection>scm:svn:https://svn.jboss.org/repos/richfaces/modules/docs/trunk/Componen...</developerConnection>
+ <url>http://fisheye.jboss.org/browse/richfaces/modules/docs/trunk/Component_Re...</url>
</scm>
</project>
Modified: modules/docs/trunk/Developer_Guide/pom.xml
===================================================================
--- modules/docs/trunk/Developer_Guide/pom.xml 2010-08-31 16:37:21 UTC (rev 19047)
+++ modules/docs/trunk/Developer_Guide/pom.xml 2010-08-31 16:57:07 UTC (rev 19048)
@@ -7,7 +7,6 @@
<version>4.0.0-SNAPSHOT</version>
<packaging>jdocbook</packaging>
<name>RichFaces Developer Guide</name>
- <url>http://www.jboss.org/richfaces</url>
<parent>
<groupId>org.richfaces.docs</groupId>
@@ -108,9 +107,9 @@
</profiles>
<scm>
- <connection>scm:svn:http://anonsvn.jboss.org/repos/richfaces/trunk/docs/Developer_Guide</connection>
- <developerConnection>scm:svn:https://svn.jboss.org/repos/richfaces/trunk/docs/Developer_Guide</developerConnection>
- <url>http://fisheye.jboss.org/browse/richfaces/trunk/</url>
+ <connection>scm:svn:http://anonsvn.jboss.org/repos/richfaces/modules/docs/trunk/Devel...</connection>
+ <developerConnection>scm:svn:https://svn.jboss.org/repos/richfaces/modules/docs/trunk/Develope...</developerConnection>
+ <url>http://fisheye.jboss.org/browse/richfaces/modules/docs/trunk/Developer_Gu...</url>
</scm>
</project>
Modified: modules/docs/trunk/Migration_Guide/pom.xml
===================================================================
--- modules/docs/trunk/Migration_Guide/pom.xml 2010-08-31 16:37:21 UTC (rev 19047)
+++ modules/docs/trunk/Migration_Guide/pom.xml 2010-08-31 16:57:07 UTC (rev 19048)
@@ -7,7 +7,6 @@
<version>4.0.0-SNAPSHOT</version>
<packaging>jdocbook</packaging>
<name>RichFaces Migration Guide</name>
- <url>http://www.jboss.org/richfaces</url>
<parent>
<groupId>org.richfaces.docs</groupId>
@@ -108,9 +107,9 @@
</profiles>
<scm>
- <connection>scm:svn:http://anonsvn.jboss.org/repos/richfaces/trunk/docs/Migration_Guide</connection>
- <developerConnection>scm:svn:https://svn.jboss.org/repos/richfaces/trunk/docs/Migration_Guide</developerConnection>
- <url>http://fisheye.jboss.org/browse/richfaces/trunk/</url>
+ <connection>scm:svn:http://anonsvn.jboss.org/repos/richfaces/modules/docs/trunk/Migra...</connection>
+ <developerConnection>scm:svn:https://svn.jboss.org/repos/richfaces/modules/docs/trunk/Migratio...</developerConnection>
+ <url>http://fisheye.jboss.org/browse/richfaces/modules/docs/trunk/Migration_Guide</url>
</scm>
</project>
Modified: modules/docs/trunk/parent/pom.xml
===================================================================
--- modules/docs/trunk/parent/pom.xml 2010-08-31 16:37:21 UTC (rev 19047)
+++ modules/docs/trunk/parent/pom.xml 2010-08-31 16:57:07 UTC (rev 19048)
@@ -23,7 +23,7 @@
<parent>
<groupId>org.richfaces</groupId>
<artifactId>richfaces-parent</artifactId>
- <version>9</version>
+ <version>10</version>
</parent>
<groupId>org.richfaces.docs</groupId>
@@ -31,6 +31,7 @@
<version>4.0.0-SNAPSHOT</version>
<name>Richfaces Docs: Parent</name>
<packaging>pom</packaging>
+ <url>http://richfaces.org</url>
<build>
<pluginManagement>
@@ -217,8 +218,8 @@
-->
<scm>
- <connection>scm:svn:http://anonsvn.jboss.org/repos/richfaces/trunk/docs/parent</connection>
- <developerConnection>scm:svn:https://svn.jboss.org/repos/richfaces/trunk/docs/parent</developerConnection>
- <url>http://fisheye.jboss.org/browse/richfaces/trunk/</url>
+ <connection>scm:svn:http://anonsvn.jboss.org/repos/richfaces/modules/docs/trunk/parent</connection>
+ <developerConnection>scm:svn:https://svn.jboss.org/repos/richfaces/modules/docs/trunk/parent</developerConnection>
+ <url>http://fisheye.jboss.org/browse/richfaces/modules/docs/trunk/parent</url>
</scm>
</project>
Modified: modules/docs/trunk/pom.xml
===================================================================
--- modules/docs/trunk/pom.xml 2010-08-31 16:37:21 UTC (rev 19047)
+++ modules/docs/trunk/pom.xml 2010-08-31 16:57:07 UTC (rev 19048)
@@ -4,7 +4,7 @@
<parent>
<groupId>org.richfaces</groupId>
<artifactId>richfaces-parent</artifactId>
- <version>9</version>
+ <version>10</version>
</parent>
<groupId>org.richfaces.docs</groupId>
@@ -22,9 +22,9 @@
</modules>
<scm>
- <connection>scm:svn:http://anonsvn.jboss.org/repos/richfaces/trunk/root/docs</connection>
- <developerConnection>scm:svn:https://svn.jboss.org/repos/richfaces/trunk/root/docs</developerConnection>
- <url>http://fisheye.jboss.org/browse/richfaces/trunk/</url>
+ <connection>scm:svn:http://anonsvn.jboss.org/repos/richfaces/modules/docs/trunk</connection>
+ <developerConnection>scm:svn:https://svn.jboss.org/repos/richfaces/modules/docs/trunk</developerConnection>
+ <url>http://fisheye.jboss.org/browse/richfaces/modules/doc/trunk/</url>
</scm>
</project>
14 years, 3 months
JBoss Rich Faces SVN: r19047 - in modules/docs/trunk: Component_Development_Kit_Guide and 4 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: jbalunas(a)redhat.com
Date: 2010-08-31 12:37:21 -0400 (Tue, 31 Aug 2010)
New Revision: 19047
Modified:
modules/docs/trunk/Component_Development_Kit_Guide/pom.xml
modules/docs/trunk/Component_Reference/pom.xml
modules/docs/trunk/Developer_Guide/pom.xml
modules/docs/trunk/Migration_Guide/pom.xml
modules/docs/trunk/parent/pom.xml
modules/docs/trunk/pom.xml
Log:
[maven-release-plugin] rollback the release of 4.0.0.20100831-M2
Modified: modules/docs/trunk/Component_Development_Kit_Guide/pom.xml
===================================================================
--- modules/docs/trunk/Component_Development_Kit_Guide/pom.xml 2010-08-31 16:29:20 UTC (rev 19046)
+++ modules/docs/trunk/Component_Development_Kit_Guide/pom.xml 2010-08-31 16:37:21 UTC (rev 19047)
@@ -4,7 +4,7 @@
<groupId>org.richfaces.cdk-guide</groupId>
<artifactId>richfaces-cdk-guide</artifactId>
- <version>4.0.0.20100831-M2</version>
+ <version>4.0.0-SNAPSHOT</version>
<packaging>jdocbook</packaging>
<name>RichFaces CDK Guide</name>
<url>http://www.jboss.org/richfaces</url>
@@ -12,7 +12,7 @@
<parent>
<groupId>org.richfaces.docs</groupId>
<artifactId>docs-parent</artifactId>
- <version>4.0.0.20100831-M2</version>
+ <version>4.0.0-SNAPSHOT</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
@@ -107,9 +107,9 @@
</profiles>
<scm>
- <connection>scm:svn:http://anonsvn.jboss.org/repos/richfaces/tags/4.0.0.20100831-M2</connection>
- <developerConnection>scm:svn:https://svn.jboss.org/repos/richfaces/tags/4.0.0.20100831-M2</developerConnection>
- <url>http://fisheye.jboss.org/browse/richfaces/tags/4.0.0.20100831-M2</url>
+ <connection>scm:svn:http://anonsvn.jboss.org/repos/richfaces/trunk/cdk/docs/guide</connection>
+ <developerConnection>scm:svn:https://svn.jboss.org/repos/richfaces/trunk/cdk/docs/guide</developerConnection>
+ <url>http://fisheye.jboss.org/browse/richfaces/</url>
</scm>
</project>
Modified: modules/docs/trunk/Component_Reference/pom.xml
===================================================================
--- modules/docs/trunk/Component_Reference/pom.xml 2010-08-31 16:29:20 UTC (rev 19046)
+++ modules/docs/trunk/Component_Reference/pom.xml 2010-08-31 16:37:21 UTC (rev 19047)
@@ -4,7 +4,7 @@
<groupId>org.richfaces.docs</groupId>
<artifactId>richfaces-component-reference</artifactId>
- <version>4.0.0.20100831-M2</version>
+ <version>4.0.0-SNAPSHOT</version>
<packaging>jdocbook</packaging>
<name>RichFaces Component Reference</name>
<url>http://www.jboss.org/richfaces</url>
@@ -12,7 +12,7 @@
<parent>
<groupId>org.richfaces.docs</groupId>
<artifactId>docs-parent</artifactId>
- <version>4.0.0.20100831-M2</version>
+ <version>4.0.0-SNAPSHOT</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
@@ -107,9 +107,9 @@
</profiles>
<scm>
- <connection>scm:svn:http://anonsvn.jboss.org/repos/richfaces/tags/4.0.0.20100831-M2</connection>
- <developerConnection>scm:svn:https://svn.jboss.org/repos/richfaces/tags/4.0.0.20100831-M2</developerConnection>
- <url>http://fisheye.jboss.org/browse/richfaces/tags/4.0.0.20100831-M2</url>
+ <connection>scm:svn:http://anonsvn.jboss.org/repos/richfaces/trunk/docs/Component_Ref...</connection>
+ <developerConnection>scm:svn:https://svn.jboss.org/repos/richfaces/trunk/docs/Component_Reference</developerConnection>
+ <url>http://fisheye.jboss.org/browse/richfaces/trunk/</url>
</scm>
</project>
Modified: modules/docs/trunk/Developer_Guide/pom.xml
===================================================================
--- modules/docs/trunk/Developer_Guide/pom.xml 2010-08-31 16:29:20 UTC (rev 19046)
+++ modules/docs/trunk/Developer_Guide/pom.xml 2010-08-31 16:37:21 UTC (rev 19047)
@@ -4,7 +4,7 @@
<groupId>org.richfaces.docs</groupId>
<artifactId>richfaces-developer-guide</artifactId>
- <version>4.0.0.20100831-M2</version>
+ <version>4.0.0-SNAPSHOT</version>
<packaging>jdocbook</packaging>
<name>RichFaces Developer Guide</name>
<url>http://www.jboss.org/richfaces</url>
@@ -12,7 +12,7 @@
<parent>
<groupId>org.richfaces.docs</groupId>
<artifactId>docs-parent</artifactId>
- <version>4.0.0.20100831-M2</version>
+ <version>4.0.0-SNAPSHOT</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
@@ -108,9 +108,9 @@
</profiles>
<scm>
- <connection>scm:svn:http://anonsvn.jboss.org/repos/richfaces/tags/4.0.0.20100831-M2</connection>
- <developerConnection>scm:svn:https://svn.jboss.org/repos/richfaces/tags/4.0.0.20100831-M2</developerConnection>
- <url>http://fisheye.jboss.org/browse/richfaces/tags/4.0.0.20100831-M2</url>
+ <connection>scm:svn:http://anonsvn.jboss.org/repos/richfaces/trunk/docs/Developer_Guide</connection>
+ <developerConnection>scm:svn:https://svn.jboss.org/repos/richfaces/trunk/docs/Developer_Guide</developerConnection>
+ <url>http://fisheye.jboss.org/browse/richfaces/trunk/</url>
</scm>
</project>
Modified: modules/docs/trunk/Migration_Guide/pom.xml
===================================================================
--- modules/docs/trunk/Migration_Guide/pom.xml 2010-08-31 16:29:20 UTC (rev 19046)
+++ modules/docs/trunk/Migration_Guide/pom.xml 2010-08-31 16:37:21 UTC (rev 19047)
@@ -4,7 +4,7 @@
<groupId>org.richfaces.docs</groupId>
<artifactId>richfaces-migration-guide</artifactId>
- <version>4.0.0.20100831-M2</version>
+ <version>4.0.0-SNAPSHOT</version>
<packaging>jdocbook</packaging>
<name>RichFaces Migration Guide</name>
<url>http://www.jboss.org/richfaces</url>
@@ -12,7 +12,7 @@
<parent>
<groupId>org.richfaces.docs</groupId>
<artifactId>docs-parent</artifactId>
- <version>4.0.0.20100831-M2</version>
+ <version>4.0.0-SNAPSHOT</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
@@ -108,9 +108,9 @@
</profiles>
<scm>
- <connection>scm:svn:http://anonsvn.jboss.org/repos/richfaces/tags/4.0.0.20100831-M2</connection>
- <developerConnection>scm:svn:https://svn.jboss.org/repos/richfaces/tags/4.0.0.20100831-M2</developerConnection>
- <url>http://fisheye.jboss.org/browse/richfaces/tags/4.0.0.20100831-M2</url>
+ <connection>scm:svn:http://anonsvn.jboss.org/repos/richfaces/trunk/docs/Migration_Guide</connection>
+ <developerConnection>scm:svn:https://svn.jboss.org/repos/richfaces/trunk/docs/Migration_Guide</developerConnection>
+ <url>http://fisheye.jboss.org/browse/richfaces/trunk/</url>
</scm>
</project>
Modified: modules/docs/trunk/parent/pom.xml
===================================================================
--- modules/docs/trunk/parent/pom.xml 2010-08-31 16:29:20 UTC (rev 19046)
+++ modules/docs/trunk/parent/pom.xml 2010-08-31 16:37:21 UTC (rev 19047)
@@ -28,7 +28,7 @@
<groupId>org.richfaces.docs</groupId>
<artifactId>docs-parent</artifactId>
- <version>4.0.0.20100831-M2</version>
+ <version>4.0.0-SNAPSHOT</version>
<name>Richfaces Docs: Parent</name>
<packaging>pom</packaging>
@@ -217,8 +217,8 @@
-->
<scm>
- <connection>scm:svn:http://anonsvn.jboss.org/repos/richfaces/tags/4.0.0.20100831-M2</connection>
- <developerConnection>scm:svn:https://svn.jboss.org/repos/richfaces/tags/4.0.0.20100831-M2</developerConnection>
- <url>http://fisheye.jboss.org/browse/richfaces/tags/4.0.0.20100831-M2</url>
+ <connection>scm:svn:http://anonsvn.jboss.org/repos/richfaces/trunk/docs/parent</connection>
+ <developerConnection>scm:svn:https://svn.jboss.org/repos/richfaces/trunk/docs/parent</developerConnection>
+ <url>http://fisheye.jboss.org/browse/richfaces/trunk/</url>
</scm>
</project>
Modified: modules/docs/trunk/pom.xml
===================================================================
--- modules/docs/trunk/pom.xml 2010-08-31 16:29:20 UTC (rev 19046)
+++ modules/docs/trunk/pom.xml 2010-08-31 16:37:21 UTC (rev 19047)
@@ -9,7 +9,7 @@
<groupId>org.richfaces.docs</groupId>
<artifactId>docs-aggregator</artifactId>
- <version>4.0.0.20100831-M2</version>
+ <version>4.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>RichFaces Document Aggregator</name>
@@ -22,9 +22,9 @@
</modules>
<scm>
- <connection>scm:svn:http://anonsvn.jboss.org/repos/richfaces/tags/4.0.0.20100831-M2</connection>
- <developerConnection>scm:svn:https://svn.jboss.org/repos/richfaces/tags/4.0.0.20100831-M2</developerConnection>
- <url>http://fisheye.jboss.org/browse/richfaces/tags/4.0.0.20100831-M2</url>
+ <connection>scm:svn:http://anonsvn.jboss.org/repos/richfaces/trunk/root/docs</connection>
+ <developerConnection>scm:svn:https://svn.jboss.org/repos/richfaces/trunk/root/docs</developerConnection>
+ <url>http://fisheye.jboss.org/browse/richfaces/trunk/</url>
</scm>
</project>
14 years, 3 months
JBoss Rich Faces SVN: r19046 - in modules/docs/trunk: Component_Development_Kit_Guide and 4 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: jbalunas(a)redhat.com
Date: 2010-08-31 12:29:20 -0400 (Tue, 31 Aug 2010)
New Revision: 19046
Modified:
modules/docs/trunk/Component_Development_Kit_Guide/pom.xml
modules/docs/trunk/Component_Reference/pom.xml
modules/docs/trunk/Developer_Guide/pom.xml
modules/docs/trunk/Migration_Guide/pom.xml
modules/docs/trunk/parent/pom.xml
modules/docs/trunk/pom.xml
Log:
[maven-release-plugin] prepare release 4.0.0.20100831-M2
Modified: modules/docs/trunk/Component_Development_Kit_Guide/pom.xml
===================================================================
--- modules/docs/trunk/Component_Development_Kit_Guide/pom.xml 2010-08-31 15:51:59 UTC (rev 19045)
+++ modules/docs/trunk/Component_Development_Kit_Guide/pom.xml 2010-08-31 16:29:20 UTC (rev 19046)
@@ -4,7 +4,7 @@
<groupId>org.richfaces.cdk-guide</groupId>
<artifactId>richfaces-cdk-guide</artifactId>
- <version>4.0.0-SNAPSHOT</version>
+ <version>4.0.0.20100831-M2</version>
<packaging>jdocbook</packaging>
<name>RichFaces CDK Guide</name>
<url>http://www.jboss.org/richfaces</url>
@@ -12,7 +12,7 @@
<parent>
<groupId>org.richfaces.docs</groupId>
<artifactId>docs-parent</artifactId>
- <version>4.0.0-SNAPSHOT</version>
+ <version>4.0.0.20100831-M2</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
@@ -107,9 +107,9 @@
</profiles>
<scm>
- <connection>scm:svn:http://anonsvn.jboss.org/repos/richfaces/trunk/cdk/docs/guide</connection>
- <developerConnection>scm:svn:https://svn.jboss.org/repos/richfaces/trunk/cdk/docs/guide</developerConnection>
- <url>http://fisheye.jboss.org/browse/richfaces/</url>
+ <connection>scm:svn:http://anonsvn.jboss.org/repos/richfaces/tags/4.0.0.20100831-M2</connection>
+ <developerConnection>scm:svn:https://svn.jboss.org/repos/richfaces/tags/4.0.0.20100831-M2</developerConnection>
+ <url>http://fisheye.jboss.org/browse/richfaces/tags/4.0.0.20100831-M2</url>
</scm>
</project>
Modified: modules/docs/trunk/Component_Reference/pom.xml
===================================================================
--- modules/docs/trunk/Component_Reference/pom.xml 2010-08-31 15:51:59 UTC (rev 19045)
+++ modules/docs/trunk/Component_Reference/pom.xml 2010-08-31 16:29:20 UTC (rev 19046)
@@ -4,7 +4,7 @@
<groupId>org.richfaces.docs</groupId>
<artifactId>richfaces-component-reference</artifactId>
- <version>4.0.0-SNAPSHOT</version>
+ <version>4.0.0.20100831-M2</version>
<packaging>jdocbook</packaging>
<name>RichFaces Component Reference</name>
<url>http://www.jboss.org/richfaces</url>
@@ -12,7 +12,7 @@
<parent>
<groupId>org.richfaces.docs</groupId>
<artifactId>docs-parent</artifactId>
- <version>4.0.0-SNAPSHOT</version>
+ <version>4.0.0.20100831-M2</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
@@ -107,9 +107,9 @@
</profiles>
<scm>
- <connection>scm:svn:http://anonsvn.jboss.org/repos/richfaces/trunk/docs/Component_Ref...</connection>
- <developerConnection>scm:svn:https://svn.jboss.org/repos/richfaces/trunk/docs/Component_Reference</developerConnection>
- <url>http://fisheye.jboss.org/browse/richfaces/trunk/</url>
+ <connection>scm:svn:http://anonsvn.jboss.org/repos/richfaces/tags/4.0.0.20100831-M2</connection>
+ <developerConnection>scm:svn:https://svn.jboss.org/repos/richfaces/tags/4.0.0.20100831-M2</developerConnection>
+ <url>http://fisheye.jboss.org/browse/richfaces/tags/4.0.0.20100831-M2</url>
</scm>
</project>
Modified: modules/docs/trunk/Developer_Guide/pom.xml
===================================================================
--- modules/docs/trunk/Developer_Guide/pom.xml 2010-08-31 15:51:59 UTC (rev 19045)
+++ modules/docs/trunk/Developer_Guide/pom.xml 2010-08-31 16:29:20 UTC (rev 19046)
@@ -4,7 +4,7 @@
<groupId>org.richfaces.docs</groupId>
<artifactId>richfaces-developer-guide</artifactId>
- <version>4.0.0-SNAPSHOT</version>
+ <version>4.0.0.20100831-M2</version>
<packaging>jdocbook</packaging>
<name>RichFaces Developer Guide</name>
<url>http://www.jboss.org/richfaces</url>
@@ -12,7 +12,7 @@
<parent>
<groupId>org.richfaces.docs</groupId>
<artifactId>docs-parent</artifactId>
- <version>4.0.0-SNAPSHOT</version>
+ <version>4.0.0.20100831-M2</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
@@ -108,9 +108,9 @@
</profiles>
<scm>
- <connection>scm:svn:http://anonsvn.jboss.org/repos/richfaces/trunk/docs/Developer_Guide</connection>
- <developerConnection>scm:svn:https://svn.jboss.org/repos/richfaces/trunk/docs/Developer_Guide</developerConnection>
- <url>http://fisheye.jboss.org/browse/richfaces/trunk/</url>
+ <connection>scm:svn:http://anonsvn.jboss.org/repos/richfaces/tags/4.0.0.20100831-M2</connection>
+ <developerConnection>scm:svn:https://svn.jboss.org/repos/richfaces/tags/4.0.0.20100831-M2</developerConnection>
+ <url>http://fisheye.jboss.org/browse/richfaces/tags/4.0.0.20100831-M2</url>
</scm>
</project>
Modified: modules/docs/trunk/Migration_Guide/pom.xml
===================================================================
--- modules/docs/trunk/Migration_Guide/pom.xml 2010-08-31 15:51:59 UTC (rev 19045)
+++ modules/docs/trunk/Migration_Guide/pom.xml 2010-08-31 16:29:20 UTC (rev 19046)
@@ -4,7 +4,7 @@
<groupId>org.richfaces.docs</groupId>
<artifactId>richfaces-migration-guide</artifactId>
- <version>4.0.0-SNAPSHOT</version>
+ <version>4.0.0.20100831-M2</version>
<packaging>jdocbook</packaging>
<name>RichFaces Migration Guide</name>
<url>http://www.jboss.org/richfaces</url>
@@ -12,7 +12,7 @@
<parent>
<groupId>org.richfaces.docs</groupId>
<artifactId>docs-parent</artifactId>
- <version>4.0.0-SNAPSHOT</version>
+ <version>4.0.0.20100831-M2</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
@@ -108,9 +108,9 @@
</profiles>
<scm>
- <connection>scm:svn:http://anonsvn.jboss.org/repos/richfaces/trunk/docs/Migration_Guide</connection>
- <developerConnection>scm:svn:https://svn.jboss.org/repos/richfaces/trunk/docs/Migration_Guide</developerConnection>
- <url>http://fisheye.jboss.org/browse/richfaces/trunk/</url>
+ <connection>scm:svn:http://anonsvn.jboss.org/repos/richfaces/tags/4.0.0.20100831-M2</connection>
+ <developerConnection>scm:svn:https://svn.jboss.org/repos/richfaces/tags/4.0.0.20100831-M2</developerConnection>
+ <url>http://fisheye.jboss.org/browse/richfaces/tags/4.0.0.20100831-M2</url>
</scm>
</project>
Modified: modules/docs/trunk/parent/pom.xml
===================================================================
--- modules/docs/trunk/parent/pom.xml 2010-08-31 15:51:59 UTC (rev 19045)
+++ modules/docs/trunk/parent/pom.xml 2010-08-31 16:29:20 UTC (rev 19046)
@@ -28,7 +28,7 @@
<groupId>org.richfaces.docs</groupId>
<artifactId>docs-parent</artifactId>
- <version>4.0.0-SNAPSHOT</version>
+ <version>4.0.0.20100831-M2</version>
<name>Richfaces Docs: Parent</name>
<packaging>pom</packaging>
@@ -217,8 +217,8 @@
-->
<scm>
- <connection>scm:svn:http://anonsvn.jboss.org/repos/richfaces/trunk/docs/parent</connection>
- <developerConnection>scm:svn:https://svn.jboss.org/repos/richfaces/trunk/docs/parent</developerConnection>
- <url>http://fisheye.jboss.org/browse/richfaces/trunk/</url>
+ <connection>scm:svn:http://anonsvn.jboss.org/repos/richfaces/tags/4.0.0.20100831-M2</connection>
+ <developerConnection>scm:svn:https://svn.jboss.org/repos/richfaces/tags/4.0.0.20100831-M2</developerConnection>
+ <url>http://fisheye.jboss.org/browse/richfaces/tags/4.0.0.20100831-M2</url>
</scm>
</project>
Modified: modules/docs/trunk/pom.xml
===================================================================
--- modules/docs/trunk/pom.xml 2010-08-31 15:51:59 UTC (rev 19045)
+++ modules/docs/trunk/pom.xml 2010-08-31 16:29:20 UTC (rev 19046)
@@ -9,7 +9,7 @@
<groupId>org.richfaces.docs</groupId>
<artifactId>docs-aggregator</artifactId>
- <version>4.0.0-SNAPSHOT</version>
+ <version>4.0.0.20100831-M2</version>
<packaging>pom</packaging>
<name>RichFaces Document Aggregator</name>
@@ -22,9 +22,9 @@
</modules>
<scm>
- <connection>scm:svn:http://anonsvn.jboss.org/repos/richfaces/trunk/root/docs</connection>
- <developerConnection>scm:svn:https://svn.jboss.org/repos/richfaces/trunk/root/docs</developerConnection>
- <url>http://fisheye.jboss.org/browse/richfaces/trunk/</url>
+ <connection>scm:svn:http://anonsvn.jboss.org/repos/richfaces/tags/4.0.0.20100831-M2</connection>
+ <developerConnection>scm:svn:https://svn.jboss.org/repos/richfaces/tags/4.0.0.20100831-M2</developerConnection>
+ <url>http://fisheye.jboss.org/browse/richfaces/tags/4.0.0.20100831-M2</url>
</scm>
</project>
14 years, 3 months
JBoss Rich Faces SVN: r19045 - in trunk: examples/output-demo/src/main/webapp/examples and 11 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: Alex.Kolonitsky
Date: 2010-08-31 11:51:59 -0400 (Tue, 31 Aug 2010)
New Revision: 19045
Added:
trunk/examples/output-demo/src/main/webapp/examples/collapsiblePanel.xhtml
trunk/examples/output-demo/src/main/webapp/qunit/collapsiblePanel.xhtml
trunk/examples/output-demo/src/main/webapp/resources/tests/richfaces-collapsible-panel-qunit.js
trunk/ui/output/api/src/main/java/org/richfaces/event/ChangeExpandEvent.java
trunk/ui/output/api/src/main/java/org/richfaces/event/ChangeExpandListener.java
trunk/ui/output/api/src/main/java/org/richfaces/event/ChangeExpandSource.java
trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractCollapsiblePanel.java
trunk/ui/output/ui/src/main/java/org/richfaces/component/UICollapsiblePanel.java
trunk/ui/output/ui/src/main/java/org/richfaces/component/html/HtmlCollapsiblePanel.java
trunk/ui/output/ui/src/main/java/org/richfaces/event/MethodExpressionChangeExpandListener.java
trunk/ui/output/ui/src/main/java/org/richfaces/event/MethodExpressionEventListener.java
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/CollapsiblePanelRenderer.java
trunk/ui/output/ui/src/main/java/org/richfaces/view/facelets/html/ChangeExpandListenerHandler.java
trunk/ui/output/ui/src/main/java/org/richfaces/view/facelets/html/CollapsiblePanelTagHandler.java
trunk/ui/output/ui/src/main/java/org/richfaces/view/facelets/html/EventListenerHandler.java
trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/CollapsiblePanel.js
trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/CollapsiblePanelItem.js
trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/collapsiblePanel.ecss
Modified:
trunk/examples/output-demo/src/main/webapp/WEB-INF/faces-config.xml
trunk/examples/output-demo/src/main/webapp/templates/template.xhtml
trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractTogglePanel.java
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/DivPanelRenderer.java
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/TogglePanelRenderer.java
trunk/ui/output/ui/src/main/resources/META-INF/pn.faces-config.xml
trunk/ui/output/ui/src/main/resources/META-INF/pn.taglib.xml
trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/TogglePanel.js
Log:
RF-8818 collapsiblePanel component
Modified: trunk/examples/output-demo/src/main/webapp/WEB-INF/faces-config.xml
===================================================================
--- trunk/examples/output-demo/src/main/webapp/WEB-INF/faces-config.xml 2010-08-31 14:36:18 UTC (rev 19044)
+++ trunk/examples/output-demo/src/main/webapp/WEB-INF/faces-config.xml 2010-08-31 15:51:59 UTC (rev 19045)
@@ -34,6 +34,10 @@
<from-outcome>accordion</from-outcome>
<to-view-id>/examples/accordion.xhtml</to-view-id>
</navigation-case>
+ <navigation-case>
+ <from-outcome>collapsiblePanel</from-outcome>
+ <to-view-id>/examples/collapsiblePanel.xhtml</to-view-id>
+ </navigation-case>
<!-- QUnit -->
<navigation-case>
@@ -52,5 +56,9 @@
<from-outcome>qunit/accordionHeaders</from-outcome>
<to-view-id>/qunit/accordionHeaders.xhtml</to-view-id>
</navigation-case>
+ <navigation-case>
+ <from-outcome>qunit/collapsiblePanel</from-outcome>
+ <to-view-id>/qunit/collapsiblePanel.xhtml</to-view-id>
+ </navigation-case>
</navigation-rule>
</faces-config>
Added: trunk/examples/output-demo/src/main/webapp/examples/collapsiblePanel.xhtml
===================================================================
--- trunk/examples/output-demo/src/main/webapp/examples/collapsiblePanel.xhtml (rev 0)
+++ trunk/examples/output-demo/src/main/webapp/examples/collapsiblePanel.xhtml 2010-08-31 15:51:59 UTC (rev 19045)
@@ -0,0 +1,44 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:pn="http://richfaces.org/output">
+
+<body>
+<ui:composition template="/templates/template.xhtml">
+
+ <ui:define name="title">Collapsible Panel QUnit</ui:define>
+ <ui:define name="body_head">Collapsible Panel QUnit</ui:define>
+
+ <ui:define name="body">
+ <p>Page</p>
+
+ <h:form id="f">
+ <pn:collapsiblePanel id="panel">
+ <f:facet name="headerExpanded" >
+ header exanded
+ </f:facet>
+ <f:facet name="headerCollapsed" >
+ header collapsed
+ </f:facet>
+
+ Hello!!!
+
+ </pn:collapsiblePanel>
+
+ </h:form>
+
+ <p>Result</p>
+ <div>
+ <ol id="qunit-tests"></ol>
+
+ <div id="testDiv" style="margin-top:10px; border:1px solid #a0a0a0">Main Test Div</div>
+
+ </div>
+ <h:outputScript name="tests/richfaces-collapsible-panel-qunit.js" />
+ </ui:define>
+</ui:composition>
+</body>
+</html>
+
Added: trunk/examples/output-demo/src/main/webapp/qunit/collapsiblePanel.xhtml
===================================================================
--- trunk/examples/output-demo/src/main/webapp/qunit/collapsiblePanel.xhtml (rev 0)
+++ trunk/examples/output-demo/src/main/webapp/qunit/collapsiblePanel.xhtml 2010-08-31 15:51:59 UTC (rev 19045)
@@ -0,0 +1,51 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:pn="http://richfaces.org/output">
+
+<body>
+<ui:composition template="/templates/template.xhtml">
+
+ <ui:define name="scripts">
+ <h:outputScript name="qunit/qunit.js" />
+ <h:outputScript name="qunit/richfaces-qunit.js" />
+
+ <h:outputStylesheet name="qunit/qunit.css" />
+ </ui:define>
+
+ <ui:define name="title">Collapsible Panel QUnit</ui:define>
+ <ui:define name="body_head">Collapsible Panel QUnit</ui:define>
+
+ <ui:define name="body">
+ <p>Page</p>
+
+ <h:form id="f">
+ <pn:collapsiblePanel id="panel" switchType="client">
+ <f:facet name="headerExpanded" >
+ header exanded
+ </f:facet>
+ <f:facet name="headerCollapsed" >
+ header collapsed
+ </f:facet>
+
+ Hello!!!
+
+ </pn:collapsiblePanel>
+
+ </h:form>
+
+ <p>Result</p>
+ <div>
+ <ol id="qunit-tests"></ol>
+
+ <div id="testDiv" style="margin-top:10px; border:1px solid #a0a0a0">Main Test Div</div>
+
+ </div>
+ <h:outputScript name="tests/richfaces-collapsible-panel-qunit.js" />
+ </ui:define>
+</ui:composition>
+</body>
+</html>
+
Added: trunk/examples/output-demo/src/main/webapp/resources/tests/richfaces-collapsible-panel-qunit.js
===================================================================
--- trunk/examples/output-demo/src/main/webapp/resources/tests/richfaces-collapsible-panel-qunit.js (rev 0)
+++ trunk/examples/output-demo/src/main/webapp/resources/tests/richfaces-collapsible-panel-qunit.js 2010-08-31 15:51:59 UTC (rev 19045)
@@ -0,0 +1,115 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, 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.
+ */
+
+RichFaces.QUnit.run(function() {
+ module("richfaces-collapsible-panel");
+
+ var COLLAPSIBLE_PANEL_ID = "f:panel";
+
+ function handler (msg, returnValue) {
+ return function () {
+ ok(true, msg);
+
+ if (returnValue != undefined) {
+ return returnValue;
+ }
+ };
+ }
+
+ test("RichFaces.ui.CollapsiblePanel test constructor", function () {
+ var c = RichFaces.$(COLLAPSIBLE_PANEL_ID);
+
+ ok(c instanceof RichFaces.ui.CollapsiblePanel, "inctance of RichFaces.ui.CollapsiblePanel");
+ equals(c.id, COLLAPSIBLE_PANEL_ID, "id");
+ // TODO other params
+
+ });
+
+ test("RichFaces.ui.CollapsiblePanel test public api", function () {
+ var c = RichFaces.$(COLLAPSIBLE_PANEL_ID);
+
+ var PUBLIC_API = ["switchPanel"];
+
+ for (var i in PUBLIC_API) {
+ var funcName = PUBLIC_API[i];
+ ok(c[funcName], funcName + " present in component");
+ equals(typeof c[funcName], "function", funcName + "is function");
+ }
+ });
+
+ test("RichFaces.ui.CollapsiblePanel.Events", function () {
+ var componentId = COLLAPSIBLE_PANEL_ID;
+ var c = RichFaces.$(componentId);
+
+ expect(4);
+
+ var beforeswitchHandler = function (event, comp, data) {
+ ok(true, "beforeswitch handler invouked");
+
+ same(data.id, componentId, "component id");
+ same(data.isExpanded, "false", "panel collapsed");
+
+ return true;
+ };
+
+ var beforeswitchHandlerWrapper = RichFaces.Event.bindById(componentId, "beforeswitch", beforeswitchHandler);
+
+ var switchHandler = handler("switch handler invouked", undefined);
+ var switchHandlerWrapper = RichFaces.Event.bindById(componentId, "switch", switchHandler);
+
+ c.switchPanel();
+
+ RichFaces.Event.unbindById(componentId, "beforeswitch", beforeswitchHandlerWrapper);
+ RichFaces.Event.unbindById(componentId, "switch", switchHandlerWrapper);
+
+ c.switchPanel();
+ });
+
+ test("RichFaces.ui.CollapsiblePanel.Events test cancelable", function () {
+ var c = RichFaces.$(COLLAPSIBLE_PANEL_ID);
+
+ expect(2);
+ var beforeswitch1 = RichFaces.Event.bindById(COLLAPSIBLE_PANEL_ID, "beforeswitch", function () {
+ ok(true, "beforeswitch handler invouked");
+
+ return false;
+ });
+
+ var beforeswitch2 = RichFaces.Event.bindById(COLLAPSIBLE_PANEL_ID, "beforeswitch", function () {
+ ok(true, "beforeswitch handler invouked");
+
+ return true;
+ });
+
+ var switchHandler = RichFaces.Event.bindById(COLLAPSIBLE_PANEL_ID, "switch", function () {
+ ok(false, "switch handler should't been invouked");
+ });
+
+ c.switchPanel();
+
+ RichFaces.Event.unbindById(COLLAPSIBLE_PANEL_ID, "beforeswitch", beforeswitch1);
+ RichFaces.Event.unbindById(COLLAPSIBLE_PANEL_ID, "beforeswitch", beforeswitch2);
+ RichFaces.Event.unbindById(COLLAPSIBLE_PANEL_ID, "switch", switchHandler);
+
+ c.switchPanel();
+ });
+});
Modified: trunk/examples/output-demo/src/main/webapp/templates/template.xhtml
===================================================================
--- trunk/examples/output-demo/src/main/webapp/templates/template.xhtml 2010-08-31 14:36:18 UTC (rev 19044)
+++ trunk/examples/output-demo/src/main/webapp/templates/template.xhtml 2010-08-31 15:51:59 UTC (rev 19045)
@@ -11,9 +11,161 @@
<meta http-equiv="content-type" content="text/xhtml; charset=UTF-8" />
+ <style type="text/css">
+ * {
+ font-family: verdana
+ }
+
+ .rftp_toptab {
+ display: table-cell;
+ border: 1px solid #A6A6A6;
+ padding: 0px 0px 3px 0px;
+ vertical-align: bottom;
+ background: url(tab_bg.gif) top repeat-x #DAE7F5;
+ }
+
+ .rftp_active_top {
+ border-bottom: 0px;
+ font-weight: bold;
+ padding: 3px 0px 0px 0px;
+ vertical-align: top;
+ background: url(acttab_bg.gif) top repeat-x #C9DBEF;
+ }
+
+ .rftp_active2_top {
+ border-bottom: 0px;
+ font-weight: bold;
+ padding: 3px 0px 0px 0px;
+ vertical-align: top;
+ background: url(acttab2_bg.gif) top repeat-x #FFFFFF;
+ }
+
+ .rftp_toptab_tabline_vis {
+ border: 1px solid #a6a6a6;
+ background: url(tabline_bg.gif) top repeat-x #EEF4FB;
+ border-bottom: 0px;
+ padding-top: 2px;
+ overflow: hidden;
+ height: 23px;
+ white-space: nowrap;
+ position: relative;
+ }
+
+ .rftp_toptab_tabline_dis {
+ border-bottom: 0px;
+ padding-top: 2px;
+ overflow: hidden;
+ height: 25px;
+ white-space: nowrap;
+ position: relative;
+ }
+
+ .rftp_toptab_tabs {
+ display: table;
+ border: 0px;
+ width: 100%;
+ height: 100%;
+ }
+
+ .rftp_toptab_spacer {
+ display: table-cell;
+ border-bottom: 1px solid #A6A6A6;
+ }
+
+ .rftp_horizonttab_tabspacer_width {
+ padding-left: 1px;
+ }
+
+ .rftp_icon {
+ display: table-cell;
+ vertical-align: middle;
+ padding: 0px 5px 0px 5px;
+ }
+
+ .rftp_close {
+ display: table-cell;
+ vertical-align: middle;
+ padding: 0px 3px 0px 15px;
+ }
+
+ .rftp_label {
+ display: table-cell;
+ vertical-align: middle;
+ font-family: verdana;
+ font-size: 11px;
+ }
+
+ .rftp_toptab_scroll_left {
+ background: url(acttab_bg.gif) top repeat-x #C9DBEF;
+ position: absolute;
+ top: 1px;
+ left: 1px;
+ width: 15px;
+ height: 250px;
+ border: 1px solid #a6a6a6;
+ font-weight: bold;
+ text-align: center;
+ font-family: verdana;
+ font-size: 11px;
+ padding-top: 6px;
+ }
+
+ .rftp_toptab_scroll_right {
+ background: url(acttab_bg.gif) top repeat-x #C9DBEF;
+ position: absolute;
+ top: 1px;
+ right: 17px;
+ width: 15px;
+ height: 250px;
+ border: 1px solid #a6a6a6;
+ font-weight: bold;
+ text-align: center;
+ font-family: verdana;
+ font-size: 11px;
+ padding-top: 6px;
+ }
+
+ .rftp_toptab_tabslist {
+ background: url(acttab_bg.gif) top repeat-x #C9DBEF;
+ position: absolute;
+ top: 1px;
+ right: 1px;
+ width: 15px;
+ height: 250px;
+ border: 1px solid #a6a6a6;
+ font-weight: bold;
+ text-align: center;
+ font-family: verdana;
+ font-size: 14px;
+ padding-top: 2px;
+ }
+
+ .rftp_toptab_border {
+ border: 1px solid #A6A6A6;
+ border-top: 0px;
+ height: 2px;
+ background: #C9DBEF;
+ }
+
+ .rftp_toptab_content {
+ border: 1px solid #A6A6A6;
+ border-top: 0px;
+ font-family: verdana;
+ font-size: 11px;
+ padding: 10px;
+ background: #ffffff;
+ }
+
+ .rftp_hidden {
+ display: none
+ }
+ </style>
+
</h:head>
<h:body>
+
+
<ui:insert name="scripts" ></ui:insert>
<table width="100%">
<thead>
@@ -46,6 +198,12 @@
<li><h:commandLink value="accordion" action="accordion" /></li>
</ul>
</li>
+ <li>
+ <p>Collapsible Panel</p>
+ <ul>
+ <li><h:commandLink value="Collapsible Panel" action="collapsiblePanel" /></li>
+ </ul>
+ </li>
</ul>
<p>QUnit</p>
<ul>
@@ -53,6 +211,7 @@
<li><h:commandLink value="togglePanelItem" action="qunit/togglePanelItem" /></li>
<li><h:commandLink value="accordion" action="qunit/accordion" /></li>
<li><h:commandLink value="accordionHeaders" action="qunit/accordionHeaders" /></li>
+ <li><h:commandLink value="collapsiblePanel" action="qunit/collapsiblePanel" /></li>
</ul>
</h:form>
</td>
Added: trunk/ui/output/api/src/main/java/org/richfaces/event/ChangeExpandEvent.java
===================================================================
--- trunk/ui/output/api/src/main/java/org/richfaces/event/ChangeExpandEvent.java (rev 0)
+++ trunk/ui/output/api/src/main/java/org/richfaces/event/ChangeExpandEvent.java 2010-08-31 15:51:59 UTC (rev 19045)
@@ -0,0 +1,82 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, 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.event;
+
+import javax.faces.component.UIComponent;
+import javax.faces.event.FacesEvent;
+import javax.faces.event.FacesListener;
+
+
+/**
+ * @author akolonitsky
+ * @since 2010-08-27
+ */
+public class ChangeExpandEvent extends FacesEvent {
+
+ private final Boolean isExpanded;
+
+
+ // ------------------------------------------------------------ Constructors
+
+ /**
+ * <p>Construct a new event object from the specified source component,
+ * old value, and new value.</p>
+ *
+ * <p>The default {@link javax.faces.event.PhaseId} for this event is {@link
+ * javax.faces.event.PhaseId#ANY_PHASE}.</p>
+ *
+ * @param component Source {@link UIComponent} for this event
+ * @param isExpanded
+ *
+ * @throws IllegalArgumentException if <code>component</code> is
+ * <code>null</code>
+ */
+ public ChangeExpandEvent(UIComponent component, Boolean isExpanded) {
+ super(component);
+ this.isExpanded = isExpanded;
+ }
+
+
+ // -------------------------------------------------------------- Properties
+
+ public Boolean getExpanded() {
+ return isExpanded;
+ }
+
+ // ------------------------------------------------- Event Broadcast Methods
+
+
+ @Override
+ public boolean isAppropriateListener(FacesListener listener) {
+ return listener instanceof ChangeExpandListener;
+ }
+
+ /**
+ * @throws javax.faces.event.AbortProcessingException {@inheritDoc}
+ */
+ @Override
+ public void processListener(FacesListener listener) {
+ ((ChangeExpandListener) listener).processChangeExpand(this);
+ }
+}
+
Added: trunk/ui/output/api/src/main/java/org/richfaces/event/ChangeExpandListener.java
===================================================================
--- trunk/ui/output/api/src/main/java/org/richfaces/event/ChangeExpandListener.java (rev 0)
+++ trunk/ui/output/api/src/main/java/org/richfaces/event/ChangeExpandListener.java 2010-08-31 15:51:59 UTC (rev 19045)
@@ -0,0 +1,54 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, 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.event;
+
+import javax.faces.event.AbortProcessingException;
+import javax.faces.event.FacesListener;
+
+/**
+ * <p>A listener interface for receiving {@link ChangeExpandEvent}s. A class
+ * that is interested in receiving such events implements this interface, and
+ * then registers itself with the source {@link javax.faces.component.UIComponent} of interest, by
+ * calling <code>addChangeExpandListener()</code>.</p>
+ *
+ * @author akolonitsky
+ * @version 1.0
+ * @since 2010-08-27
+ *
+ */
+public interface ChangeExpandListener extends FacesListener {
+
+
+ /**
+ * <p>Invoked when {@link ChangeExpandEvent} occurs.</p>
+ *
+ * @param event The {@link ChangeExpandEvent} that has occurred
+ *
+ * @throws AbortProcessingException Signal the JavaServer Faces
+ * implementation that no further processing on the current event
+ * should be performed
+ */
+ public void processChangeExpand(ChangeExpandEvent event)
+ throws AbortProcessingException;
+
+}
Added: trunk/ui/output/api/src/main/java/org/richfaces/event/ChangeExpandSource.java
===================================================================
--- trunk/ui/output/api/src/main/java/org/richfaces/event/ChangeExpandSource.java (rev 0)
+++ trunk/ui/output/api/src/main/java/org/richfaces/event/ChangeExpandSource.java 2010-08-31 15:51:59 UTC (rev 19045)
@@ -0,0 +1,58 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, 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.event;
+
+/**
+ * @author akolonitsky
+ * @since 2010-08-27
+ */
+public interface ChangeExpandSource {
+
+ /**
+ * <p>Add a new {@link org.richfaces.event.ChangeExpandListener} to the set of listeners
+ * interested in being notified when {@link org.richfaces.event.ChangeExpandEvent}s occur.</p>
+ *
+ * @param listener The {@link org.richfaces.event.ChangeExpandListener} to be added
+ * @throws NullPointerException if <code>listener</code>
+ * is <code>null</code>
+ */
+ void addChangeExpandListener(ChangeExpandListener listener);
+
+ /**
+ * <p>Return the set of registered {@link org.richfaces.event.ChangeExpandListener}s for this instance.
+ * If there are no registered listeners, a zero-length array is returned.</p>
+ */
+ ChangeExpandListener[] getChangeExpandListeners();
+
+ /**
+ * <p>Remove an existing {@link org.richfaces.event.ChangeExpandListener} (if any) from the
+ * set of listeners interested in being notified when
+ * {@link org.richfaces.event.ChangeExpandEvent}s occur.</p>
+ *
+ * @param listener The {@link org.richfaces.event.ChangeExpandListener} to be removed
+ * @throws NullPointerException if <code>listener</code>
+ * is <code>null</code>
+ */
+ void removeChangeExpandListener(ChangeExpandListener listener);
+
+}
Added: trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractCollapsiblePanel.java
===================================================================
--- trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractCollapsiblePanel.java (rev 0)
+++ trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractCollapsiblePanel.java 2010-08-31 15:51:59 UTC (rev 19045)
@@ -0,0 +1,97 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, 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.component;
+
+import javax.el.MethodExpression;
+import javax.faces.component.UIComponent;
+
+import org.richfaces.event.ChangeExpandSource;
+import org.richfaces.event.ChangeExpandListener;
+
+/**
+ * @author akolonitsky
+ * @since 2010-08-27
+ */
+public abstract class AbstractCollapsiblePanel extends UITogglePanel implements ChangeExpandSource {
+
+ public static final String COMPONENT_TYPE = "org.richfaces.CollapsiblePanel";
+
+ public static final String COMPONENT_FAMILY = "org.richfaces.CollapsiblePanel";
+ private static final String STATE_EXPANDED = "expanded";
+ private static final String STATE_COLLAPSED = "collapsed";
+
+ protected AbstractCollapsiblePanel() {
+ setRendererType("org.richfaces.CollapsiblePanel");
+ }
+
+ @Override
+ public String getFamily() {
+ return COMPONENT_FAMILY;
+ }
+
+ @Override
+ public String getActiveItem() {
+ String ai = super.getActiveItem();
+ return ai == null ? "true" : ai;
+ }
+
+ @Override
+ protected boolean isActiveItem(UIComponent kid) {
+ return isExpanded();
+ }
+
+ @Override
+ protected boolean isActiveItem(UIComponent kid, String value) {
+ return isExpanded();
+ }
+
+
+ public boolean isExpanded() {
+ return Boolean.parseBoolean(getActiveItem());
+ }
+
+ public void setExpanded(boolean isExpanded) {
+ setActiveItem(String.valueOf(isExpanded));
+ }
+
+ public abstract String getHeader();
+
+ public abstract MethodExpression getChangeExpandListener();
+
+
+
+
+ // ------------------------------------------------ Event Processing Methods
+
+ public void addChangeExpandListener(ChangeExpandListener listener) {
+ addFacesListener(listener);
+ }
+
+ public ChangeExpandListener[] getChangeExpandListeners() {
+ return (ChangeExpandListener[]) getFacesListeners(ChangeExpandListener.class);
+ }
+
+ public void removeChangeExpandListener(ChangeExpandListener listener) {
+ removeFacesListener(listener);
+ }
+}
Modified: trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractTogglePanel.java
===================================================================
--- trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractTogglePanel.java 2010-08-31 14:36:18 UTC (rev 19044)
+++ trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractTogglePanel.java 2010-08-31 15:51:59 UTC (rev 19045)
@@ -423,7 +423,7 @@
return isActiveItem(kid, getActiveItemValue());
}
- protected static boolean isActiveItem(UIComponent kid, String value) {
+ protected boolean isActiveItem(UIComponent kid, String value) {
if (kid == null || value == null) {
return false;
}
Added: trunk/ui/output/ui/src/main/java/org/richfaces/component/UICollapsiblePanel.java
===================================================================
--- trunk/ui/output/ui/src/main/java/org/richfaces/component/UICollapsiblePanel.java (rev 0)
+++ trunk/ui/output/ui/src/main/java/org/richfaces/component/UICollapsiblePanel.java 2010-08-31 15:51:59 UTC (rev 19045)
@@ -0,0 +1,53 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, 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.component;
+
+import javax.el.MethodExpression;
+
+/**
+ * @author akolonitsky
+ * @since 2010-08-27
+ */
+public class UICollapsiblePanel extends AbstractCollapsiblePanel {
+
+ public enum PropertyKeys {
+ header,
+ changeExpandListener
+ }
+
+ public String getHeader() {
+ return (String) getStateHelper().eval(PropertyKeys.header);
+ }
+
+ public void setHeader(String header) {
+ getStateHelper().put(PropertyKeys.header, header);
+ }
+
+ public MethodExpression getChangeExpandListener() {
+ return (MethodExpression) getStateHelper().get(PropertyKeys.changeExpandListener);
+ }
+
+ public void setChangeExpandListener(MethodExpression changeExpandListener) {
+ getStateHelper().put(PropertyKeys.changeExpandListener, changeExpandListener);
+ }
+}
Added: trunk/ui/output/ui/src/main/java/org/richfaces/component/html/HtmlCollapsiblePanel.java
===================================================================
--- trunk/ui/output/ui/src/main/java/org/richfaces/component/html/HtmlCollapsiblePanel.java (rev 0)
+++ trunk/ui/output/ui/src/main/java/org/richfaces/component/html/HtmlCollapsiblePanel.java 2010-08-31 15:51:59 UTC (rev 19045)
@@ -0,0 +1,245 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, 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.component.html;
+
+import org.richfaces.component.UICollapsiblePanel;
+import javax.faces.component.behavior.ClientBehaviorHolder;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+
+/**
+ * @author akolonitsky
+ * @since 2010-08-27
+ */
+public class HtmlCollapsiblePanel extends UICollapsiblePanel implements ClientBehaviorHolder {
+
+ public static final String COMPONENT_TYPE = "org.richfaces.CollapsiblePanel";
+
+ public static final String COMPONENT_FAMILY = "org.richfaces.CollapsiblePanel";
+
+ private static final Collection<String> EVENT_NAMES = Collections.unmodifiableCollection(Arrays.asList(
+ "onswitch",
+ "onbeforeswitch",
+ "click",
+ "dblclick",
+ "mousedown",
+ "mousemove",
+ "mouseout",
+ "mouseover",
+ "mouseup"
+ ));
+
+
+ public enum PropertyKeys {
+ bodyClass,
+ headerClass,
+ headerControlClass,
+ oncomplete,
+ onbeforedomupdate,
+ ononswitch,
+ ononbeforeswitch,
+ lang,
+ title,
+ style,
+ styleClass,
+ dir,
+ onclick,
+ ondblclick,
+ onmousedown,
+ onmousemove,
+ onmouseout,
+ onmouseover,
+ onmouseup
+ }
+
+ public HtmlCollapsiblePanel() {
+ setRendererType("org.richfaces.CollapsiblePanel");
+ }
+
+ @Override
+ public String getFamily() {
+ return COMPONENT_FAMILY;
+ }
+
+ public String getBodyClass() {
+ return (String) getStateHelper().eval(PropertyKeys.bodyClass);
+ }
+
+ public void setBodyClass(String bodyClass) {
+ getStateHelper().put(PropertyKeys.bodyClass, bodyClass);
+ }
+
+ public String getHeaderClass() {
+ return (String) getStateHelper().eval(PropertyKeys.headerClass);
+ }
+
+ public void setHeaderClass(String headerClass) {
+ getStateHelper().put(PropertyKeys.headerClass, headerClass);
+ }
+
+ public String getHeaderControlClass() {
+ return (String) getStateHelper().eval(PropertyKeys.headerControlClass);
+ }
+
+ public void setHeaderControlClass(String headerControlClass) {
+ getStateHelper().put(PropertyKeys.headerControlClass, headerControlClass);
+ }
+
+ public String getOncomplete() {
+ return (String) getStateHelper().eval(PropertyKeys.oncomplete);
+ }
+
+ public void setOncomplete(String oncomplete) {
+ getStateHelper().put(PropertyKeys.oncomplete, oncomplete);
+ }
+
+ public String getOnbeforedomupdate() {
+ return (String) getStateHelper().eval(PropertyKeys.onbeforedomupdate);
+ }
+
+ public void setOnbeforedomupdate(String onbeforedomupdate) {
+ getStateHelper().put(PropertyKeys.onbeforedomupdate, onbeforedomupdate);
+ }
+
+ public String getOnonswitch() {
+ return (String) getStateHelper().eval(PropertyKeys.ononswitch);
+ }
+
+ public void setOnonswitch(String ononswitch) {
+ getStateHelper().put(PropertyKeys.ononswitch, ononswitch);
+ }
+
+ public String getOnonbeforeswitch() {
+ return (String) getStateHelper().eval(PropertyKeys.ononbeforeswitch);
+ }
+
+ public void setOnonbeforeswitch(String ononbeforeswitch) {
+ getStateHelper().put(PropertyKeys.ononbeforeswitch, ononbeforeswitch);
+ }
+
+ public String getLang() {
+ return (String) getStateHelper().eval(PropertyKeys.lang);
+ }
+
+ public void setLang(String lang) {
+ getStateHelper().put(PropertyKeys.lang, lang);
+ }
+
+ public String getTitle() {
+ return (String) getStateHelper().eval(PropertyKeys.title);
+ }
+
+ public void setTitle(String title) {
+ getStateHelper().put(PropertyKeys.title, title);
+ }
+
+ public String getStyle() {
+ return (String) getStateHelper().eval(PropertyKeys.style);
+ }
+
+ public void setStyle(String style) {
+ getStateHelper().put(PropertyKeys.style, style);
+ }
+
+ public String getStyleClass() {
+ return (String) getStateHelper().eval(PropertyKeys.styleClass);
+ }
+
+ public void setStyleClass(String styleClass) {
+ getStateHelper().put(PropertyKeys.styleClass, styleClass);
+ }
+
+ public String getDir() {
+ return (String) getStateHelper().eval(PropertyKeys.dir);
+ }
+
+ public void setDir(String dir) {
+ getStateHelper().put(PropertyKeys.dir, dir);
+ }
+
+ public String getOnclick() {
+ return (String) getStateHelper().eval(PropertyKeys.onclick);
+ }
+
+ public void setOnclick(String onclick) {
+ getStateHelper().put(PropertyKeys.onclick, onclick);
+ }
+
+ public String getOndblclick() {
+ return (String) getStateHelper().eval(PropertyKeys.ondblclick);
+ }
+
+ public void setOndblclick(String ondblclick) {
+ getStateHelper().put(PropertyKeys.ondblclick, ondblclick);
+ }
+
+ public String getOnmousedown() {
+ return (String) getStateHelper().eval(PropertyKeys.onmousedown);
+ }
+
+ public void setOnmousedown(String onmousedown) {
+ getStateHelper().put(PropertyKeys.onmousedown, onmousedown);
+ }
+
+ public String getOnmousemove() {
+ return (String) getStateHelper().eval(PropertyKeys.onmousemove);
+ }
+
+ public void setOnmousemove(String onmousemove) {
+ getStateHelper().put(PropertyKeys.onmousemove, onmousemove);
+ }
+
+ public String getOnmouseout() {
+ return (String) getStateHelper().eval(PropertyKeys.onmouseout);
+ }
+
+ public void setOnmouseout(String onmouseout) {
+ getStateHelper().put(PropertyKeys.onmouseout, onmouseout);
+ }
+
+ public String getOnmouseover() {
+ return (String) getStateHelper().eval(PropertyKeys.onmouseover);
+ }
+
+ public void setOnmouseover(String onmouseover) {
+ getStateHelper().put(PropertyKeys.onmouseover, onmouseover);
+ }
+
+ public String getOnmouseup() {
+ return (String) getStateHelper().eval(PropertyKeys.onmouseup);
+ }
+
+ public void setOnmouseup(String onmouseup) {
+ getStateHelper().put(PropertyKeys.onmouseup, onmouseup);
+ }
+
+
+
+ @Override
+ public Collection<String> getEventNames() {
+ return EVENT_NAMES;
+ }
+}
+
Added: trunk/ui/output/ui/src/main/java/org/richfaces/event/MethodExpressionChangeExpandListener.java
===================================================================
--- trunk/ui/output/ui/src/main/java/org/richfaces/event/MethodExpressionChangeExpandListener.java (rev 0)
+++ trunk/ui/output/ui/src/main/java/org/richfaces/event/MethodExpressionChangeExpandListener.java 2010-08-31 15:51:59 UTC (rev 19045)
@@ -0,0 +1,59 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, 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.event;
+
+import javax.el.MethodExpression;
+import javax.faces.event.AbortProcessingException;
+
+/**
+ * <p><strong><span
+ * class="changed_modified_2_0">MethodExpressionChangeExpandListener</span></strong>
+ * is a {@link ChangeExpandListener} that wraps a {@link
+ * MethodExpression}. When it receives a {@link ChangeExpandEvent}, it
+ * executes a method on an object identified by the {@link
+ * MethodExpression}.</p>
+ *
+ * @author akolonitsky
+ * @version 1.0
+ *
+ */
+public class MethodExpressionChangeExpandListener extends MethodExpressionEventListener implements ChangeExpandListener {
+
+ public MethodExpressionChangeExpandListener() {
+ super();
+ }
+
+ public MethodExpressionChangeExpandListener(MethodExpression methodExprOneArg) {
+ super(methodExprOneArg);
+ }
+
+ public MethodExpressionChangeExpandListener(MethodExpression methodExprOneArg, MethodExpression methodExprZeroArg) {
+ super(methodExprOneArg, methodExprZeroArg);
+ }
+
+ // ------------------------------------------------------- Event Method
+
+ public void processChangeExpand(ChangeExpandEvent changeExpandEvent) throws AbortProcessingException {
+ processEvent(changeExpandEvent);
+ }
+}
Added: trunk/ui/output/ui/src/main/java/org/richfaces/event/MethodExpressionEventListener.java
===================================================================
--- trunk/ui/output/ui/src/main/java/org/richfaces/event/MethodExpressionEventListener.java (rev 0)
+++ trunk/ui/output/ui/src/main/java/org/richfaces/event/MethodExpressionEventListener.java 2010-08-31 15:51:59 UTC (rev 19045)
@@ -0,0 +1,197 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, 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.event;
+
+import javax.el.ELContext;
+import javax.el.ELException;
+import javax.el.MethodExpression;
+import javax.el.MethodNotFoundException;
+import javax.faces.component.StateHolder;
+import javax.faces.component.UIComponentBase;
+import javax.faces.context.FacesContext;
+import javax.faces.event.AbortProcessingException;
+import javax.faces.event.FacesEvent;
+import javax.faces.event.FacesListener;
+
+/**
+ * <p><strong><span
+ * class="changed_modified_2_0">MethodExpressionEventListener</span></strong>
+ * is a {@link FacesListener} that wraps a {@link
+ * MethodExpression}. When it receives a {@link FacesEvent}, it
+ * executes a method on an object identified by the {@link
+ * MethodExpression}.</p>
+ *
+ * @author akolonitsky
+ * @version 1.0
+ *
+ */
+public abstract class MethodExpressionEventListener implements FacesListener, StateHolder {
+
+ private static final Class<?>[] EVENT_LISTENER_ZERO_ARG_SIG = new Class[] { };
+
+ private static final Object[] NO_PARAMS = new Object[0];
+
+ // ------------------------------------------------------ Instance Variables
+
+ private MethodExpression methodExpressionOneArg = null;
+ private MethodExpression methodExpressionZeroArg = null;
+
+ private boolean isTransient;
+
+ protected MethodExpressionEventListener() {
+ }
+
+ /**
+ * <p><span class="changed_modified_2_0">Construct</span> a {@link
+ * FacesListener} that contains a {@link
+ * MethodExpression}.<span
+ * class="changed_added_2_0">To accomodate method expression targets
+ * that take no arguments instead of taking a {@link
+ * FacesEvent} argument</span>, the implementation of this
+ * class must take the argument <code>methodExpressionOneArg</code>,
+ * extract its expression string, and create another
+ * <code>MethodExpression</code> whose expected param types match
+ * those of a zero argument method. The usage requirements for both
+ * of these <code>MethodExpression</code> instances are described in
+ * {@link #processEvent}.</span></p>
+ *
+ * @param methodExpressionOneArg a <code>MethodExpression</code>
+ * that points to a method that returns <code>void</code> and takes
+ * a single argument of type {@link FacesEvent}.
+ */
+ protected MethodExpressionEventListener(MethodExpression methodExpressionOneArg) {
+
+ super();
+ this.methodExpressionOneArg = methodExpressionOneArg;
+ FacesContext context = FacesContext.getCurrentInstance();
+ ELContext elContext = context.getELContext();
+ this.methodExpressionZeroArg = context.getApplication().getExpressionFactory().createMethodExpression(
+ elContext, methodExpressionOneArg.getExpressionString(), Void.class, EVENT_LISTENER_ZERO_ARG_SIG);
+ }
+
+ /**
+ * <p>Construct a {@link FacesListener} that contains a {@link MethodExpression}.</p>
+ *
+ * @param methodExprOneArg
+ * @param methodExprZeroArg
+ */
+ protected MethodExpressionEventListener(MethodExpression methodExprOneArg, MethodExpression methodExprZeroArg) {
+
+ super();
+ this.methodExpressionOneArg = methodExprOneArg;
+ this.methodExpressionZeroArg = methodExprZeroArg;
+ }
+
+ // ------------------------------------------------------- Event Method
+
+ /**
+ * <p><span class="changed_modified_2_0">Call</span> through to the
+ * {@link MethodExpression} passed in our constructor. <span
+ * class="changed_added_2_0">First, try to invoke the
+ * <code>MethodExpression</code> passed to the constructor of this
+ * instance, passing the argument {@link FacesEvent} as the
+ * argument. If a {@link MethodNotFoundException} is thrown, call
+ * to the zero argument <code>MethodExpression</code> derived from
+ * the <code>MethodExpression</code> passed to the constructor of
+ * this instance. If that fails for any reason, throw an {@link
+ * AbortProcessingException}, including the cause of the
+ * failure.</span></p>
+ *
+ * @throws NullPointerException {@inheritDoc}
+ * @throws AbortProcessingException {@inheritDoc}
+ */
+ public void processEvent(FacesEvent event) throws AbortProcessingException {
+
+ if (event == null) {
+ throw new NullPointerException();
+ }
+ FacesContext context = FacesContext.getCurrentInstance();
+ ELContext elContext = context.getELContext();
+ // PENDING: The corresponding code in MethodExpressionActionListener
+ // has an elaborate message capture, logging, and rethrowing block.
+ // Why not here?
+ try {
+ methodExpressionOneArg.invoke(elContext, new Object[] {event});
+ } catch (MethodNotFoundException mnf) {
+ if (null != methodExpressionZeroArg) {
+
+ try {
+ // try to invoke a no-arg version
+ methodExpressionZeroArg.invoke(elContext, NO_PARAMS);
+ } catch (ELException e) {
+ throw new AbortProcessingException(e.getMessage(), e.getCause());
+ }
+ }
+ } catch (ELException e) {
+ throw new AbortProcessingException(e.getMessage(), e.getCause());
+ }
+ }
+
+
+ // ------------------------------------------------ Methods from StateHolder
+
+
+ /**
+ * <p class="changed_modified_2_0">Both {@link MethodExpression}
+ * instances described in the constructor must be saved.</p>
+ */
+ public Object saveState(FacesContext context) {
+ if (context == null) {
+ throw new NullPointerException();
+ }
+
+ return new Object[] {
+ UIComponentBase.saveAttachedState(context, methodExpressionOneArg),
+ UIComponentBase.saveAttachedState(context, methodExpressionZeroArg)
+ };
+ }
+
+
+ /**
+ * <p class="changed_modified_2_0">Both {@link MethodExpression}
+ * instances described in the constructor must be restored.</p>
+ */
+ public void restoreState(FacesContext context, Object state) {
+
+ if (context == null) {
+ throw new NullPointerException();
+ }
+ if (state == null) {
+ return;
+ }
+
+ methodExpressionOneArg = (MethodExpression) UIComponentBase
+ .restoreAttachedState(context, ((Object[]) state)[0]);
+ methodExpressionZeroArg = (MethodExpression) UIComponentBase
+ .restoreAttachedState(context, ((Object[]) state)[1]);
+ }
+
+
+ public boolean isTransient() {
+ return isTransient;
+ }
+
+ public void setTransient(boolean newTransientValue) {
+ isTransient = newTransientValue;
+ }
+}
Added: trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/CollapsiblePanelRenderer.java
===================================================================
--- trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/CollapsiblePanelRenderer.java (rev 0)
+++ trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/CollapsiblePanelRenderer.java 2010-08-31 15:51:59 UTC (rev 19045)
@@ -0,0 +1,235 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, 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.html;
+
+import org.ajax4jsf.javascript.JSObject;
+import org.richfaces.component.AbstractCollapsiblePanel;
+import org.richfaces.component.AbstractTogglePanel;
+
+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.List;
+import java.util.Map;
+
+import static org.richfaces.component.util.HtmlUtil.concatClasses;
+import static org.richfaces.component.util.HtmlUtil.concatStyles;
+
+/**
+ * @author akolonitsky
+ * @since 2010-08-27
+ */
+@ResourceDependencies( {
+ @ResourceDependency(library = "javax.faces", name = "jsf.js"),
+ @ResourceDependency(name = "jquery.js"),
+ @ResourceDependency(name = "richfaces.js"),
+ @ResourceDependency(name = "richfaces-event.js"),
+ @ResourceDependency(name = "richfaces-base-component.js"),
+ @ResourceDependency(library = "org.richfaces", name = "TogglePanel.js"),
+ @ResourceDependency(library = "org.richfaces", name = "TogglePanelItem.js"),
+ @ResourceDependency(library = "org.richfaces", name = "CollapsiblePanel.js"),
+ @ResourceDependency(library = "org.richfaces", name = "CollapsiblePanelItem.js"),
+ @ResourceDependency(library = "org.richfaces", name = "collapsiblePanel.ecss") })
+public class CollapsiblePanelRenderer extends TogglePanelRenderer {
+
+ public static final String SWITCH = "switch";
+ public static final String BEFORE_SWITCH = "beforeswitch";
+
+ @Override
+ protected void doDecode(FacesContext context, UIComponent component) {
+ AbstractTogglePanel panel = (AbstractTogglePanel) component;
+
+ Map<String, String> requestMap =
+ context.getExternalContext().getRequestParameterMap();
+
+ // Don't overwrite the value unless you have to!
+ String newValue = requestMap.get(getValueRequestParamName(context, component));
+ if (newValue != null) {
+ panel.setSubmittedActiveItem(newValue);
+ }
+
+ String compClientId = component.getClientId(context);
+ String clientId = requestMap.get(compClientId);
+ if (clientId != null && clientId.equals(compClientId)) {
+ String itemClientId = clientId + (Boolean.parseBoolean(newValue) ? ":content" : ":empty");
+ context.getPartialViewContext().getRenderIds().add(itemClientId);
+
+ //TODO nick - this should be done on encode, not on decode
+ addOnCompleteParam(newValue, panel.getClientId());
+ }
+ }
+
+ @Override
+ protected void doEncodeBegin(ResponseWriter writer, FacesContext context, UIComponent comp) throws IOException {
+ super.doEncodeBegin(writer, context, comp);
+
+ encodeHeader(context, comp, writer);
+ }
+
+ @Override
+ protected String getStyleClass(UIComponent component) {
+ return concatClasses("rf-cp", super.getStyleClass(component));
+ }
+
+ @Override
+ protected JSObject getScriptObject(FacesContext context, UIComponent component) {
+ return new JSObject("RichFaces.ui.CollapsiblePanel",
+ component.getClientId(), getScriptObjectOptions(context, component));
+ }
+
+ @Override
+ protected Map<String, Object> getScriptObjectOptions(FacesContext context, UIComponent component) {
+ AbstractTogglePanel panel = (AbstractTogglePanel) component;
+
+ Map<String, Object> options = super.getScriptObjectOptions(context, component);
+ options.put("switchMode", panel.getSwitchType());
+
+// TogglePanelRenderer.addEventOption(context, panel, options, SWITCH);
+// TogglePanelRenderer.addEventOption(context, panel, options, BEFORE_SWITCH);
+
+ return options;
+ }
+
+ private void encodeHeader(FacesContext context, UIComponent component, ResponseWriter writer) throws IOException {
+ writer.startElement("div", component);
+ writer.writeAttribute("id", component.getClientId(context) + ":header", null);
+ writer.writeAttribute("class", concatClasses("rf-cp-hr", attributeAsString(component, "headerClass")), null);
+
+ AbstractCollapsiblePanel panel = (AbstractCollapsiblePanel) component;
+ encodeHeader(context, component, writer, "expanded", panel.isExpanded());
+ encodeHeader(context, component, writer, "collapsed", !panel.isExpanded());
+
+ writer.endElement("div");
+ }
+
+ private void encodeHeader(FacesContext context, UIComponent component, ResponseWriter responseWriter, String state, boolean isVisible) throws IOException {
+ responseWriter.startElement("div", component);
+ responseWriter.writeAttribute("class", "rf-cp-hr-" + state, null);
+ responseWriter.writeAttribute("style", concatStyles(styleElement("display", isVisible ? "" : "none"), attributeAsString(component, "headerClass")), null);
+
+ UIComponent header = component.getFacet("header" + capitalize(state));
+ if (header != null && header.isRendered()) {
+ header.encodeAll(context);
+ } else {
+ String headerText = (String) component.getAttributes().get("header");
+ if (headerText != null && !headerText.isEmpty()) {
+ responseWriter.writeText(headerText, null);
+ }
+ }
+
+ responseWriter.endElement("div");
+ }
+
+ @Override
+ protected void doEncodeChildren(ResponseWriter writer, FacesContext context, UIComponent component)
+ throws IOException {
+
+ AbstractCollapsiblePanel panel = (AbstractCollapsiblePanel) component;
+
+ encodeContentChild(writer, context, component, panel);
+ encodeEmptyChild(writer, context, component, panel);
+ }
+
+ private void encodeContentChild(ResponseWriter writer, FacesContext context, UIComponent component, AbstractCollapsiblePanel panel) throws IOException {
+ if (panel.isExpanded()) {
+ encodeContent(writer, context, component, true);
+ } else {
+ switch (panel.getSwitchType()) {
+ case client:
+ encodeContent(writer, context, component, false);
+ break;
+
+ case ajax:
+ context.getResponseWriter().write(getPlaceHolder(panel.getClientId() + ":content"));
+ break;
+
+ case server:
+ // Do nothing.
+ break;
+
+ default:
+ throw new IllegalStateException("Unknown switch type : " + panel.getSwitchType());
+ }
+ }
+ }
+
+ private void encodeEmptyChild(ResponseWriter writer, FacesContext context, UIComponent component, AbstractCollapsiblePanel panel) throws IOException {
+ if (!panel.isExpanded()) {
+ encodeEmptyDiv(writer, context, component, true);
+ } else {
+ switch (panel.getSwitchType()) {
+ case client:
+ encodeEmptyDiv(writer, context, component, false);
+ break;
+
+ case ajax:
+ context.getResponseWriter().write(getPlaceHolder(panel.getClientId() + ":empty"));
+ break;
+
+ case server:
+ // Do nothing.
+ break;
+
+ default:
+ throw new IllegalStateException("Unknown switch type : " + panel.getSwitchType());
+ }
+ }
+ }
+
+ private String getPlaceHolder(String id) {
+ return "<div id=\"" + id + "\" style=\"display: none\" ></div>";
+ }
+
+ private void encodeContent(ResponseWriter writer, FacesContext context, UIComponent component, boolean visible) throws IOException {
+ writer.startElement("div", component);
+ writer.writeAttribute("id", component.getClientId() + ":content", null);
+ writer.writeAttribute("class", concatClasses("rf-cp-b", attributeAsString(component, "bodyClass")), null);
+ writer.writeAttribute("style", concatStyles(visible ? "" : "none", attributeAsString(component, "style")), null);
+
+ renderChildren(context, component);
+
+ writer.endElement("div");
+ }
+
+ private void encodeEmptyDiv(ResponseWriter writer, FacesContext context, UIComponent component, boolean visible) throws IOException {
+ writer.startElement("div", component);
+ writer.writeAttribute("id", component.getClientId() + ":empty", null);
+ writer.writeAttribute("class", "rf-cp-empty", null);
+ writer.writeAttribute("style", styleElement("display", visible ? "" : "none"), null);
+ writer.endElement("div");
+ }
+
+ @Override
+ protected List<JSObject> getChildrenScriptObjects(FacesContext context, UIComponent component) {
+ return null;
+ }
+
+ @Override
+ protected Class<? extends UIComponent> getComponentClass() {
+ return AbstractCollapsiblePanel.class;
+ }
+}
+
Modified: trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/DivPanelRenderer.java
===================================================================
--- trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/DivPanelRenderer.java 2010-08-31 14:36:18 UTC (rev 19044)
+++ trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/DivPanelRenderer.java 2010-08-31 15:51:59 UTC (rev 19045)
@@ -62,12 +62,18 @@
return "";
}
+ return styleElement(attr, value);
+ }
+
+ protected static String styleElement(Object name, Object value) {
return new StringBuilder()
- .append(attr).append(':').append(value).toString();
+ .append(name).append(':').append(value).toString();
}
+
protected static String attributeAsString(UIComponent comp, Enum attr) {
return attributeAsString(comp, attr.toString());
}
+
protected static String attributeAsString(UIComponent comp, String attr) {
Object o = comp.getAttributes().get(attr);
return o == null ? "" : o.toString();
Modified: trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/TogglePanelRenderer.java
===================================================================
--- trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/TogglePanelRenderer.java 2010-08-31 14:36:18 UTC (rev 19044)
+++ trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/TogglePanelRenderer.java 2010-08-31 15:51:59 UTC (rev 19045)
@@ -60,7 +60,7 @@
@ResourceDependency(library = "org.richfaces", name = "TogglePanel.js") })
public class TogglePanelRenderer extends DivPanelRenderer {
- private static final String VALUE_POSTFIX = "-value";
+ public static final String VALUE_POSTFIX = "-value";
private static final String ON = "on";
private static final String ITEM_CHANGE = "itemchange";
@@ -74,7 +74,7 @@
context.getExternalContext().getRequestParameterMap();
// Don't overwrite the value unless you have to!
- String newValue = requestMap.get(getActiveItemRequestParamName(context, component));
+ String newValue = requestMap.get(getValueRequestParamName(context, component));
if (newValue != null) {
panel.setSubmittedActiveItem(newValue);
}
@@ -92,7 +92,7 @@
}
}
- private static void addOnCompleteParam(String newValue, String panelId) {
+ protected static void addOnCompleteParam(String newValue, String panelId) {
StringBuilder onComplete = new StringBuilder();
onComplete.append("RichFaces.$('").append(panelId)
.append("').onCompleteHandler('").append(newValue).append("');");
@@ -100,7 +100,7 @@
AjaxContext.getCurrentInstance().appendOncomplete(onComplete.toString());
}
- private static String getActiveItemRequestParamName(FacesContext context, UIComponent component) {
+ public static String getValueRequestParamName(FacesContext context, UIComponent component) {
return component.getClientId(context) + VALUE_POSTFIX;
}
@@ -114,8 +114,8 @@
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, getActiveItemRequestParamName(context, comp), null);
- writer.writeAttribute(HTML.NAME_ATTRIBUTE, getActiveItemRequestParamName(context, comp), null);
+ writer.writeAttribute(HTML.ID_ATTRIBUTE, getValueRequestParamName(context, comp), null);
+ writer.writeAttribute(HTML.NAME_ATTRIBUTE, getValueRequestParamName(context, comp), null);
writer.endElement(HTML.INPUT_ELEM);
}
@@ -127,7 +127,7 @@
@Override
protected void doEncodeChildren(ResponseWriter writer, FacesContext context, UIComponent component)
throws IOException {
-
+
renderChildren(context, component);
}
@@ -141,7 +141,7 @@
protected Map<String, Object> getScriptObjectOptions(FacesContext context, UIComponent component) {
AbstractTogglePanel panel = (AbstractTogglePanel) component;
- Map<String, Object> options = new HashMap<String, Object>(5);
+ Map<String, Object> options = new HashMap<String, Object>();
options.put("activeItem", panel.getActiveItem());
options.put("cycledSwitching", panel.isCycledSwitching());
options.put("items", getChildrenScriptObjects(context, panel));
@@ -155,7 +155,7 @@
public static void addEventOption(FacesContext context, UIComponent component, Map<String, Object> options,
String eventName) {
-
+
HandlersChain handlersChain = new HandlersChain(context, component);
handlersChain.addInlineHandlerFromAttribute(ON + eventName);
handlersChain.addBehaviors(eventName);
@@ -168,11 +168,11 @@
}
}
- private static AjaxEventOptions getAjaxOptions(FacesContext context, UIComponent panel) {
+ public static AjaxEventOptions getAjaxOptions(FacesContext context, UIComponent panel) {
return AjaxRendererUtils.buildEventOptions(context, panel);
}
- private List<JSObject> getChildrenScriptObjects(FacesContext context, UIComponent component) {
+ protected List<JSObject> getChildrenScriptObjects(FacesContext context, UIComponent component) {
List<JSObject> res = new ArrayList<JSObject>(component.getChildCount());
for (UIComponent child : component.getChildren()) {
res.add(getChildScriptObject(context, (AbstractTogglePanelItem) child));
Added: trunk/ui/output/ui/src/main/java/org/richfaces/view/facelets/html/ChangeExpandListenerHandler.java
===================================================================
--- trunk/ui/output/ui/src/main/java/org/richfaces/view/facelets/html/ChangeExpandListenerHandler.java (rev 0)
+++ trunk/ui/output/ui/src/main/java/org/richfaces/view/facelets/html/ChangeExpandListenerHandler.java 2010-08-31 15:51:59 UTC (rev 19045)
@@ -0,0 +1,70 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, 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.view.facelets.html;
+
+import org.richfaces.event.ChangeExpandEvent;
+import org.richfaces.event.ChangeExpandListener;
+import org.richfaces.event.ChangeExpandSource;
+
+import javax.el.ValueExpression;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.event.AbortProcessingException;
+import javax.faces.view.facelets.FaceletContext;
+import javax.faces.view.facelets.TagConfig;
+
+/**
+ *
+ * @author akolonitsky
+ * @version 1.0
+ */
+public final class ChangeExpandListenerHandler extends EventListenerHandler {
+
+ private static class LazyChangeExpandListener extends LazyEventListener<ChangeExpandListener> implements ChangeExpandListener {
+ private static final long serialVersionUID = -391020876192823200L;
+
+ LazyChangeExpandListener(String type, ValueExpression binding) {
+ super(type, binding);
+ }
+
+ public void processChangeExpand(ChangeExpandEvent event) throws AbortProcessingException {
+ processEvent(event);
+ }
+ }
+
+ public ChangeExpandListenerHandler(TagConfig config) {
+ super(config);
+ }
+
+ public void applyAttachedObject(FacesContext context, UIComponent parent) {
+ ValueExpression expression = null;
+ if (this.binding != null) {
+ FaceletContext ctx = (FaceletContext) context.getAttributes().get(FaceletContext.FACELET_CONTEXT_KEY);
+ expression = this.binding.getValueExpression(ctx, ChangeExpandListener.class);
+ }
+
+ ChangeExpandSource source = (ChangeExpandSource) parent;
+ source.addChangeExpandListener(new LazyChangeExpandListener(this.listenerType, expression));
+ }
+}
+
Added: trunk/ui/output/ui/src/main/java/org/richfaces/view/facelets/html/CollapsiblePanelTagHandler.java
===================================================================
--- trunk/ui/output/ui/src/main/java/org/richfaces/view/facelets/html/CollapsiblePanelTagHandler.java (rev 0)
+++ trunk/ui/output/ui/src/main/java/org/richfaces/view/facelets/html/CollapsiblePanelTagHandler.java 2010-08-31 15:51:59 UTC (rev 19045)
@@ -0,0 +1,92 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, 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.view.facelets.html;
+
+import org.richfaces.component.AbstractCollapsiblePanel;
+
+import org.richfaces.event.MethodExpressionChangeExpandListener;
+import org.richfaces.event.ChangeExpandEvent;
+
+import javax.faces.view.facelets.ComponentConfig;
+import javax.faces.view.facelets.ComponentHandler;
+import javax.faces.view.facelets.FaceletContext;
+import javax.faces.view.facelets.MetaRule;
+import javax.faces.view.facelets.MetaRuleset;
+import javax.faces.view.facelets.Metadata;
+import javax.faces.view.facelets.MetadataTarget;
+import javax.faces.view.facelets.TagAttribute;
+
+/**
+ * @author akolonitsky
+ * @since 2010-08-27
+ */
+public class CollapsiblePanelTagHandler extends ComponentHandler {
+
+ private static final MetaRule META_RULE = new CollapsiblePanelMetaRule();
+
+
+ public CollapsiblePanelTagHandler(ComponentConfig config) {
+ super(config);
+ }
+
+ @Override
+ protected MetaRuleset createMetaRuleset(Class type) {
+ MetaRuleset metaRuleset = super.createMetaRuleset(type);
+ metaRuleset.addRule(META_RULE);
+ return metaRuleset;
+ }
+
+ private static class CollapsiblePanelMetaRule extends MetaRule{
+
+ @Override
+ public Metadata applyRule(String name, TagAttribute attribute, MetadataTarget meta) {
+ if (meta.isTargetInstanceOf(AbstractCollapsiblePanel.class)) {
+ if ("changeExpandListener".equals(name)) {
+ return new ChangeExpandExpressionMetadata(attribute);
+ }
+
+ }
+ return null;
+ }
+ }
+
+ private static final class ChangeExpandExpressionMetadata extends Metadata {
+ private static final Class<?>[] CHANGE_EXPAND_SIG = new Class[] {ChangeExpandEvent.class };
+
+ private final TagAttribute attr;
+
+ ChangeExpandExpressionMetadata(TagAttribute attr) {
+ this.attr = attr;
+ }
+
+ @Override
+ public void applyMetadata(FaceletContext ctx, Object instance) {
+ ((AbstractCollapsiblePanel) instance).addChangeExpandListener(new MethodExpressionChangeExpandListener(
+ this.attr.getMethodExpression(ctx, null, CHANGE_EXPAND_SIG)));
+ }
+ }
+
+
+
+}
+
Added: trunk/ui/output/ui/src/main/java/org/richfaces/view/facelets/html/EventListenerHandler.java
===================================================================
--- trunk/ui/output/ui/src/main/java/org/richfaces/view/facelets/html/EventListenerHandler.java (rev 0)
+++ trunk/ui/output/ui/src/main/java/org/richfaces/view/facelets/html/EventListenerHandler.java 2010-08-31 15:51:59 UTC (rev 19045)
@@ -0,0 +1,145 @@
+/**
+ * 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 org.richfaces.component.AbstractCollapsiblePanel;
+
+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 java.io.IOException;
+import java.io.Serializable;
+
+/**
+ * @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: trunk/ui/output/ui/src/main/resources/META-INF/pn.faces-config.xml
===================================================================
--- trunk/ui/output/ui/src/main/resources/META-INF/pn.faces-config.xml 2010-08-31 14:36:18 UTC (rev 19044)
+++ trunk/ui/output/ui/src/main/resources/META-INF/pn.faces-config.xml 2010-08-31 15:51:59 UTC (rev 19045)
@@ -11,6 +11,61 @@
</behavior>
<component>
+ <component-type>org.richfaces.CollapsiblePanel</component-type>
+ <component-class>org.richfaces.component.html.HtmlCollapsiblePanel</component-class>
+ <property>
+ <description></description>
+ <property-name>switchType</property-name>
+ <property-class>org.richfaces.component.SwitchType</property-class>
+ </property>
+ <property>
+ <description></description>
+ <property-name>expanded</property-name>
+ <property-class>boolean</property-class>
+ </property>
+ <property>
+ <description></description>
+ <property-name>header</property-name>
+ <property-class>java.lang.String</property-class>
+ </property>
+ <property>
+ <description></description>
+ <property-name>bypassUpdates</property-name>
+ <property-class>boolean</property-class>
+ </property>
+ <property>
+ <description></description>
+ <property-name>limitToList</property-name>
+ <property-class>boolean</property-class>
+ </property>
+ <property>
+ <description></description>
+ <property-name>data</property-name>
+ <property-class>java.lang.Object</property-class>
+ </property>
+ <property>
+ <description></description>
+ <property-name>status</property-name>
+ <property-class>java.lang.String</property-class>
+ </property>
+ <property>
+ <description></description>
+ <property-name>execute</property-name>
+ <property-class>java.lang.Object</property-class>
+ </property>
+ <property>
+ <description></description>
+ <property-name>render</property-name>
+ <property-class>java.lang.Object</property-class>
+ </property>
+ <property>
+ <description></description>
+ <property-name>changeExpandListener</property-name>
+ <property-class>javax.el.MethodExpression</property-class>
+ </property>
+
+ </component>
+ <component>
<component-type>org.richfaces.TogglePanel</component-type>
<component-class>org.richfaces.component.html.HtmlTogglePanel</component-class>
<property>
@@ -604,6 +659,11 @@
<render-kit>
<render-kit-id>HTML_BASIC</render-kit-id>
<renderer>
+ <component-family>org.richfaces.CollapsiblePanel</component-family>
+ <renderer-type>org.richfaces.CollapsiblePanel</renderer-type>
+ <renderer-class>org.richfaces.renderkit.html.CollapsiblePanelRenderer</renderer-class>
+ </renderer>
+ <renderer>
<component-family>org.richfaces.TogglePanel</component-family>
<renderer-type>org.richfaces.TogglePanel</renderer-type>
<renderer-class>org.richfaces.renderkit.html.TogglePanelRenderer</renderer-class>
Modified: trunk/ui/output/ui/src/main/resources/META-INF/pn.taglib.xml
===================================================================
--- trunk/ui/output/ui/src/main/resources/META-INF/pn.taglib.xml 2010-08-31 14:36:18 UTC (rev 19044)
+++ trunk/ui/output/ui/src/main/resources/META-INF/pn.taglib.xml 2010-08-31 15:51:59 UTC (rev 19045)
@@ -29,6 +29,217 @@
</tag>
<tag>
+ <tag-name>collapsiblePanel</tag-name>
+ <component>
+ <component-type>org.richfaces.CollapsiblePanel</component-type>
+ <renderer-type>org.richfaces.CollapsiblePanel</renderer-type>
+ <handler-class>org.richfaces.view.facelets.html.CollapsiblePanelTagHandler</handler-class>
+ </component>
+ <attribute>
+ <description></description>
+ <name>switchType</name>
+ <type>org.richfaces.component.SwitchType</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>expanded</name>
+ <type>boolean</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>header</name>
+ <type>java.lang.String</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>bypassUpdates</name>
+ <type>boolean</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>limitToList</name>
+ <type>boolean</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>data</name>
+ <type>java.lang.Object</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>status</name>
+ <type>java.lang.String</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>execute</name>
+ <type>java.lang.Object</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>render</name>
+ <type>java.lang.Object</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>id</name>
+ <type>java.lang.String</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>binding</name>
+ <type>javax.faces.component.UIComponent</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>rendered</name>
+ <type>boolean</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>immediate</name>
+ <type>boolean</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>changeExpandListener</name>
+ <type>javax.el.MethodExpression</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>bodyClass</name>
+ <type>java.lang.String</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>headerClass</name>
+ <type>java.lang.String</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>headerControlClass</name>
+ <type>java.lang.String</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>oncomplete</name>
+ <type>java.lang.String</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>onbeforedomupdate</name>
+ <type>java.lang.String</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>ononswitch</name>
+ <type>java.lang.String</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>ononbeforeswitch</name>
+ <type>java.lang.String</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>lang</name>
+ <type>java.lang.String</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>title</name>
+ <type>java.lang.String</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>style</name>
+ <type>java.lang.String</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>styleClass</name>
+ <type>java.lang.String</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>dir</name>
+ <type>java.lang.String</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>onclick</name>
+ <type>java.lang.String</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>ondblclick</name>
+ <type>java.lang.String</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>onmousedown</name>
+ <type>java.lang.String</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>onmousemove</name>
+ <type>java.lang.String</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>onmouseout</name>
+ <type>java.lang.String</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>onmouseover</name>
+ <type>java.lang.String</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>onmouseup</name>
+ <type>java.lang.String</type>
+ </attribute>
+
+ </tag>
+ <tag>
+ <description>
+ Register a ChangeExpandListener instance on the UIComponent
+ associated with the closest parent UIComponent custom
+ action.
+ </description>
+ <tag-name>changeExpandListener</tag-name>
+ <handler-class>org.richfaces.view.facelets.html.ChangeExpandListenerHandler</handler-class>
+ <attribute>
+ <description>
+ Fully qualified Java class name of a
+ ChangeExpandListener to be created and registered.
+ </description>
+ <name>type</name>
+ <type>java.lang.String</type>
+ </attribute>
+ <attribute>
+ <description>
+ Value binding expression that evaluates to an object that
+ implements org.richfaces.event.ChangeExpandListener.
+ </description>
+ <name>binding</name>
+ <required>false</required>
+ <type>org.richfaces.event.ChangeExpandListener</type>
+ </attribute>
+ <attribute>
+ <description>
+ <p class="changed_added_2_0">If present, this attribute refers
+ to the value of one of the exposed attached objects within the
+ composite component inside of which this tag is nested.</p>
+ </description>
+ <name>for</name>
+ <required>false</required>
+ <type>java.lang.String</type>
+ </attribute>
+ </tag>
+
+ <tag>
<tag-name>togglePanel</tag-name>
<component>
<component-type>org.richfaces.TogglePanel</component-type>
@@ -37,6 +248,11 @@
</component>
<attribute>
<description></description>
+ <name>cycledSwitching</name>
+ <type>boolean</type>
+ </attribute>
+ <attribute>
+ <description></description>
<name>switchType</name>
<type>org.richfaces.component.SwitchType</type>
</attribute>
@@ -57,11 +273,6 @@
</attribute>
<attribute>
<description></description>
- <name>cycledSwitching</name>
- <type>boolean</type>
- </attribute>
- <attribute>
- <description></description>
<name>data</name>
<type>java.lang.Object</type>
</attribute>
@@ -219,7 +430,7 @@
<component>
<component-type>org.richfaces.TogglePanelItem</component-type>
<renderer-type>org.richfaces.TogglePanelItem</renderer-type>
-
+
</component>
<attribute>
<description></description>
@@ -324,10 +535,15 @@
<component>
<component-type>org.richfaces.Accordion</component-type>
<renderer-type>org.richfaces.Accordion</renderer-type>
-
+
</component>
<attribute>
<description></description>
+ <name>cycledSwitching</name>
+ <type>boolean</type>
+ </attribute>
+ <attribute>
+ <description></description>
<name>switchType</name>
<type>org.richfaces.component.SwitchType</type>
</attribute>
@@ -338,16 +554,6 @@
</attribute>
<attribute>
<description></description>
- <name>height</name>
- <type>java.lang.String</type>
- </attribute>
- <attribute>
- <description></description>
- <name>width</name>
- <type>java.lang.String</type>
- </attribute>
- <attribute>
- <description></description>
<name>bypassUpdates</name>
<type>boolean</type>
</attribute>
@@ -358,11 +564,6 @@
</attribute>
<attribute>
<description></description>
- <name>cycledSwitching</name>
- <type>boolean</type>
- </attribute>
- <attribute>
- <description></description>
<name>data</name>
<type>java.lang.Object</type>
</attribute>
@@ -408,6 +609,16 @@
</attribute>
<attribute>
<description></description>
+ <name>width</name>
+ <type>java.lang.String</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>height</name>
+ <type>java.lang.String</type>
+ </attribute>
+ <attribute>
+ <description></description>
<name>itemHeaderClassActive</name>
<type>java.lang.String</type>
</attribute>
@@ -509,7 +720,7 @@
<component>
<component-type>org.richfaces.TogglePanelTitledItem</component-type>
<renderer-type>org.richfaces.AccordionItem</renderer-type>
-
+
</component>
<attribute>
<description></description>
@@ -673,8 +884,4 @@
</attribute>
</tag>
-
-
-
-
</facelet-taglib>
Added: trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/CollapsiblePanel.js
===================================================================
--- trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/CollapsiblePanel.js (rev 0)
+++ trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/CollapsiblePanel.js 2010-08-31 15:51:59 UTC (rev 19045)
@@ -0,0 +1,84 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, 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.
+ */
+
+(function ($, rf) {
+
+ rf.ui = rf.ui || {};
+
+ rf.ui.CollapsiblePanel = rf.ui.TogglePanel.extendClass({
+
+ name:"CollapsiblePanel",
+
+ /**
+ * @class CollapsiblePanel
+ * @name CollapsiblePanel
+ *
+ * @constructor
+ * @param {String} componentId - component id
+ * @param {Hash} options - params
+ * */
+ init : function (componentId, options) {
+ rf.ui.TogglePanel.call(this, componentId, options);
+ this.switchMode = options.switchMode;
+
+ this.items = [
+ new RichFaces.ui.CollapsiblePanelItem(
+ this.id + ":content", {"index":0, "togglePanelId":this.id, "switchMode":this.switchMode, "name":"true"}),
+
+ new RichFaces.ui.CollapsiblePanelItem(
+ this.id + ":empty", {"index":1, "togglePanelId":this.id, "switchMode":this.switchMode, "name":"false"})
+ ];
+ this.options.cycledSwitching = true;
+
+ rf.Event.bindById(this.id + ":header", "click", this.__onHeaderClick, this)
+ },
+
+ switchPanel : function (to) {
+ this.switchToItem(to || "@next");
+ },
+
+ /***************************** Private Methods ********************************************************/
+
+ __onHeaderClick : function () {
+ this.switchToItem("@next");
+ },
+
+ __fireItemChange : function (oldItem, newItem) {
+ return new rf.Event.fireById(this.id, "switch", {
+ id: this.id,
+ isExpanded : newItem.getName()
+ });
+ },
+
+ __fireBeforeItemChange : function (oldItem, newItem) {
+ return rf.Event.fireById(this.id, "beforeswitch", {
+ id: this.id,
+ isExpanded : newItem.getName()
+ });
+ },
+
+
+ destroy: function () {
+ rf.ui.TogglePanel.destroy.call(this);
+ }
+ });
+})(jQuery, RichFaces);
Added: trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/CollapsiblePanelItem.js
===================================================================
--- trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/CollapsiblePanelItem.js (rev 0)
+++ trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/CollapsiblePanelItem.js 2010-08-31 15:51:59 UTC (rev 19045)
@@ -0,0 +1,60 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, 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.
+ */
+
+(function ($, rf) {
+
+ rf.ui = rf.ui || {};
+
+ rf.ui.CollapsiblePanelItem = rf.ui.TogglePanelItem.extendClass({
+
+ init : function (componentId, options) {
+ rf.ui.TogglePanelItem.call(this, componentId, options);
+ },
+
+ __enter : function () {
+ rf.getDomElement(this.id).style.display = "block";
+ this.__header(this.__state()).show();
+
+ return true;
+ },
+
+ __leave : function () {
+ rf.getDomElement(this.id).style.display = "none";
+ this.__header(this.__state()).hide();
+
+ return true;
+ },
+
+ __state : function () {
+ return this.getName() === "true" ? "expanded" : "collapsed";
+ },
+
+ __header : function (state) {
+ var res = $(rf.getDomElement(this.togglePanelId + ":header"));
+ if (state) {
+ return res.find(".rf-cp-hr-" + state);
+ }
+
+ return res;
+ }
+ });
+})(jQuery, RichFaces);
Modified: trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/TogglePanel.js
===================================================================
--- trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/TogglePanel.js 2010-08-31 14:36:18 UTC (rev 19044)
+++ trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/TogglePanel.js 2010-08-31 15:51:59 UTC (rev 19045)
@@ -111,7 +111,7 @@
this.__setActiveItem(newPanel.getName());
newPanel.__enter();
- this.__fireItemChange(oldPanel, newPanel);
+ this.comp.__fireItemChange(oldPanel, newPanel);
return true;
},
@@ -136,16 +136,6 @@
* */
__getValueInputId: function () {
return this.comp.id + "-value"
- },
-
- /********************* Events *************************/
-
- __fireItemChange : function (oldItem, newItem) {
- return new rf.Event.fireById(this.comp.id, "itemchange", {
- id: this.comp.id,
- oldItem : oldItem,
- newItem : newItem
- });
}
};
@@ -163,7 +153,6 @@
name:"TogglePanel",
init : function (componentId, options) {
- // call constructor of parent class
rf.BaseComponent.call(this, componentId);
this.attachToDom(componentId);
@@ -381,6 +370,15 @@
/**
* Fire Concealable Event
* */
+
+ __fireItemChange : function (oldItem, newItem) {
+ return new rf.Event.fireById(this.id, "itemchange", {
+ id: this.id,
+ oldItem : oldItem,
+ newItem : newItem
+ });
+ },
+
__fireBeforeItemChange : function (oldItem, newItem) {
return rf.Event.fireById(this.id, "beforeitemchange", {
id: this.id,
@@ -389,11 +387,8 @@
});
},
- // class stuff
destroy: function () {
- // rf.Event.unbindById(this.options.buttonId, "."+this.namespace);
- // rf.Event.unbindById(this.componentId, "."+this.namespace);
- // $super.destroy.call(this);
+ rf.BaseComponent.destroy.call(this);
}
});
})(jQuery, RichFaces);
Added: trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/collapsiblePanel.ecss
===================================================================
--- trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/collapsiblePanel.ecss (rev 0)
+++ trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/collapsiblePanel.ecss 2010-08-31 15:51:59 UTC (rev 19045)
@@ -0,0 +1,29 @@
+.rf-cp{
+ background-color:'#{richSkin.generalBackgroundColor}';
+ color:'#{richSkin.panelBorderColor}';
+ border-width:1px;
+ border-style:solid;
+ padding:1px;
+}
+
+.rf-cp-hr{
+ background-color:'#{richSkin.headerBackgroundColor}';
+ border-color:'#{richSkin.headerBackgroundColor}';
+ font-size:'#{richSkin.headerSizeFont}';
+ color:'#{richSkin.headerTextColor}';
+ font-weight:'#{richSkin.headerWeightFont}';
+ font-family:'#{richSkin.headerFamilyFont}';
+ padding:2px;
+ border-width:1px;
+ border-style:solid;
+ background-position:top left;
+ background-repeat:repeat-x;
+ background-image:"url(#{resource['org.richfaces.renderkit.html.GradientA']})";
+}
+
+.rf-cp-b{
+ font-size:'#{richSkin.generalSizeFont}';
+ color:'#{richSkin.generalTextColor}';
+ font-family:'#{richSkin.generalFamilyFont}';
+ padding:10px;
+}
\ No newline at end of file
14 years, 3 months