MFHTML5-18 Use myfaces commons utils 1.0.2 to prevent duplicated code
git-svn-id: https://svn.apache.org/repos/asf/myfaces/html5/trunk@1187465 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/myfaces-html5-core/pom.xml b/myfaces-html5-core/pom.xml
index 0963061..7ce764d 100644
--- a/myfaces-html5-core/pom.xml
+++ b/myfaces-html5-core/pom.xml
@@ -52,11 +52,6 @@
<version>${myfaces-commons20-version}</version>
</dependency>
<dependency>
- <groupId>org.apache.myfaces.commons</groupId>
- <artifactId>myfaces-components20</artifactId>
- <version>${myfaces-commons20-version}</version>
- </dependency>
- <dependency>
<groupId>org.apache.myfaces.buildtools</groupId>
<artifactId>myfaces-builder-annotations</artifactId>
<version>${myfaces-builder-annotations-version}</version>
@@ -421,7 +416,7 @@
</profiles>
<properties>
- <myfaces-commons20-version>1.0.1</myfaces-commons20-version>
+ <myfaces-commons20-version>1.0.2</myfaces-commons20-version>
<myfaces-builder-plugin-version>1.0.8</myfaces-builder-plugin-version>
<myfaces-builder-annotations-version>1.0.5</myfaces-builder-annotations-version>
</properties>
diff --git a/myfaces-html5-core/src/main/java/org/apache/myfaces/html5/component/output/AbstractSlide.java b/myfaces-html5-core/src/main/java/org/apache/myfaces/html5/component/output/AbstractSlide.java
index 1b3b476..fed3f6d 100644
--- a/myfaces-html5-core/src/main/java/org/apache/myfaces/html5/component/output/AbstractSlide.java
+++ b/myfaces-html5-core/src/main/java/org/apache/myfaces/html5/component/output/AbstractSlide.java
@@ -3,7 +3,7 @@
import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFComponent;
import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFProperty;
import org.apache.myfaces.html5.component.properties.*;
-import org.apache.myfaces.html5.component.util.ComponentUtils;
+import org.apache.myfaces.commons.util.ComponentUtils;
import javax.faces.component.NamingContainer;
import javax.faces.component.UIComponent;
diff --git a/myfaces-html5-core/src/main/java/org/apache/myfaces/html5/component/output/AbstractSlideView.java b/myfaces-html5-core/src/main/java/org/apache/myfaces/html5/component/output/AbstractSlideView.java
index eb2c798..93c9438 100644
--- a/myfaces-html5-core/src/main/java/org/apache/myfaces/html5/component/output/AbstractSlideView.java
+++ b/myfaces-html5-core/src/main/java/org/apache/myfaces/html5/component/output/AbstractSlideView.java
@@ -23,7 +23,7 @@
import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFProperty;
import org.apache.myfaces.html5.component.properties.*;
import org.apache.myfaces.html5.component.properties.effect.TransitionProperties;
-import org.apache.myfaces.html5.component.util.ComponentUtils;
+import org.apache.myfaces.commons.util.ComponentUtils;
import javax.faces.component.NamingContainer;
import javax.faces.component.UIComponent;
diff --git a/myfaces-html5-core/src/main/java/org/apache/myfaces/html5/component/util/ComponentUtils.java b/myfaces-html5-core/src/main/java/org/apache/myfaces/html5/component/util/ComponentUtils.java
deleted file mode 100644
index 47abc82..0000000
--- a/myfaces-html5-core/src/main/java/org/apache/myfaces/html5/component/util/ComponentUtils.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.myfaces.html5.component.util;
-
-import javax.faces.component.NamingContainer;
-import javax.faces.component.UIComponent;
-import javax.faces.component.UIViewRoot;
-
-public class ComponentUtils {
-
- public static UIComponent findParentNamingContainer(UIComponent component, boolean returnRootIfNotFound)
- {
- UIComponent parent = component.getParent();
- if (returnRootIfNotFound && parent == null)
- {
- return component;
- }
- while (parent != null)
- {
- if (parent instanceof NamingContainer)
- return parent;
- if (returnRootIfNotFound)
- {
- UIComponent nextParent = parent.getParent();
- if (nextParent == null)
- {
- return parent; // Root
- }
- parent = nextParent;
- }
- else
- {
- parent = parent.getParent();
- }
- }
- return null;
- }
-
- //copied from org.apache.myfaces.commons.exporter.util.ComponentUtils
- public static String getPathToComponent(UIComponent component) {
- StringBuffer buf = new StringBuffer();
-
- if (component == null)
- {
- buf.append("{Component-Path : ");
- buf.append("[null]}");
- return buf.toString();
- }
-
- getPathToComponent(component, buf);
-
- buf.insert(0, "{Component-Path : ");
- buf.append("}");
-
- return buf.toString();
- }
-
- //copied from org.apache.myfaces.commons.exporter.util.ComponentUtils
- private static void getPathToComponent(UIComponent component,
- StringBuffer buf) {
-
- if (component == null)
- return;
-
- StringBuffer intBuf = new StringBuffer();
-
- intBuf.append("[Class: ");
- intBuf.append(component.getClass().getName());
- if (component instanceof UIViewRoot)
- {
- intBuf.append(",ViewId: ");
- intBuf.append(((UIViewRoot) component).getViewId());
- }
- else
- {
- intBuf.append(",Id: ");
- intBuf.append(component.getId());
- }
- intBuf.append("]");
-
- buf.insert(0, intBuf.toString());
-
- getPathToComponent(component.getParent(), buf);
- }
-
-}
diff --git a/myfaces-html5-core/src/main/java/org/apache/myfaces/html5/handler/DragSourceBehaviorHandler.java b/myfaces-html5-core/src/main/java/org/apache/myfaces/html5/handler/DragSourceBehaviorHandler.java
index 974bf6f..bbb14a0 100644
--- a/myfaces-html5-core/src/main/java/org/apache/myfaces/html5/handler/DragSourceBehaviorHandler.java
+++ b/myfaces-html5-core/src/main/java/org/apache/myfaces/html5/handler/DragSourceBehaviorHandler.java
@@ -36,9 +36,9 @@
import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFFaceletAttribute;
import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFFaceletTag;
+import org.apache.myfaces.commons.util.DebugUtils;
import org.apache.myfaces.html5.behavior.DragSourceBehavior;
import org.apache.myfaces.html5.component.api.Draggable;
-import org.apache.myfaces.html5.component.util.ComponentUtils;
import org.apache.myfaces.html5.event.DropEvent;
import org.apache.myfaces.html5.renderkit.util.ClientBehaviorEvents;
@@ -102,7 +102,7 @@
if (!ComponentHandler.isNew(parent))
{
if (log.isLoggable(Level.FINE))
- log.fine("Component " + ComponentUtils.getPathToComponent(parent)
+ log.fine("Component " + DebugUtils.getPathToComponent(parent)
+ " is not new, thus return without any operation.");
return;
@@ -133,7 +133,7 @@
else
{
if (log.isLoggable(Level.WARNING))
- log.warning("Parent " + ComponentUtils.getPathToComponent(parent)
+ log.warning("Parent " + DebugUtils.getPathToComponent(parent)
+ " does not implement Draggable interface, thus unable to set the draggable attribute. "
+ "Renderer of the parent must handle the decision of being draggable manually.");
}
@@ -202,7 +202,7 @@
{
throw new TagException(getTag(),
"DragSourceBehavior must be attached to a ClientBehaviorHolder parent. Component "
- + ComponentUtils.getPathToComponent(parent) + "is not a ClientBehaviorHolder.");
+ + DebugUtils.getPathToComponent(parent) + "is not a ClientBehaviorHolder.");
}
ClientBehaviorHolder holder = (ClientBehaviorHolder) parent;
@@ -224,7 +224,7 @@
message.append("ClientBehaviorHolders that support the '");
message.append(eventName);
message.append("' event. The parent ClientBehaviorHolder "
- + ComponentUtils.getPathToComponent((UIComponent) holder) + " only ");
+ + DebugUtils.getPathToComponent((UIComponent) holder) + " only ");
message.append("supports the following events: ");
for (String supportedEventName : eventNames)
diff --git a/myfaces-html5-core/src/main/java/org/apache/myfaces/html5/handler/DropTargetBehaviorHandler.java b/myfaces-html5-core/src/main/java/org/apache/myfaces/html5/handler/DropTargetBehaviorHandler.java
index af022ac..855a788 100644
--- a/myfaces-html5-core/src/main/java/org/apache/myfaces/html5/handler/DropTargetBehaviorHandler.java
+++ b/myfaces-html5-core/src/main/java/org/apache/myfaces/html5/handler/DropTargetBehaviorHandler.java
@@ -37,8 +37,8 @@
import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFFaceletAttribute;
import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFFaceletTag;
+import org.apache.myfaces.commons.util.DebugUtils;
import org.apache.myfaces.html5.behavior.DropTargetBehavior;
-import org.apache.myfaces.html5.component.util.ComponentUtils;
import org.apache.myfaces.html5.event.DropEvent;
import org.apache.myfaces.html5.event.DropListener;
import org.apache.myfaces.html5.renderkit.behavior.DropTargetBehaviorRenderer;
@@ -166,7 +166,7 @@
if (!ComponentHandler.isNew(parent))
{
if (log.isLoggable(Level.FINE))
- log.fine("Component" + ComponentUtils.getPathToComponent(parent)
+ log.fine("Component" + DebugUtils.getPathToComponent(parent)
+ " is not new, thus return without any operation.");
return;
}
@@ -275,7 +275,7 @@
{
throw new TagException(getTag(),
"DropTargetBehavior must be attached to a ClientBehaviorHolder parent. Component "
- + ComponentUtils.getPathToComponent(parent) + "is not a ClientBehaviorHolder");
+ + DebugUtils.getPathToComponent(parent) + "is not a ClientBehaviorHolder");
}
ClientBehaviorHolder holder = (ClientBehaviorHolder) parent;
@@ -299,7 +299,7 @@
message.append("ClientBehaviorHolders that support the '");
message.append(eventName);
message.append("' event. The parent ClientBehaviorHolder "
- + ComponentUtils.getPathToComponent((UIComponent) holder) + " only ");
+ + DebugUtils.getPathToComponent((UIComponent) holder) + " only ");
message.append("supports the following events: ");
for (String supportedEventName : eventNames)
diff --git a/myfaces-html5-core/src/main/java/org/apache/myfaces/html5/handler/MediaSourceHandler.java b/myfaces-html5-core/src/main/java/org/apache/myfaces/html5/handler/MediaSourceHandler.java
index 456788f..750b261 100644
--- a/myfaces-html5-core/src/main/java/org/apache/myfaces/html5/handler/MediaSourceHandler.java
+++ b/myfaces-html5-core/src/main/java/org/apache/myfaces/html5/handler/MediaSourceHandler.java
@@ -30,7 +30,7 @@
import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFFaceletAttribute;
import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFFaceletTag;
-import org.apache.myfaces.html5.component.util.ComponentUtils;
+import org.apache.myfaces.commons.util.DebugUtils;
import org.apache.myfaces.html5.holder.MediaSourceHolder;
import org.apache.myfaces.html5.model.MediaInfo;
@@ -100,7 +100,7 @@
if (!(parent instanceof MediaSourceHolder))
{
if (log.isLoggable(Level.WARNING))
- log.warning("parent component " + ComponentUtils.getPathToComponent(parent) + " is not a MediaSourceHolder. handler will not apply anything.");
+ log.warning("parent component " + DebugUtils.getPathToComponent(parent) + " is not a MediaSourceHolder. handler will not apply anything.");
return;
}
else
diff --git a/myfaces-html5-core/src/main/java/org/apache/myfaces/html5/handler/MediaSourcesHandler.java b/myfaces-html5-core/src/main/java/org/apache/myfaces/html5/handler/MediaSourcesHandler.java
index b0593aa..b577e0e 100644
--- a/myfaces-html5-core/src/main/java/org/apache/myfaces/html5/handler/MediaSourcesHandler.java
+++ b/myfaces-html5-core/src/main/java/org/apache/myfaces/html5/handler/MediaSourcesHandler.java
@@ -32,7 +32,7 @@
import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFFaceletAttribute;
import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFFaceletTag;
-import org.apache.myfaces.html5.component.util.ComponentUtils;
+import org.apache.myfaces.commons.util.DebugUtils;
import org.apache.myfaces.html5.holder.MediaSourceHolder;
import org.apache.myfaces.html5.model.MediaInfo;
@@ -95,7 +95,7 @@
if (!(parent instanceof MediaSourceHolder))
{
if (log.isLoggable(Level.WARNING))
- log.warning("parent component " + ComponentUtils.getPathToComponent(parent) + " is not a MediaSourceHolder. handler will not apply anything.");
+ log.warning("parent component " + DebugUtils.getPathToComponent(parent) + " is not a MediaSourceHolder. handler will not apply anything.");
return;
}
diff --git a/myfaces-html5-core/src/main/java/org/apache/myfaces/html5/renderkit/input/HtmlInputColorRenderer.java b/myfaces-html5-core/src/main/java/org/apache/myfaces/html5/renderkit/input/HtmlInputColorRenderer.java
index c6aa118..aaf41cf 100644
--- a/myfaces-html5-core/src/main/java/org/apache/myfaces/html5/renderkit/input/HtmlInputColorRenderer.java
+++ b/myfaces-html5-core/src/main/java/org/apache/myfaces/html5/renderkit/input/HtmlInputColorRenderer.java
@@ -29,9 +29,9 @@
import javax.faces.convert.ConverterException;
import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFRenderer;
+import org.apache.myfaces.commons.util.DebugUtils;
import org.apache.myfaces.html5.component.input.Html5BaseInputText;
import org.apache.myfaces.html5.component.input.HtmlInputColor;
-import org.apache.myfaces.html5.component.util.ComponentUtils;
import org.apache.myfaces.html5.renderkit.input.delegate.HtmlTextInputSuggestionRendererHelper;
import org.apache.myfaces.html5.renderkit.input.delegate.SuggestionRendererHelper;
import org.apache.myfaces.html5.renderkit.util.HTML5;
@@ -65,7 +65,7 @@
if (submittedValue != null && !(submittedValue instanceof String))
{
throw new IllegalArgumentException("Submitted value of type String for component : "
- + ComponentUtils.getPathToComponent(uiComponent) + "expected");
+ + DebugUtils.getPathToComponent(uiComponent) + "expected");
}
RendererUtils.checkParamValidity(facesContext, uiComponent, HtmlInputColor.class);
@@ -153,7 +153,7 @@
// new Object[] { _MessageUtils.getLabel(facesContext,
// uiComponent) }));
// XXX: externalize and localize the message later!
- throw new ConverterException(new FacesMessage("Provided value for component " + ComponentUtils.getPathToComponent(uiComponent) + " is not a valid simple color: "
+ throw new ConverterException(new FacesMessage("Provided value for component " + DebugUtils.getPathToComponent(uiComponent) + " is not a valid simple color: "
+ value));
}
}
diff --git a/myfaces-html5-core/src/main/java/org/apache/myfaces/html5/renderkit/input/HtmlInputDateTimeRenderer.java b/myfaces-html5-core/src/main/java/org/apache/myfaces/html5/renderkit/input/HtmlInputDateTimeRenderer.java
index b1d4890..a67dfc6 100644
--- a/myfaces-html5-core/src/main/java/org/apache/myfaces/html5/renderkit/input/HtmlInputDateTimeRenderer.java
+++ b/myfaces-html5-core/src/main/java/org/apache/myfaces/html5/renderkit/input/HtmlInputDateTimeRenderer.java
@@ -36,9 +36,9 @@
import javax.faces.validator.Validator;
import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFRenderer;
+import org.apache.myfaces.commons.util.DebugUtils;
import org.apache.myfaces.html5.component.input.Html5BaseInputText;
import org.apache.myfaces.html5.component.input.HtmlInputDateTime;
-import org.apache.myfaces.html5.component.util.ComponentUtils;
import org.apache.myfaces.html5.renderkit.input.delegate.HtmlTextInputSuggestionRendererHelper;
import org.apache.myfaces.html5.renderkit.input.delegate.SuggestionRendererHelper;
import org.apache.myfaces.html5.renderkit.input.util.Html5DateTimeConverter;
@@ -84,7 +84,7 @@
if (submittedValue != null && !(submittedValue instanceof String))
{
throw new IllegalArgumentException("Submitted value of type String for component : "
- + ComponentUtils.getPathToComponent(uiComponent) + " expected");
+ + DebugUtils.getPathToComponent(uiComponent) + " expected");
}
RendererUtils.checkParamValidity(facesContext, uiComponent, HtmlInputDateTime.class);
@@ -130,7 +130,7 @@
else if (step < 0)
{
throw new FacesException("'step' cannot be negative for component "
- + ComponentUtils.getPathToComponent(uiComponent) + ". Provided " + step);
+ + DebugUtils.getPathToComponent(uiComponent) + ". Provided " + step);
}
else
{
@@ -164,7 +164,7 @@
}
catch (ParseException e)
{
- throw new FacesException("Unable to resolve minimum value of component " + ComponentUtils.getPathToComponent(component) + ".", e);
+ throw new FacesException("Unable to resolve minimum value of component " + DebugUtils.getPathToComponent(component) + ".", e);
}
if (minimum != null)
return Html5DateTimeFormatUtils.formatDateTime(minimum, component.getType());
@@ -193,7 +193,7 @@
catch (ParseException e)
{
throw new FacesException("Unable to resolve maximum value of component "
- + ComponentUtils.getPathToComponent(component) + ".", e);
+ + DebugUtils.getPathToComponent(component) + ".", e);
}
if (maximum != null)
return Html5DateTimeFormatUtils.formatDateTime(maximum, component.getType());
@@ -244,7 +244,7 @@
{
if (!(Arrays.asList(ALLOWED_INPUT_TYPES).contains(type)))
throw new FacesException("\"type\" attribute of component "
- + ComponentUtils.getPathToComponent(uiComponent) + " can be one of "
+ + DebugUtils.getPathToComponent(uiComponent) + " can be one of "
+ Arrays.toString(ALLOWED_INPUT_TYPES) + " . Provided: \"" + type + "\"");
}
}
diff --git a/myfaces-html5-core/src/main/java/org/apache/myfaces/html5/renderkit/input/HtmlInputEmailRenderer.java b/myfaces-html5-core/src/main/java/org/apache/myfaces/html5/renderkit/input/HtmlInputEmailRenderer.java
index b00a3cb..1b8af0a 100644
--- a/myfaces-html5-core/src/main/java/org/apache/myfaces/html5/renderkit/input/HtmlInputEmailRenderer.java
+++ b/myfaces-html5-core/src/main/java/org/apache/myfaces/html5/renderkit/input/HtmlInputEmailRenderer.java
@@ -27,9 +27,9 @@
import javax.faces.convert.ConverterException;
import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFRenderer;
+import org.apache.myfaces.commons.util.DebugUtils;
import org.apache.myfaces.html5.component.HtmlInputEmail;
import org.apache.myfaces.html5.component.input.Html5BaseInputText;
-import org.apache.myfaces.html5.component.util.ComponentUtils;
import org.apache.myfaces.html5.renderkit.input.delegate.HtmlTextInputSuggestionRendererHelper;
import org.apache.myfaces.html5.renderkit.input.delegate.SuggestionRendererHelper;
import org.apache.myfaces.html5.renderkit.input.util.Html5EmailConverter;
@@ -58,7 +58,7 @@
if (submittedValue != null && !(submittedValue instanceof String))
{
throw new IllegalArgumentException("Submitted value of type String for component : "
- + ComponentUtils.getPathToComponent(uiComponent) + " expected");
+ + DebugUtils.getPathToComponent(uiComponent) + " expected");
}
RendererUtils.checkParamValidity(facesContext, uiComponent, HtmlInputEmail.class);
diff --git a/myfaces-html5-core/src/main/java/org/apache/myfaces/html5/renderkit/input/HtmlInputNumberSliderRenderer.java b/myfaces-html5-core/src/main/java/org/apache/myfaces/html5/renderkit/input/HtmlInputNumberSliderRenderer.java
index fc3c164..4a6befc 100644
--- a/myfaces-html5-core/src/main/java/org/apache/myfaces/html5/renderkit/input/HtmlInputNumberSliderRenderer.java
+++ b/myfaces-html5-core/src/main/java/org/apache/myfaces/html5/renderkit/input/HtmlInputNumberSliderRenderer.java
@@ -30,9 +30,9 @@
import javax.faces.validator.Validator;
import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFRenderer;
+import org.apache.myfaces.commons.util.DebugUtils;
import org.apache.myfaces.html5.component.input.Html5BaseInputText;
import org.apache.myfaces.html5.component.input.HtmlInputNumberSlider;
-import org.apache.myfaces.html5.component.util.ComponentUtils;
import org.apache.myfaces.html5.renderkit.input.delegate.HtmlTextInputSuggestionRendererHelper;
import org.apache.myfaces.html5.renderkit.input.delegate.SuggestionRendererHelper;
import org.apache.myfaces.html5.renderkit.util.HTML5;
@@ -89,7 +89,7 @@
if (max <= min)
{
- throw new FacesException("Maximum must be larger than minimum for component " + ComponentUtils.getPathToComponent(uiComponent) + ". "
+ throw new FacesException("Maximum must be larger than minimum for component " + DebugUtils.getPathToComponent(uiComponent) + ". "
+ "These values are calculated from the first attached DoubleRangeValidator or LongRangeValidator");
}
@@ -116,14 +116,14 @@
if (step != Double.MIN_VALUE && segmentCount != Integer.MIN_VALUE)
{ // if both are set
throw new FacesException(
- "Only one of 'step' or 'segmentCount' properties must be defined for component " + ComponentUtils.getPathToComponent(component) + ". Undefined one will be calculated.");
+ "Only one of 'step' or 'segmentCount' properties must be defined for component " + DebugUtils.getPathToComponent(component) + ". Undefined one will be calculated.");
}
if (step != Double.MIN_VALUE)
{ // if only step is set
if (step <= 0)
{ // if it is set but it is negative
- throw new FacesException("'step' property of component " + ComponentUtils.getPathToComponent(component) + " must be positive");
+ throw new FacesException("'step' property of component " + DebugUtils.getPathToComponent(component) + " must be positive");
}
calculatedStep = step;
}
@@ -131,7 +131,7 @@
{ // if only segmentCount is set
if (segmentCount <= 0)
{ // if it is set but it is negative
- throw new FacesException("'segmentCount' property of component " + ComponentUtils.getPathToComponent(
+ throw new FacesException("'segmentCount' property of component " + DebugUtils.getPathToComponent(
component) + " must be positive");
}
calculatedStep = (max - min) / segmentCount;
diff --git a/myfaces-html5-core/src/main/java/org/apache/myfaces/html5/renderkit/input/HtmlInputTextRenderer.java b/myfaces-html5-core/src/main/java/org/apache/myfaces/html5/renderkit/input/HtmlInputTextRenderer.java
index f74e143..21f08a2 100644
--- a/myfaces-html5-core/src/main/java/org/apache/myfaces/html5/renderkit/input/HtmlInputTextRenderer.java
+++ b/myfaces-html5-core/src/main/java/org/apache/myfaces/html5/renderkit/input/HtmlInputTextRenderer.java
@@ -30,8 +30,8 @@
import javax.faces.render.Renderer;
import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFRenderer;
+import org.apache.myfaces.commons.util.DebugUtils;
import org.apache.myfaces.html5.component.input.HtmlInputText;
-import org.apache.myfaces.html5.component.util.ComponentUtils;
import org.apache.myfaces.html5.renderkit.input.delegate.HtmlInputTextRendererDelegate;
import org.apache.myfaces.html5.renderkit.input.delegate.HtmlTextAreaRendererDelegate;
import org.apache.myfaces.html5.renderkit.util.JsfProperties;
@@ -111,7 +111,7 @@
}
else
{
- throw new IllegalStateException("Input type of component " + ComponentUtils.getPathToComponent(component) + " is not one of the expected types: \""
+ throw new IllegalStateException("Input type of component " + DebugUtils.getPathToComponent(component) + " is not one of the expected types: \""
+ JsfProperties.INPUTTEXT_TYPE_TEXT + "\", \"" + JsfProperties.INPUTTEXT_TYPE_SEARCH + "\", \""
+ JsfProperties.INPUTTEXT_TYPE_URL + "\" ,\"" + JsfProperties.INPUTTEXT_TYPE_TEL + "\". Provided: \""
+ type + "\".");
@@ -184,7 +184,7 @@
else
{
if (!(Arrays.asList(ALLOWED_INPUT_TYPES).contains(type)))
- throw new FacesException("\"type\" attribute of component " + ComponentUtils.getPathToComponent(uiComponent) + " can be one of " + Arrays.toString(ALLOWED_INPUT_TYPES)
+ throw new FacesException("\"type\" attribute of component " + DebugUtils.getPathToComponent(uiComponent) + " can be one of " + Arrays.toString(ALLOWED_INPUT_TYPES)
+ ". You provided: \"" + type + "\"");
}
}
diff --git a/myfaces-html5-core/src/main/java/org/apache/myfaces/html5/renderkit/input/delegate/HtmlDataListSuggestionRendererHelper.java b/myfaces-html5-core/src/main/java/org/apache/myfaces/html5/renderkit/input/delegate/HtmlDataListSuggestionRendererHelper.java
index 45f2a4a..922e624 100644
--- a/myfaces-html5-core/src/main/java/org/apache/myfaces/html5/renderkit/input/delegate/HtmlDataListSuggestionRendererHelper.java
+++ b/myfaces-html5-core/src/main/java/org/apache/myfaces/html5/renderkit/input/delegate/HtmlDataListSuggestionRendererHelper.java
@@ -27,11 +27,10 @@
import javax.faces.convert.Converter;
import javax.faces.model.SelectItem;
+import org.apache.myfaces.commons.util.DebugUtils;
import org.apache.myfaces.html5.component.input.HtmlDataList;
-import org.apache.myfaces.html5.component.util.ComponentUtils;
import org.apache.myfaces.html5.renderkit.util.HTML5;
import org.apache.myfaces.html5.renderkit.util.JsfProperties;
-import org.apache.myfaces.html5.renderkit.util.RendererUtils;
/**
* Implementation of {@link SuggestionRendererHelper} for usage in {@link org.apache.myfaces.html5.component.input.HtmlDataList}s.
@@ -94,7 +93,7 @@
else
{
throw new IllegalArgumentException(
- "Component " + ComponentUtils.getPathToComponent(uiComponent) + " is not instance of HtmlDataList. HtmlDataListSuggestionRendererHelper is unable to render options of suggestions attr.");
+ "Component " + DebugUtils.getPathToComponent(uiComponent) + " is not instance of HtmlDataList. HtmlDataListSuggestionRendererHelper is unable to render options of suggestions attr.");
}
}
diff --git a/myfaces-html5-core/src/main/java/org/apache/myfaces/html5/renderkit/input/delegate/HtmlTextInputSuggestionRendererHelper.java b/myfaces-html5-core/src/main/java/org/apache/myfaces/html5/renderkit/input/delegate/HtmlTextInputSuggestionRendererHelper.java
index 8b5614f..0c1200c 100644
--- a/myfaces-html5-core/src/main/java/org/apache/myfaces/html5/renderkit/input/delegate/HtmlTextInputSuggestionRendererHelper.java
+++ b/myfaces-html5-core/src/main/java/org/apache/myfaces/html5/renderkit/input/delegate/HtmlTextInputSuggestionRendererHelper.java
@@ -34,13 +34,13 @@
import javax.faces.convert.Converter;
import javax.faces.model.SelectItem;
+import org.apache.myfaces.commons.util.DebugUtils;
+import org.apache.myfaces.commons.util.SelectItemsIterator;
import org.apache.myfaces.html5.component.input.Html5BaseInputText;
import org.apache.myfaces.html5.component.input.HtmlInputText;
-import org.apache.myfaces.html5.component.util.ComponentUtils;
import org.apache.myfaces.html5.renderkit.util.HTML5;
import org.apache.myfaces.html5.renderkit.util.JsfProperties;
import org.apache.myfaces.html5.renderkit.util.RendererUtils;
-import org.apache.myfaces.html5.renderkit.util.SelectItemsIterator;
/**
* Implementation of {@link SuggestionRendererHelper} for usage in {@link HtmlInputText}s.
@@ -76,13 +76,13 @@
{
// WIKI: put a wiki page about this error
throw new FacesException(
- "Either \"list\" attribute or \"suggestions\" attribute and children with type SelectItem mechanism can be used for suggestions. Component " + ComponentUtils.getPathToComponent(uiComponent) + "has both!");
+ "Either \"list\" attribute or \"suggestions\" attribute and children with type SelectItem mechanism can be used for suggestions. Component " + DebugUtils.getPathToComponent(uiComponent) + "has both!");
}
}
else
{
throw new IllegalArgumentException(
- "Component " + ComponentUtils.getPathToComponent(uiComponent) + " is not instance of Html5BaseInputText. HtmlTextInputSuggestionRendererHelper is unable to check suggestions.");
+ "Component " + DebugUtils.getPathToComponent(uiComponent) + " is not instance of Html5BaseInputText. HtmlTextInputSuggestionRendererHelper is unable to check suggestions.");
}
}
@@ -118,7 +118,7 @@
else
{
throw new IllegalArgumentException(
- "Component " + ComponentUtils.getPathToComponent(uiComponent) + " is not instance of Html5BaseInputText. HtmlTextInputSuggestionRendererHelper is unable to determine whether datalist will be generated or not.");
+ "Component " + DebugUtils.getPathToComponent(uiComponent) + " is not instance of Html5BaseInputText. HtmlTextInputSuggestionRendererHelper is unable to determine whether datalist will be generated or not.");
}
}
@@ -177,7 +177,7 @@
else
{
throw new IllegalArgumentException(
- "Component " + ComponentUtils.getPathToComponent(uiComponent) + " is not instance of Html5BaseInputText. HtmlTextInputSuggestionRendererHelper is unable to render options of suggestions attr.");
+ "Component " + DebugUtils.getPathToComponent(uiComponent) + " is not instance of Html5BaseInputText. HtmlTextInputSuggestionRendererHelper is unable to render options of suggestions attr.");
}
}
diff --git a/myfaces-html5-core/src/main/java/org/apache/myfaces/html5/renderkit/input/util/Html5DateTimeConverter.java b/myfaces-html5-core/src/main/java/org/apache/myfaces/html5/renderkit/input/util/Html5DateTimeConverter.java
index a88c4c1..1f93979 100644
--- a/myfaces-html5-core/src/main/java/org/apache/myfaces/html5/renderkit/input/util/Html5DateTimeConverter.java
+++ b/myfaces-html5-core/src/main/java/org/apache/myfaces/html5/renderkit/input/util/Html5DateTimeConverter.java
@@ -28,8 +28,8 @@
import javax.faces.convert.Converter;
import javax.faces.convert.ConverterException;
+import org.apache.myfaces.commons.util.DebugUtils;
import org.apache.myfaces.html5.component.input.HtmlInputDateTime;
-import org.apache.myfaces.html5.component.util.ComponentUtils;
/**
* Converter for use in hx:inputDateTime.
@@ -53,12 +53,12 @@
}
catch (ParseException e)
{
- throw new ConverterException(new FacesMessage("Unable to parse input " + value + " for " + ComponentUtils.getPathToComponent(uiComponent) + " with type " + type), e);
+ throw new ConverterException(new FacesMessage("Unable to parse input " + value + " for " + DebugUtils.getPathToComponent(uiComponent) + " with type " + type), e);
}
}
else
{
- throw new FacesException("Component " + ComponentUtils.getPathToComponent(uiComponent) + " is not a HtmlInputDateTime");
+ throw new FacesException("Component " + DebugUtils.getPathToComponent(uiComponent) + " is not a HtmlInputDateTime");
}
}
@@ -69,7 +69,7 @@
return null;
if (!(objValue instanceof Date))
- throw new FacesException("Value is not a java.util.Date for component " + ComponentUtils.getPathToComponent(uiComponent) + ".");
+ throw new FacesException("Value is not a java.util.Date for component " + DebugUtils.getPathToComponent(uiComponent) + ".");
if (uiComponent instanceof HtmlInputDateTime)
{
@@ -82,7 +82,7 @@
}
else
{
- throw new FacesException("Component " + ComponentUtils.getPathToComponent(uiComponent) + " is not a HtmlInputDateTime");
+ throw new FacesException("Component " + DebugUtils.getPathToComponent(uiComponent) + " is not a HtmlInputDateTime");
}
}
diff --git a/myfaces-html5-core/src/main/java/org/apache/myfaces/html5/renderkit/input/util/Html5EmailConverter.java b/myfaces-html5-core/src/main/java/org/apache/myfaces/html5/renderkit/input/util/Html5EmailConverter.java
index 247f814..dfaf90e 100644
--- a/myfaces-html5-core/src/main/java/org/apache/myfaces/html5/renderkit/input/util/Html5EmailConverter.java
+++ b/myfaces-html5-core/src/main/java/org/apache/myfaces/html5/renderkit/input/util/Html5EmailConverter.java
@@ -25,7 +25,7 @@
import javax.faces.convert.ConverterException;
import org.apache.commons.validator.EmailValidator;
-import org.apache.myfaces.html5.component.util.ComponentUtils;
+import org.apache.myfaces.commons.util.DebugUtils;
/**
* Converter for use in hx:inputEmail.
@@ -54,7 +54,7 @@
if (!EmailValidator.getInstance().isValid(email))
{
throw new ConverterException(new FacesMessage("Provided value for component "
- + ComponentUtils.getPathToComponent(component) + " is not a valid email: " + email));
+ + DebugUtils.getPathToComponent(component) + " is not a valid email: " + email));
}
}
@@ -93,7 +93,7 @@
else
{
throw new ConverterException(new FacesMessage("Provided value for component "
- + ComponentUtils.getPathToComponent(component) + " is not String or String[]: " + value.toString()));
+ + DebugUtils.getPathToComponent(component) + " is not String or String[]: " + value.toString()));
}
}
}
diff --git a/myfaces-html5-core/src/main/java/org/apache/myfaces/html5/renderkit/media/AbstractMediaRenderer.java b/myfaces-html5-core/src/main/java/org/apache/myfaces/html5/renderkit/media/AbstractMediaRenderer.java
index e4e8faf..570ce59 100644
--- a/myfaces-html5-core/src/main/java/org/apache/myfaces/html5/renderkit/media/AbstractMediaRenderer.java
+++ b/myfaces-html5-core/src/main/java/org/apache/myfaces/html5/renderkit/media/AbstractMediaRenderer.java
@@ -33,8 +33,8 @@
import javax.faces.context.ResponseWriter;
import javax.faces.render.Renderer;
+import org.apache.myfaces.commons.util.DebugUtils;
import org.apache.myfaces.html5.component.media.AbstractMedia;
-import org.apache.myfaces.html5.component.util.ComponentUtils;
import org.apache.myfaces.html5.model.MediaInfo;
import org.apache.myfaces.html5.renderkit.util.HTML5;
import org.apache.myfaces.html5.renderkit.util.Html5RendererUtils;
@@ -162,7 +162,7 @@
// src is reqired to be present and not empty!
if (mediaInfo.getSrc() == null || mediaInfo.getSrc().length() == 0)
// WIKI: add a wiki page
- throw new FacesException("'src' field of MediaInfo has to be defined and nonempty for component " + ComponentUtils.getPathToComponent(uiComponent) + ".");
+ throw new FacesException("'src' field of MediaInfo has to be defined and nonempty for component " + DebugUtils.getPathToComponent(uiComponent) + ".");
writer.writeAttribute(HTML5.SRC_ATTR, mediaInfo.getSrc(), null);
diff --git a/myfaces-html5-core/src/main/java/org/apache/myfaces/html5/renderkit/util/Html5RendererUtils.java b/myfaces-html5-core/src/main/java/org/apache/myfaces/html5/renderkit/util/Html5RendererUtils.java
index 22dbaeb..abdcdbc 100644
--- a/myfaces-html5-core/src/main/java/org/apache/myfaces/html5/renderkit/util/Html5RendererUtils.java
+++ b/myfaces-html5-core/src/main/java/org/apache/myfaces/html5/renderkit/util/Html5RendererUtils.java
@@ -18,9 +18,15 @@
*/
package org.apache.myfaces.html5.renderkit.util;
-import org.apache.commons.collections.MapUtils;
-import org.apache.commons.lang.StringUtils;
-import org.apache.myfaces.html5.component.util.ComponentUtils;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.logging.Logger;
import javax.faces.component.EditableValueHolder;
import javax.faces.component.UIComponent;
@@ -31,9 +37,10 @@
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
-import java.io.IOException;
-import java.util.*;
-import java.util.logging.Logger;
+
+import org.apache.commons.collections.MapUtils;
+import org.apache.commons.lang.StringUtils;
+import org.apache.myfaces.commons.util.DebugUtils;
/**
* @author Ali Ok
@@ -725,7 +732,7 @@
} else {
log.warning(NON_SUBMITTED_VALUE_WARNING +
" Component : " +
- ComponentUtils.getPathToComponent(component));
+ DebugUtils.getPathToComponent(component));
}
}
diff --git a/myfaces-html5-core/src/main/java/org/apache/myfaces/html5/renderkit/util/RendererUtils.java b/myfaces-html5-core/src/main/java/org/apache/myfaces/html5/renderkit/util/RendererUtils.java
index a96fc48..87cab6a 100644
--- a/myfaces-html5-core/src/main/java/org/apache/myfaces/html5/renderkit/util/RendererUtils.java
+++ b/myfaces-html5-core/src/main/java/org/apache/myfaces/html5/renderkit/util/RendererUtils.java
@@ -19,7 +19,8 @@
package org.apache.myfaces.html5.renderkit.util;
-import org.apache.myfaces.html5.component.util.ComponentUtils;
+import java.util.logging.Level;
+import java.util.logging.Logger;
import javax.el.ValueExpression;
import javax.faces.FacesException;
@@ -31,8 +32,8 @@
import javax.faces.convert.Converter;
import javax.faces.convert.ConverterException;
import javax.faces.el.PropertyNotFoundException;
-import java.util.logging.Level;
-import java.util.logging.Logger;
+
+import org.apache.myfaces.commons.util.DebugUtils;
/**
* @author Ali Ok
@@ -51,7 +52,7 @@
// why isAssignableFrom with additional getClass method call if isInstance does the same?
if (compClass != null && !(compClass.isInstance(uiComponent)))
{
- throw new IllegalArgumentException("uiComponent : " + ComponentUtils.getPathToComponent(uiComponent)+
+ throw new IllegalArgumentException("uiComponent : " + DebugUtils.getPathToComponent(uiComponent)+
" is not instance of "+compClass.getName()+" as it should be");
}
}
@@ -199,7 +200,7 @@
{
if (!(component instanceof ValueHolder))
{
- throw new IllegalArgumentException("Component : " + ComponentUtils.getPathToComponent(component)+"is not a ValueHolder");
+ throw new IllegalArgumentException("Component : " + DebugUtils.getPathToComponent(component)+"is not a ValueHolder");
}
if (component instanceof EditableValueHolder)
@@ -263,7 +264,7 @@
}
catch(PropertyNotFoundException ex)
{
- log.log(Level.SEVERE, "Property not found - called by component : "+ComponentUtils.getPathToComponent(component),ex);
+ log.log(Level.SEVERE, "Property not found - called by component : "+DebugUtils.getPathToComponent(component),ex);
throw ex;
}
@@ -278,7 +279,7 @@
catch(Exception ex)
{
throw new FacesException("Could not retrieve value of component with path : "+
- ComponentUtils.getPathToComponent(component),ex);
+ DebugUtils.getPathToComponent(component),ex);
}
return value;
}
diff --git a/myfaces-html5-core/src/main/java/org/apache/myfaces/html5/renderkit/util/SelectItemsIterator.java b/myfaces-html5-core/src/main/java/org/apache/myfaces/html5/renderkit/util/SelectItemsIterator.java
deleted file mode 100644
index 60d6655..0000000
--- a/myfaces-html5-core/src/main/java/org/apache/myfaces/html5/renderkit/util/SelectItemsIterator.java
+++ /dev/null
@@ -1,323 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.html5.renderkit.util;
-
-import org.apache.myfaces.html5.component.util.ComponentUtils;
-
-import java.lang.reflect.Array;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.NoSuchElementException;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import javax.el.ValueExpression;
-import javax.faces.application.ProjectStage;
-import javax.faces.component.UIComponent;
-import javax.faces.component.UISelectItem;
-import javax.faces.component.UISelectItems;
-import javax.faces.context.FacesContext;
-import javax.faces.model.SelectItem;
-
-// ATTENTION
-// This class is associated with javax.faces.component._SelectItemsIterator.
-// Changes here should also be applied to this class.
-
-/**
- * @author Mathias Broekelmann (latest modification by $Author$)
- * @author Jakob Korherr (jsf 2.0)
- * @version $Revision$ $Date$
- */
-public class SelectItemsIterator implements Iterator<SelectItem>
-{
- private static final Logger log = Logger.getLogger(SelectItemsIterator.class.getName());
-
- private static final String VAR_PROP = JsfProperties.VAR_PROP;
- private static final String ITEM_VALUE_PROP = JsfProperties.ITEM_VALUE_PROP;
- private static final String ITEM_LABEL_PROP = JsfProperties.ITEM_LABEL_PROP;
- private static final String ITEM_DESCRIPTION_PROP = JsfProperties.ITEM_DESCRIPTION_PROP;
- private static final String ITEM_DISABLED_PROP = JsfProperties.ITEM_DISABLED_PROP;
- private static final String ITEM_LABEL_ESCAPED_PROP = JsfProperties.ITEM_LABEL_ESCAPED_PROP;
- private static final String NO_SELECTION_VALUE_PROP = JsfProperties.NO_SELECTION_VALUE_PROP;
-
- private final Iterator<UIComponent> _children;
- private Iterator<? extends Object> _nestedItems;
- private SelectItem _nextItem;
- private UISelectItems _currentUISelectItems;
- private FacesContext _facesContext;
-
- public SelectItemsIterator(UIComponent selectItemsParent, FacesContext facesContext)
- {
- _children = selectItemsParent.getChildren().iterator();
- _facesContext = facesContext;
- }
-
- @SuppressWarnings("unchecked")
- public boolean hasNext()
- {
- if (_nextItem != null)
- {
- return true;
- }
- if (_nestedItems != null)
- {
- if (_nestedItems.hasNext())
- {
- return true;
- }
- _nestedItems = null;
- }
- if (_children.hasNext())
- {
- UIComponent child = _children.next();
- // When there is other components nested that does
- // not extends from UISelectItem or UISelectItems
- // the behavior for this iterator is just skip this
- // element(s) until an element that extends from these
- // classes are found. If there is no more elements
- // that conform this condition, just return false.
- while (!(child instanceof UISelectItem) && !(child instanceof UISelectItems))
- {
- // Try to skip it
- if (_children.hasNext())
- {
- // Skip and do the same check
- child = _children.next();
- }
- else
- {
- // End loop, so the final result is return false,
- // since there are no more components to iterate.
- return false;
- }
- }
- if (child instanceof UISelectItem)
- {
- UISelectItem uiSelectItem = (UISelectItem) child;
- Object item = uiSelectItem.getValue();
- if (item == null)
- {
- // no value attribute --> create the SelectItem out of the other attributes
- Object itemValue = uiSelectItem.getItemValue();
- String label = uiSelectItem.getItemLabel();
- String description = uiSelectItem.getItemDescription();
- boolean disabled = uiSelectItem.isItemDisabled();
- boolean escape = uiSelectItem.isItemEscaped();
- boolean noSelectionOption = uiSelectItem.isNoSelectionOption();
- if (label == null)
- {
- label = itemValue.toString();
- }
- item = new SelectItem(itemValue, label, description, disabled, escape, noSelectionOption);
- }
- else if (!(item instanceof SelectItem))
- {
- ValueExpression expression = uiSelectItem.getValueExpression("value");
- throw new IllegalArgumentException("ValueExpression '"
- + (expression == null ? null : expression.getExpressionString()) + "' of UISelectItem : "
- + ComponentUtils.getPathToComponent(child) + " does not reference an Object of type SelectItem");
- }
- _nextItem = (SelectItem) item;
- return true;
- }
- else if (child instanceof UISelectItems)
- {
- _currentUISelectItems = ((UISelectItems) child);
- Object value = _currentUISelectItems.getValue();
-
- if (value instanceof SelectItem)
- {
- _nextItem = (SelectItem) value;
- return true;
- }
- else if (value != null && value.getClass().isArray())
- {
- // value is any kind of array (primitive or non-primitive)
- // --> we have to use class Array to get the values
- final int length = Array.getLength(value);
- Collection<Object> items = new ArrayList<Object>(length);
- for (int i = 0; i < length; i++)
- {
- items.add(Array.get(value, i));
- }
- _nestedItems = items.iterator();
- return hasNext();
- }
- else if (value instanceof Iterable)
- {
- // value is Iterable --> Collection, DataModel,...
- _nestedItems = ((Iterable<?>) value).iterator();
- return hasNext();
- }
- else if (value instanceof Map)
- {
- Map<Object, Object> map = ((Map<Object, Object>) value);
- Collection<SelectItem> items = new ArrayList<SelectItem>(map.size());
- for (Map.Entry<Object, Object> entry : map.entrySet())
- {
- items.add(new SelectItem(entry.getValue(), entry.getKey().toString()));
- }
-
- _nestedItems = items.iterator();
- return hasNext();
- }
- else
- {
- Level level = Level.FINE;
- if (!_facesContext.isProjectStage(ProjectStage.Production))
- {
- level = Level.WARNING;
- }
-
- if (log.isLoggable(level))
- {
- ValueExpression expression = _currentUISelectItems.getValueExpression("value");
- log.log(level, "ValueExpression {0} of UISelectItems with component-path {1}"
- + " does not reference an Object of type SelectItem,"
- + " array, Iterable or Map, but of type: {2}",
- new Object[] {
- (expression == null ? null : expression.getExpressionString()),
- ComponentUtils.getPathToComponent(child),
- (value == null ? null : value.getClass().getName())
- });
- }
- }
- }
- }
- return false;
- }
-
- public SelectItem next()
- {
- if (!hasNext())
- {
- throw new NoSuchElementException();
- }
- if (_nextItem != null)
- {
- SelectItem value = _nextItem;
- _nextItem = null;
- return value;
- }
- if (_nestedItems != null)
- {
- Object item = _nestedItems.next();
-
- if (!(item instanceof SelectItem))
- {
- // check new params of SelectItems (since 2.0): itemValue, itemLabel, itemDescription,...
- // Note that according to the spec UISelectItems does not provide Getter and Setter
- // methods for this values, so we have to use the attribute map
- Map<String, Object> attributeMap = _currentUISelectItems.getAttributes();
-
- // write the current item into the request map under the key listed in var, if available
- boolean wroteRequestMapVarValue = false;
- Object oldRequestMapVarValue = null;
- final String var = (String) attributeMap.get(VAR_PROP);
- if(var != null && !"".equals(var))
- {
- // save the current value of the key listed in var from the request map
- oldRequestMapVarValue = _facesContext.getExternalContext().getRequestMap().put(var, item);
- wroteRequestMapVarValue = true;
- }
-
- // check the itemValue attribute
- Object itemValue = attributeMap.get(ITEM_VALUE_PROP);
- if (itemValue == null)
- {
- // the itemValue attribute was not provided
- // --> use the current item as the itemValue
- itemValue = item;
- }
-
- // Spec: When iterating over the select items, toString()
- // must be called on the string rendered attribute values
- Object itemLabel = attributeMap.get(ITEM_LABEL_PROP);
- if (itemLabel == null)
- {
- itemLabel = itemValue.toString();
- }
- else
- {
- itemLabel = itemLabel.toString();
- }
- Object itemDescription = attributeMap.get(ITEM_DESCRIPTION_PROP);
- if (itemDescription != null)
- {
- itemDescription = itemDescription.toString();
- }
- Boolean itemDisabled = getBooleanAttribute(_currentUISelectItems, ITEM_DISABLED_PROP, false);
- Boolean itemLabelEscaped = getBooleanAttribute(_currentUISelectItems, ITEM_LABEL_ESCAPED_PROP, true);
- Object noSelectionValue = attributeMap.get(NO_SELECTION_VALUE_PROP);
- item = new SelectItem(itemValue,
- (String) itemLabel,
- (String) itemDescription,
- itemDisabled,
- itemLabelEscaped,
- itemValue.equals(noSelectionValue));
-
- // remove the value with the key from var from the request map, if previously written
- if(wroteRequestMapVarValue)
- {
- // If there was a previous value stored with the key from var in the request map, restore it
- if (oldRequestMapVarValue != null)
- {
- _facesContext.getExternalContext()
- .getRequestMap().put(var, oldRequestMapVarValue);
- }
- else
- {
- _facesContext.getExternalContext()
- .getRequestMap().remove(var);
- }
- }
- }
- return (SelectItem) item;
- }
- throw new NoSuchElementException();
- }
-
- public void remove()
- {
- throw new UnsupportedOperationException();
- }
-
- private boolean getBooleanAttribute(UIComponent component, String attrName, boolean defaultValue)
- {
- Object value = component.getAttributes().get(attrName);
- if (value == null)
- {
- return defaultValue;
- }
- else if (value instanceof Boolean)
- {
- return (Boolean) value;
- }
- else
- {
- // If the value is a String, parse the boolean.
- // This makes the following code work: <tag attribute="true" />,
- // otherwise you would have to write <tag attribute="#{true}" />.
- return Boolean.valueOf(value.toString());
- }
- }
-
-}
diff --git a/myfaces-html5-core/src/main/java/org/apache/myfaces/html5/validator/DateTimeRangeValidator.java b/myfaces-html5-core/src/main/java/org/apache/myfaces/html5/validator/DateTimeRangeValidator.java
index bd399b7..2a63cee 100644
--- a/myfaces-html5-core/src/main/java/org/apache/myfaces/html5/validator/DateTimeRangeValidator.java
+++ b/myfaces-html5-core/src/main/java/org/apache/myfaces/html5/validator/DateTimeRangeValidator.java
@@ -34,8 +34,8 @@
import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFProperty;
import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFValidator;
+import org.apache.myfaces.commons.util.DebugUtils;
import org.apache.myfaces.html5.component.input.HtmlInputDateTime;
-import org.apache.myfaces.html5.component.util.ComponentUtils;
import org.apache.myfaces.html5.renderkit.input.util.Html5DateTimeFormatUtils;
import org.apache.myfaces.html5.renderkit.util.HTML5;
@@ -89,7 +89,7 @@
catch (ParseException e)
{
throw new ValidatorException(new FacesMessage("Unable to resolve minimum for component "
- + ComponentUtils.getPathToComponent(uiComponent) + "."), e);
+ + DebugUtils.getPathToComponent(uiComponent) + "."), e);
}
Date resolvedMaximum = null;
@@ -100,7 +100,7 @@
catch (ParseException e)
{
throw new ValidatorException(new FacesMessage("Unable to resolve maximum for component "
- + ComponentUtils.getPathToComponent(uiComponent) + "."), e);
+ + DebugUtils.getPathToComponent(uiComponent) + "."), e);
}
if (resolvedMinimum != null && resolvedMaximum != null)
@@ -109,7 +109,7 @@
{
// not a ValidatorException since state is illegal
throw new FacesException("Minimum value is before than maximum for component "
- + ComponentUtils.getPathToComponent(uiComponent) + ".");
+ + DebugUtils.getPathToComponent(uiComponent) + ".");
}
else
{
@@ -120,7 +120,7 @@
else
throw new ValidatorException(
new FacesMessage("Submitted value is not in allowed range for component "
- + ComponentUtils.getPathToComponent(uiComponent) + ". Range is "
+ + DebugUtils.getPathToComponent(uiComponent) + ". Range is "
+ resolvedMinimum.toString() + " - " + resolvedMaximum.toString() + "."));
}
}
@@ -132,7 +132,7 @@
throw new ValidatorException(new FacesMessage(this.lessThanMinimumMessage));
else
throw new ValidatorException(new FacesMessage("Value is before minimum for component "
- + ComponentUtils.getPathToComponent(uiComponent) + ". Minimum value is "
+ + DebugUtils.getPathToComponent(uiComponent) + ". Minimum value is "
+ resolvedMinimum.toString() + "."));
}
@@ -142,7 +142,7 @@
throw new ValidatorException(new FacesMessage(this.exceedMaximumMessage));
else
throw new ValidatorException(new FacesMessage("Value is after maximum for component "
- + ComponentUtils.getPathToComponent(uiComponent) + ". Maximum value is "
+ + DebugUtils.getPathToComponent(uiComponent) + ". Maximum value is "
+ resolvedMaximum.toString() + "."));
}
}