You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ta...@apache.org on 2018/11/07 21:22:47 UTC
[myfaces] branch master updated: duplicate code
This is an automated email from the ASF dual-hosted git repository.
tandraschko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/myfaces.git
The following commit(s) were added to refs/heads/master by this push:
new f276ca0 duplicate code
f276ca0 is described below
commit f276ca043e5f1e1a9b90a7420381a1ee921044b0
Author: Thomas Andraschko <ta...@apache.org>
AuthorDate: Wed Nov 7 22:22:41 2018 +0100
duplicate code
---
.../javax/faces/component/UIComponentBase.java | 53 +--------------
.../main/java/javax/faces/component/UIForm.java | 49 +-------------
.../faces/component/_SelectItemsIterator.java | 51 +-------------
.../myfaces/application/StateManagerImpl.java | 50 +-------------
.../myfaces/shared/renderkit/RendererUtils.java | 78 ++++------------------
.../shared/renderkit/_SharedRendererUtils.java | 3 +-
.../renderkit/html/HtmlGridRendererBase.java | 3 +-
.../renderkit/html/HtmlImageRendererBase.java | 5 +-
.../shared/renderkit/html/HtmlRendererUtils.java | 3 +-
.../renderkit/html/HtmlResponseWriterImpl.java | 4 +-
.../renderkit/html/util/OutcomeTargetUtils.java | 7 +-
.../org/apache/myfaces/shared/util/ClassUtils.java | 2 +-
.../apache/myfaces/shared/util/ComponentUtils.java | 54 +++++++++++++++
.../myfaces/shared/util/SelectItemsIterator.java | 5 +-
.../compiler/CheckDuplicateIdFaceletUtils.java | 4 +-
.../myfaces/view/facelets/compiler/UILeaf.java | 50 +-------------
.../component/AbstractUIComponentBaseTest.java | 2 -
.../javax/faces/component/UIComponentBaseTest.java | 2 -
18 files changed, 96 insertions(+), 329 deletions(-)
diff --git a/api/src/main/java/javax/faces/component/UIComponentBase.java b/api/src/main/java/javax/faces/component/UIComponentBase.java
index a15b270..b1e47a7 100755
--- a/api/src/main/java/javax/faces/component/UIComponentBase.java
+++ b/api/src/main/java/javax/faces/component/UIComponentBase.java
@@ -924,7 +924,7 @@ public abstract class UIComponentBase extends UIComponent
String location = getComponentLocation(this);
throw new FacesException("Cannot create clientId. No id is assigned for component"
+ " to create an id and UIViewRoot is not defined: "
- + getPathToComponent(this)
+ + _ComponentUtils.getPathToComponent(this)
+ (location != null ? " created from: " + location : ""));
}
}
@@ -973,7 +973,7 @@ public abstract class UIComponentBase extends UIComponent
// + "If this component was created dynamically (i.e. not by a JSP tag) you should assign it an "
// + "explicit static id or assign it the id you get from "
// + "the createUniqueId from the current UIViewRoot "
- // + "component right after creation! Path to Component: " + getPathToComponent(this));
+ // + "component right after creation! Path to Component: " + _ComponentUtils.getPathToComponent(this));
//}
return _clientId;
@@ -1295,7 +1295,7 @@ public abstract class UIComponentBase extends UIComponent
if (renderer == null)
{
String location = getComponentLocation(this);
- String logStr = "No Renderer found for component " + getPathToComponent(this)
+ String logStr = "No Renderer found for component " + _ComponentUtils.getPathToComponent(this)
+ " (component-family=" + getFamily()
+ ", renderer-type=" + rendererType + ')'
+ (location != null ? " created from: " + location : "");
@@ -1667,53 +1667,6 @@ public abstract class UIComponentBase extends UIComponent
return null;
}
- private String getPathToComponent(UIComponent component)
- {
- StringBuilder buf = new StringBuilder();
-
- 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();
- }
-
- private void getPathToComponent(UIComponent component, StringBuilder buf)
- {
- if (component == null)
- {
- return;
- }
-
- StringBuilder intBuf = new StringBuilder();
-
- 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);
- }
-
public void setTransient(boolean transientFlag)
{
_transient = transientFlag;
diff --git a/api/src/main/java/javax/faces/component/UIForm.java b/api/src/main/java/javax/faces/component/UIForm.java
index dfe8f83..a5f9c2c 100755
--- a/api/src/main/java/javax/faces/component/UIForm.java
+++ b/api/src/main/java/javax/faces/component/UIForm.java
@@ -71,7 +71,7 @@ public class UIForm extends UIComponentBase implements NamingContainer, UniqueId
String location = getComponentLocation(this);
throw new FacesException("Cannot create clientId. No id is assigned for component"
+ " to create an id and UIViewRoot is not defined: "
- + getPathToComponent(this)
+ + _ComponentUtils.getPathToComponent(this)
+ (location != null ? " created from: " + location : ""));
}
}
@@ -385,53 +385,6 @@ public class UIForm extends UIComponentBase implements NamingContainer, UniqueId
}
return null;
}
-
- private String getPathToComponent(UIComponent component)
- {
- StringBuilder buf = new StringBuilder();
-
- 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();
- }
-
- private void getPathToComponent(UIComponent component, StringBuilder buf)
- {
- if (component == null)
- {
- return;
- }
-
- StringBuilder intBuf = new StringBuilder();
-
- 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);
- }
// ------------------ GENERATED CODE END ---------------------------------------
diff --git a/api/src/main/java/javax/faces/component/_SelectItemsIterator.java b/api/src/main/java/javax/faces/component/_SelectItemsIterator.java
index 5210b94..f0aafb7 100644
--- a/api/src/main/java/javax/faces/component/_SelectItemsIterator.java
+++ b/api/src/main/java/javax/faces/component/_SelectItemsIterator.java
@@ -133,7 +133,7 @@ class _SelectItemsIterator implements Iterator<SelectItem>
ValueExpression expression = uiSelectItem.getValueExpression("value");
throw new IllegalArgumentException("ValueExpression '"
+ (expression == null ? null : expression.getExpressionString()) + "' of UISelectItem : "
- + getPathToComponent(child) + " does not reference an Object of type SelectItem");
+ + _ComponentUtils.getPathToComponent(child) + " does not reference an Object of type SelectItem");
}
_nextItem = (SelectItem) item;
_currentComponent = child;
@@ -197,7 +197,7 @@ class _SelectItemsIterator implements Iterator<SelectItem>
+ " array, Iterable or Map, but of type: {2}",
new Object[] {
(expression == null ? null : expression.getExpressionString()),
- getPathToComponent(child),
+ _ComponentUtils.getPathToComponent(child),
(value == null ? null : value.getClass().getName())
});
}
@@ -335,51 +335,4 @@ class _SelectItemsIterator implements Iterator<SelectItem>
return Boolean.valueOf(value.toString());
}
}
-
- private 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();
- }
-
- private 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);
-
- getPathToComponent(component.getParent(), buf);
- }
}
diff --git a/impl/src/main/java/org/apache/myfaces/application/StateManagerImpl.java b/impl/src/main/java/org/apache/myfaces/application/StateManagerImpl.java
index e8fd11c..8d434bc 100644
--- a/impl/src/main/java/org/apache/myfaces/application/StateManagerImpl.java
+++ b/impl/src/main/java/org/apache/myfaces/application/StateManagerImpl.java
@@ -41,6 +41,7 @@ import javax.faces.view.ViewDeclarationLanguage;
import org.apache.myfaces.application.viewstate.StateCacheUtils;
import org.apache.myfaces.context.RequestViewContext;
+import org.apache.myfaces.shared.util.ComponentUtils;
public class StateManagerImpl extends StateManager
{
@@ -303,7 +304,7 @@ public class StateManagerImpl extends StateManager
throw new IllegalStateException("Client-id : " + id +
" is duplicated in the faces tree. Component : " +
component.getClientId(context)+", path: " +
- getPathToComponent(component));
+ ComponentUtils.getPathToComponent(component));
}
if (component instanceof NamingContainer)
@@ -326,53 +327,6 @@ public class StateManagerImpl extends StateManager
}
}
- private static String getPathToComponent(UIComponent component)
- {
- StringBuilder buf = new StringBuilder();
-
- 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();
- }
-
- private static void getPathToComponent(UIComponent component, StringBuilder buf)
- {
- if(component == null)
- {
- return;
- }
-
- StringBuilder intBuf = new StringBuilder();
-
- 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);
- }
-
@Override
public void writeState(FacesContext facesContext,
Object state) throws IOException
diff --git a/impl/src/main/java/org/apache/myfaces/shared/renderkit/RendererUtils.java b/impl/src/main/java/org/apache/myfaces/shared/renderkit/RendererUtils.java
index dbf32d7..3bbab26 100755
--- a/impl/src/main/java/org/apache/myfaces/shared/renderkit/RendererUtils.java
+++ b/impl/src/main/java/org/apache/myfaces/shared/renderkit/RendererUtils.java
@@ -46,7 +46,6 @@ import javax.faces.component.UIForm;
import javax.faces.component.UIOutput;
import javax.faces.component.UISelectMany;
import javax.faces.component.UISelectOne;
-import javax.faces.component.UIViewRoot;
import javax.faces.component.ValueHolder;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
@@ -54,6 +53,7 @@ import javax.faces.convert.ConverterException;
import javax.faces.model.SelectItem;
import org.apache.myfaces.shared.renderkit.html.util.FormInfo;
+import org.apache.myfaces.shared.util.ComponentUtils;
import org.apache.myfaces.shared.util.HashMapUtils;
import org.apache.myfaces.shared.util.SelectItemsIterator;
import org.apache.myfaces.shared.renderkit.html.util.JSFAttr;
@@ -74,60 +74,6 @@ public final class RendererUtils
// This nice constant is "specified" 13.1.1.2 The Resource API Approach in Spec as an example
public static final String RES_NOT_FOUND = "RES_NOT_FOUND";
- public static String getPathToComponent(UIComponent component)
- {
- StringBuilder buf = new StringBuilder();
-
- if (component == null)
- {
- buf.append("{Component-Path : ");
- buf.append("[null]}");
- return buf.toString();
- }
-
- getPathToComponent(component, buf);
-
- buf.insert(0, "{Component-Path : ");
- Object location = component.getAttributes().get(
- UIComponent.VIEW_LOCATION_KEY);
- if (location != null)
- {
- buf.append(" Location: ").append(location);
- }
- buf.append('}');
-
- return buf.toString();
- }
-
- private static void getPathToComponent(UIComponent component,
- StringBuilder buf)
- {
- if (component == null)
- {
- return;
- }
-
- StringBuilder intBuf = new StringBuilder();
-
- 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);
- }
-
public static String getConcatenatedId(FacesContext context,
UIComponent container, String clientId)
{
@@ -183,7 +129,7 @@ public final class RendererUtils
throw new IllegalArgumentException(
"Expected submitted value of type Boolean for Component : "
- + getPathToComponent(component));
+ + ComponentUtils.getPathToComponent(component));
}
@@ -197,7 +143,7 @@ public final class RendererUtils
throw new IllegalArgumentException(
"Expected submitted value of type Date for component : "
- + getPathToComponent(component));
+ + ComponentUtils.getPathToComponent(component));
}
public static Object getObjectValue(UIComponent component)
@@ -205,7 +151,7 @@ public final class RendererUtils
if (!(component instanceof ValueHolder))
{
throw new IllegalArgumentException("Component : "
- + getPathToComponent(component) + "is not a ValueHolder");
+ + ComponentUtils.getPathToComponent(component) + "is not a ValueHolder");
}
if (component instanceof EditableValueHolder)
@@ -236,7 +182,7 @@ public final class RendererUtils
if (!(component instanceof ValueHolder))
{
throw new IllegalArgumentException("Component : "
- + getPathToComponent(component)
+ + ComponentUtils.getPathToComponent(component)
+ "is not a ValueHolder");
}
@@ -330,7 +276,7 @@ public final class RendererUtils
if (!(component instanceof ValueHolder))
{
throw new IllegalArgumentException("Component : "
- + getPathToComponent(component)
+ + ComponentUtils.getPathToComponent(component)
+ "is not a ValueHolder");
}
@@ -416,7 +362,7 @@ public final class RendererUtils
catch (PropertyNotFoundException ex)
{
log.log(Level.SEVERE, "Property not found - called by component : "
- + getPathToComponent(component), ex);
+ + ComponentUtils.getPathToComponent(component), ex);
throw ex;
}
@@ -558,7 +504,7 @@ public final class RendererUtils
{
throw new IllegalArgumentException(
"ValueExpression for UISelectMany : "
- + getPathToComponent(component)
+ + ComponentUtils.getPathToComponent(component)
+ " must be of type Collection or Array");
}
@@ -607,7 +553,7 @@ public final class RendererUtils
if (compClass != null && !(compClass.isInstance(uiComponent)))
{
throw new IllegalArgumentException("uiComponent : "
- + getPathToComponent(uiComponent) + " is not instance of "
+ + ComponentUtils.getPathToComponent(uiComponent) + " is not instance of "
+ compClass.getName() + " as it should be");
}
}
@@ -834,7 +780,7 @@ public final class RendererUtils
{
throw new IllegalArgumentException(
"Value of UISelectMany component with path : "
- + getPathToComponent(uiSelectMany)
+ + ComponentUtils.getPathToComponent(uiSelectMany)
+ " is not of type Array or List");
}
}
@@ -846,7 +792,7 @@ public final class RendererUtils
{
throw new IllegalArgumentException(
"Submitted value of type String for component : "
- + getPathToComponent(output) + "expected");
+ + ComponentUtils.getPathToComponent(output) + "expected");
}
//To be compatible with jsf ri, and according to issue 69
@@ -939,7 +885,7 @@ public final class RendererUtils
{
throw new ConverterException(
"Submitted value of type String[] for component : "
- + getPathToComponent(selectMany) + "expected");
+ + ComponentUtils.getPathToComponent(selectMany) + "expected");
}
return _SharedRendererUtils.getConvertedUISelectManyValue(facesContext,
diff --git a/impl/src/main/java/org/apache/myfaces/shared/renderkit/_SharedRendererUtils.java b/impl/src/main/java/org/apache/myfaces/shared/renderkit/_SharedRendererUtils.java
index 5669802..66ca58d 100755
--- a/impl/src/main/java/org/apache/myfaces/shared/renderkit/_SharedRendererUtils.java
+++ b/impl/src/main/java/org/apache/myfaces/shared/renderkit/_SharedRendererUtils.java
@@ -43,6 +43,7 @@ import javax.faces.convert.ConverterException;
import javax.faces.model.SelectItem;
import javax.faces.model.SelectItemGroup;
+import org.apache.myfaces.shared.util.ComponentUtils;
import org.apache.myfaces.shared.util.SelectItemsIterator;
/**
@@ -435,7 +436,7 @@ class _SharedRendererUtils
if (converter == null)
{
log.log(Level.WARNING, "Found attribute valueType on component " +
- RendererUtils.getPathToComponent(component) +
+ ComponentUtils.getPathToComponent(component) +
", but could not get a by-type converter for type " +
valueType.getName());
}
diff --git a/impl/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlGridRendererBase.java b/impl/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlGridRendererBase.java
index 1da7e9a..45b4465 100644
--- a/impl/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlGridRendererBase.java
+++ b/impl/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlGridRendererBase.java
@@ -37,6 +37,7 @@ import org.apache.myfaces.shared.renderkit.html.util.JSFAttr;
import org.apache.myfaces.shared.renderkit.RendererUtils;
import org.apache.myfaces.shared.renderkit.html.util.ResourceUtils;
import org.apache.myfaces.shared.util.ArrayUtils;
+import org.apache.myfaces.shared.util.ComponentUtils;
import org.apache.myfaces.shared.util.StringUtils;
import org.apache.myfaces.shared.renderkit.html.util.HTML;
@@ -390,7 +391,7 @@ public class HtmlGridRendererBase
Level level = context.isProjectStage(ProjectStage.Production) ? Level.FINE : Level.WARNING;
if (log.isLoggable(level))
{
- log.log(level, "PanelGrid " + RendererUtils.getPathToComponent(component)
+ log.log(level, "PanelGrid " + ComponentUtils.getPathToComponent(component)
+ " has not enough children. Child count should be a "
+ "multiple of the columns attribute.");
}
diff --git a/impl/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlImageRendererBase.java b/impl/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlImageRendererBase.java
index e66a55e..0df0636 100644
--- a/impl/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlImageRendererBase.java
+++ b/impl/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlImageRendererBase.java
@@ -36,6 +36,7 @@ import org.apache.myfaces.shared.renderkit.html.util.JSFAttr;
import org.apache.myfaces.shared.renderkit.RendererUtils;
import org.apache.myfaces.shared.renderkit.html.util.ResourceUtils;
import org.apache.myfaces.shared.renderkit.html.util.HTML;
+import org.apache.myfaces.shared.util.ComponentUtils;
public class HtmlImageRendererBase
@@ -92,7 +93,7 @@ public class HtmlImageRendererBase
{
log.warning("Component UIGraphic " + uiComponent.getClientId(facesContext)
+ " has no attribute url, value, name or attribute resolves to null. Path to component "
- + RendererUtils.getPathToComponent(uiComponent));
+ + ComponentUtils.getPathToComponent(uiComponent));
}
}
@@ -105,7 +106,7 @@ public class HtmlImageRendererBase
{
log.warning("Component UIGraphic " + uiComponent.getClientId(facesContext)
+ " has no attribute alt or attribute resolves to null. Path to component "
- + RendererUtils.getPathToComponent(uiComponent));
+ + ComponentUtils.getPathToComponent(uiComponent));
}
}
diff --git a/impl/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlRendererUtils.java b/impl/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlRendererUtils.java
index d836f67..b570f3e 100644
--- a/impl/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlRendererUtils.java
+++ b/impl/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlRendererUtils.java
@@ -68,6 +68,7 @@ import org.apache.myfaces.shared.renderkit.RendererUtils;
import org.apache.myfaces.shared.renderkit.html.util.FormInfo;
import org.apache.myfaces.shared.renderkit.html.util.HTMLEncoder;
import org.apache.myfaces.shared.renderkit.html.util.OutcomeTargetUtils;
+import org.apache.myfaces.shared.util.ComponentUtils;
import org.apache.myfaces.shared.util.StringUtils;
import org.apache.myfaces.shared.renderkit.html.util.HTML;
@@ -120,7 +121,7 @@ public final class HtmlRendererUtils
}
else
{
- log.warning(NON_SUBMITTED_VALUE_WARNING + " Component : " + RendererUtils.getPathToComponent(component));
+ log.warning(NON_SUBMITTED_VALUE_WARNING + " Component : " + ComponentUtils.getPathToComponent(component));
}
}
diff --git a/impl/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlResponseWriterImpl.java b/impl/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlResponseWriterImpl.java
index c5c68ec..29e561a 100644
--- a/impl/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlResponseWriterImpl.java
+++ b/impl/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlResponseWriterImpl.java
@@ -36,9 +36,9 @@ import javax.faces.render.Renderer;
import org.apache.myfaces.config.MyfacesConfig;
import org.apache.myfaces.shared.renderkit.ContentTypeUtils;
-import org.apache.myfaces.shared.renderkit.RendererUtils;
import org.apache.myfaces.shared.renderkit.html.util.UnicodeEncoder;
import org.apache.myfaces.shared.util.CommentUtils;
+import org.apache.myfaces.shared.util.ComponentUtils;
import org.apache.myfaces.shared.util.StreamCharBuffer;
import org.apache.myfaces.shared.renderkit.html.util.HTML;
@@ -545,7 +545,7 @@ public class HtmlResponseWriterImpl
{
log.warning("HTML nesting warning on closing " + elementName + ": element " + _startElementName +
(_startElementUIComponent==null?"":(" rendered by component : "+
- RendererUtils.getPathToComponent(_startElementUIComponent)))+" not explicitly closed");
+ ComponentUtils.getPathToComponent(_startElementUIComponent)))+" not explicitly closed");
}
}
diff --git a/impl/src/main/java/org/apache/myfaces/shared/renderkit/html/util/OutcomeTargetUtils.java b/impl/src/main/java/org/apache/myfaces/shared/renderkit/html/util/OutcomeTargetUtils.java
index d83343a..4f30836 100644
--- a/impl/src/main/java/org/apache/myfaces/shared/renderkit/html/util/OutcomeTargetUtils.java
+++ b/impl/src/main/java/org/apache/myfaces/shared/renderkit/html/util/OutcomeTargetUtils.java
@@ -40,6 +40,7 @@ import javax.faces.flow.FlowHandler;
import javax.faces.lifecycle.ClientWindow;
import org.apache.myfaces.shared.application.NavigationUtils;
import org.apache.myfaces.shared.renderkit.RendererUtils;
+import org.apache.myfaces.shared.util.ComponentUtils;
/**
* Utility methods for OutcomeTarget components.
@@ -89,7 +90,7 @@ public class OutcomeTargetUtils
{
// log a warning
log.warning("Could not determine NavigationCase for UIOutcomeTarget component "
- + RendererUtils.getPathToComponent(component) + " with outcome " + outcome);
+ + ComponentUtils.getPathToComponent(component) + " with outcome " + outcome);
return null;
}
@@ -263,7 +264,7 @@ public class OutcomeTargetUtils
if (skipNullName && (name == null || RendererUtils.EMPTY_STRING.equals(name)))
{
// warn for a null-name
- log.log(Level.WARNING, "The UIParameter " + RendererUtils.getPathToComponent(param)
+ log.log(Level.WARNING, "The UIParameter " + ComponentUtils.getPathToComponent(param)
+ " has a name of null or empty string and thus will not be added to the URL.");
// and skip it
continue;
@@ -274,7 +275,7 @@ public class OutcomeTargetUtils
if (facesContext.isProjectStage(ProjectStage.Development))
{
// inform the user about the null value when in Development stage
- log.log(Level.INFO, "The UIParameter " + RendererUtils.getPathToComponent(param)
+ log.log(Level.INFO, "The UIParameter " + ComponentUtils.getPathToComponent(param)
+ " has a value of null and thus will not be added to the URL.");
}
// skip a null-value
diff --git a/impl/src/main/java/org/apache/myfaces/shared/util/ClassUtils.java b/impl/src/main/java/org/apache/myfaces/shared/util/ClassUtils.java
index 548c686..f2fa1e4 100755
--- a/impl/src/main/java/org/apache/myfaces/shared/util/ClassUtils.java
+++ b/impl/src/main/java/org/apache/myfaces/shared/util/ClassUtils.java
@@ -728,7 +728,7 @@ public final class ClassUtils
public static Class<?> forName(String name) throws ClassNotFoundException
{
- if (null == name || "".equals(name))
+ if (name == null || name.isEmpty())
{
return null;
}
diff --git a/impl/src/main/java/org/apache/myfaces/shared/util/ComponentUtils.java b/impl/src/main/java/org/apache/myfaces/shared/util/ComponentUtils.java
index 0252c71..22048e3 100644
--- a/impl/src/main/java/org/apache/myfaces/shared/util/ComponentUtils.java
+++ b/impl/src/main/java/org/apache/myfaces/shared/util/ComponentUtils.java
@@ -21,6 +21,7 @@ package org.apache.myfaces.shared.util;
import javax.faces.component.NamingContainer;
import javax.faces.component.UIComponent;
+import javax.faces.component.UIViewRoot;
import javax.faces.component.UniqueIdVendor;
/**
@@ -93,4 +94,57 @@ public class ComponentUtils
}
return null;
}
+
+ public static String getPathToComponent(UIComponent component)
+ {
+ StringBuilder buf = new StringBuilder();
+
+ if (component == null)
+ {
+ buf.append("{Component-Path : ");
+ buf.append("[null]}");
+ return buf.toString();
+ }
+
+ getPathToComponent(component, buf);
+
+ buf.insert(0, "{Component-Path : ");
+ Object location = component.getAttributes().get(
+ UIComponent.VIEW_LOCATION_KEY);
+ if (location != null)
+ {
+ buf.append(" Location: ").append(location);
+ }
+ buf.append('}');
+
+ return buf.toString();
+ }
+
+ private static void getPathToComponent(UIComponent component, StringBuilder buf)
+ {
+ if (component == null)
+ {
+ return;
+ }
+
+ StringBuilder intBuf = new StringBuilder();
+
+ 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/impl/src/main/java/org/apache/myfaces/shared/util/SelectItemsIterator.java b/impl/src/main/java/org/apache/myfaces/shared/util/SelectItemsIterator.java
index 2106f8b..9ee0b43 100644
--- a/impl/src/main/java/org/apache/myfaces/shared/util/SelectItemsIterator.java
+++ b/impl/src/main/java/org/apache/myfaces/shared/util/SelectItemsIterator.java
@@ -35,7 +35,6 @@ import javax.faces.component.UISelectItem;
import javax.faces.component.UISelectItems;
import javax.faces.context.FacesContext;
import javax.faces.model.SelectItem;
-import org.apache.myfaces.shared.renderkit.RendererUtils;
import org.apache.myfaces.shared.renderkit.html.util.JSFAttr;
@@ -138,7 +137,7 @@ public class SelectItemsIterator implements Iterator<SelectItem>
ValueExpression expression = uiSelectItem.getValueExpression("value");
throw new IllegalArgumentException("ValueExpression '"
+ (expression == null ? null : expression.getExpressionString()) + "' of UISelectItem : "
- + RendererUtils.getPathToComponent(child)
+ + ComponentUtils.getPathToComponent(child)
+ " does not reference an Object of type SelectItem");
}
_nextItem = (SelectItem) item;
@@ -204,7 +203,7 @@ public class SelectItemsIterator implements Iterator<SelectItem>
+ " array, Iterable or Map, but of type: {2}",
new Object[] {
(expression == null ? null : expression.getExpressionString()),
- RendererUtils.getPathToComponent(child),
+ ComponentUtils.getPathToComponent(child),
(value == null ? null : value.getClass().getName())
});
}
diff --git a/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/CheckDuplicateIdFaceletUtils.java b/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/CheckDuplicateIdFaceletUtils.java
index 0543196..458d6b5 100644
--- a/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/CheckDuplicateIdFaceletUtils.java
+++ b/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/CheckDuplicateIdFaceletUtils.java
@@ -27,7 +27,7 @@ import javax.faces.event.ExceptionQueuedEvent;
import javax.faces.event.ExceptionQueuedEventContext;
import javax.faces.view.Location;
-import org.apache.myfaces.shared.renderkit.RendererUtils;
+import org.apache.myfaces.shared.util.ComponentUtils;
/**
*
@@ -141,7 +141,7 @@ public final class CheckDuplicateIdFaceletUtils
{
// location is not available in production mode or if the component
// doesn't come from Facelets VDL.
- message += RendererUtils.getPathToComponent(firstComponent);
+ message += ComponentUtils.getPathToComponent(firstComponent);
}
// 2) we store the first commponent in exception attributes
diff --git a/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/UILeaf.java b/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/UILeaf.java
index 177e6d2..54d7d1c 100644
--- a/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/UILeaf.java
+++ b/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/UILeaf.java
@@ -44,6 +44,7 @@ import javax.faces.event.FacesListener;
import javax.faces.render.Renderer;
import javax.faces.view.Location;
+
import org.apache.myfaces.shared.renderkit.html.util.SharedStringBuilder;
import org.apache.myfaces.shared.util.ComponentUtils;
import org.apache.myfaces.view.facelets.tag.jsf.ComponentSupport;
@@ -97,7 +98,7 @@ class UILeaf extends UIComponent implements UntargetableComponent, Map<String, O
String location = getComponentLocation(this);
throw new FacesException("Cannot create clientId. No id is assigned for component"
+ " to create an id and UIViewRoot is not defined: "
- + getPathToComponent(this)
+ + ComponentUtils.getPathToComponent(this)
+ (location != null ? " created from: " + location : ""));
}
}
@@ -223,53 +224,6 @@ class UILeaf extends UIComponent implements UntargetableComponent, Map<String, O
return null;
}
- private String getPathToComponent(UIComponent component)
- {
- StringBuilder buf = new StringBuilder();
-
- 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();
- }
-
- private void getPathToComponent(UIComponent component, StringBuilder buf)
- {
- if (component == null)
- {
- return;
- }
-
- StringBuilder intBuf = new StringBuilder();
-
- 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);
- }
-
//-------------- END TAKEN FROM UICOMPONENTBASE ------------------
diff --git a/impl/src/test/java/javax/faces/component/AbstractUIComponentBaseTest.java b/impl/src/test/java/javax/faces/component/AbstractUIComponentBaseTest.java
index 482d172..4a284bd 100644
--- a/impl/src/test/java/javax/faces/component/AbstractUIComponentBaseTest.java
+++ b/impl/src/test/java/javax/faces/component/AbstractUIComponentBaseTest.java
@@ -74,8 +74,6 @@ public abstract class AbstractUIComponentBaseTest
methods.add(UIComponentBase.class.getDeclaredMethod("getRenderer", new Class[]{FacesContext.class}));
methods.add(UIComponentBase.class.getDeclaredMethod("getFacesContext", (Class<?>[])null));
methods.add(UIComponentBase.class.getDeclaredMethod("getParent", (Class<?>[])null));
- methods.add(UIComponentBase.class
- .getDeclaredMethod("getPathToComponent", new Class[]{UIComponent.class}));
return methods;
}
diff --git a/impl/src/test/java/javax/faces/component/UIComponentBaseTest.java b/impl/src/test/java/javax/faces/component/UIComponentBaseTest.java
index 392a3a4..f92db36 100644
--- a/impl/src/test/java/javax/faces/component/UIComponentBaseTest.java
+++ b/impl/src/test/java/javax/faces/component/UIComponentBaseTest.java
@@ -83,8 +83,6 @@ public class UIComponentBaseTest
methods.add(UIComponentBase.class.getDeclaredMethod("getRenderer", new Class[] { FacesContext.class }));
methods.add(UIComponentBase.class.getDeclaredMethod("getFacesContext", (Class<?>[])null));
methods.add(UIComponentBase.class.getDeclaredMethod("getParent", (Class<?>[])null));
- methods.add(UIComponentBase.class
- .getDeclaredMethod("getPathToComponent", new Class[] { UIComponent.class }));
return methods;
}