You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by mg...@apache.org on 2012/07/31 15:59:58 UTC

git commit: WICKET-4685 ValidationError addKey fails with error abort

Updated Branches:
  refs/heads/master b89909c1f -> 89b14a67d


WICKET-4685 ValidationError addKey fails with error abort


Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/89b14a67
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/89b14a67
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/89b14a67

Branch: refs/heads/master
Commit: 89b14a67df6d9d16ad62b4a1fb6a11e878f824b0
Parents: b89909c
Author: Martin Tzvetanov Grigorov <mg...@apache.org>
Authored: Tue Jul 31 16:59:22 2012 +0300
Committer: Martin Tzvetanov Grigorov <mg...@apache.org>
Committed: Tue Jul 31 16:59:22 2012 +0300

----------------------------------------------------------------------
 .../java/org/apache/wicket/MarkupContainer.java    |    5 +-
 .../src/main/java/org/apache/wicket/Page.java      |    5 +-
 .../apache/wicket/RequestListenerInterface.java    |    3 +-
 .../apache/wicket/ajax/AbstractAjaxResponse.java   |    3 +-
 .../org/apache/wicket/ajax/AjaxRequestHandler.java |    4 +-
 .../wicket/markup/head/ResourceAggregator.java     |    3 +-
 .../apache/wicket/markup/html/basic/EnumLabel.java |    3 +-
 .../markup/html/form/EnumChoiceRenderer.java       |    3 +-
 .../wicket/markup/html/form/FormComponent.java     |    7 ++-
 .../form/validation/AbstractFormValidator.java     |    5 +-
 .../html/panel/AbstractMarkupSourcingStrategy.java |    7 ++-
 .../apache/wicket/protocol/http/RequestLogger.java |    6 ++-
 .../wicket/request/resource/AbstractResource.java  |    3 +-
 .../bundles/ConcatResourceBundleReference.java     |    3 +-
 .../apache/wicket/validation/ValidationError.java  |    7 ++-
 .../validation/validator/AbstractValidator.java    |    9 ++--
 .../java/org/apache/wicket/util/lang/Classes.java  |   29 ++++++++++
 .../org/apache/wicket/util/lang/ClassesTest.java   |   41 +++++++++++++++
 18 files changed, 116 insertions(+), 30 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/89b14a67/wicket-core/src/main/java/org/apache/wicket/MarkupContainer.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/MarkupContainer.java b/wicket-core/src/main/java/org/apache/wicket/MarkupContainer.java
index de9f2d2..d2927eb 100644
--- a/wicket-core/src/main/java/org/apache/wicket/MarkupContainer.java
+++ b/wicket-core/src/main/java/org/apache/wicket/MarkupContainer.java
@@ -43,6 +43,7 @@ import org.apache.wicket.settings.IDebugSettings;
 import org.apache.wicket.util.io.IClusterable;
 import org.apache.wicket.util.iterator.ComponentHierarchyIterator;
 import org.apache.wicket.util.lang.Args;
+import org.apache.wicket.util.lang.Classes;
 import org.apache.wicket.util.lang.Generics;
 import org.apache.wicket.core.util.string.ComponentStrings;
 import org.apache.wicket.util.string.Strings;
@@ -151,7 +152,7 @@ public abstract class MarkupContainer extends Component implements Iterable<Comp
 					if (child instanceof Border.BorderBodyContainer)
 					{
 						msg += ". Please consider using Border.addToBorder(new " +
-							this.getClass().getSimpleName() + "(\"" + this.getId() +
+								Classes.simpleName(this.getClass()) + "(\"" + this.getId() +
 							"\", ...) instead of add(...)";
 					}
 
@@ -818,7 +819,7 @@ public abstract class MarkupContainer extends Component implements Iterable<Comp
 	public String toString(final boolean detailed)
 	{
 		final StringBuilder buffer = new StringBuilder();
-		buffer.append('[').append(this.getClass().getSimpleName()).append(' ');
+		buffer.append('[').append(Classes.simpleName(this.getClass())).append(' ');
 		buffer.append(super.toString(detailed));
 		if (detailed && children_size() != 0)
 		{

http://git-wip-us.apache.org/repos/asf/wicket/blob/89b14a67/wicket-core/src/main/java/org/apache/wicket/Page.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/Page.java b/wicket-core/src/main/java/org/apache/wicket/Page.java
index 7992230..01b2190 100644
--- a/wicket-core/src/main/java/org/apache/wicket/Page.java
+++ b/wicket-core/src/main/java/org/apache/wicket/Page.java
@@ -37,6 +37,7 @@ import org.apache.wicket.request.cycle.RequestCycle;
 import org.apache.wicket.request.mapper.parameter.PageParameters;
 import org.apache.wicket.settings.IDebugSettings;
 import org.apache.wicket.settings.IPageSettings;
+import org.apache.wicket.util.lang.Classes;
 import org.apache.wicket.util.lang.Generics;
 import org.apache.wicket.util.string.StringValue;
 import org.apache.wicket.util.visit.IVisit;
@@ -384,8 +385,8 @@ public abstract class Page extends MarkupContainer implements IRedirectListener,
 				}
 				buffer.append(StringValue.repeat(levels, "	"))
 					.append(component.getPageRelativePath())
-					.append(":")
-					.append(component.getClass().getSimpleName());
+					.append(':')
+					.append(Classes.simpleName(component.getClass()));
 			}
 		});
 		return buffer.toString();

http://git-wip-us.apache.org/repos/asf/wicket/blob/89b14a67/wicket-core/src/main/java/org/apache/wicket/RequestListenerInterface.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/RequestListenerInterface.java b/wicket-core/src/main/java/org/apache/wicket/RequestListenerInterface.java
index 28ad6c7..f40c63f 100644
--- a/wicket-core/src/main/java/org/apache/wicket/RequestListenerInterface.java
+++ b/wicket-core/src/main/java/org/apache/wicket/RequestListenerInterface.java
@@ -28,6 +28,7 @@ import org.apache.wicket.behavior.Behavior;
 import org.apache.wicket.request.RequestHandlerStack.ReplaceHandlerException;
 import org.apache.wicket.request.component.IRequestableComponent;
 import org.apache.wicket.core.request.handler.ListenerInvocationNotAllowedException;
+import org.apache.wicket.util.lang.Classes;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -120,7 +121,7 @@ public class RequestListenerInterface
 		}
 
 		// Save short class name
-		name = listenerInterfaceClass.getSimpleName();
+		name = Classes.simpleName(listenerInterfaceClass);
 
 		// Register this listener
 		register();

http://git-wip-us.apache.org/repos/asf/wicket/blob/89b14a67/wicket-core/src/main/java/org/apache/wicket/ajax/AbstractAjaxResponse.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/ajax/AbstractAjaxResponse.java b/wicket-core/src/main/java/org/apache/wicket/ajax/AbstractAjaxResponse.java
index ec4a7e7..61bed9e 100644
--- a/wicket-core/src/main/java/org/apache/wicket/ajax/AbstractAjaxResponse.java
+++ b/wicket-core/src/main/java/org/apache/wicket/ajax/AbstractAjaxResponse.java
@@ -40,6 +40,7 @@ import org.apache.wicket.request.Response;
 import org.apache.wicket.request.cycle.RequestCycle;
 import org.apache.wicket.request.http.WebResponse;
 import org.apache.wicket.util.lang.Args;
+import org.apache.wicket.util.lang.Classes;
 import org.apache.wicket.util.lang.Generics;
 import org.apache.wicket.util.string.AppendingStringBuffer;
 import org.apache.wicket.util.string.Strings;
@@ -729,7 +730,7 @@ abstract class AbstractAjaxResponse
 	{
 		if (frozen)
 		{
-			throw new IllegalStateException(clazz.getSimpleName() + "s can no " +
+			throw new IllegalStateException(Classes.simpleName(clazz) + "s can no " +
 					" longer be added");
 		}
 	}

http://git-wip-us.apache.org/repos/asf/wicket/blob/89b14a67/wicket-core/src/main/java/org/apache/wicket/ajax/AjaxRequestHandler.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/ajax/AjaxRequestHandler.java b/wicket-core/src/main/java/org/apache/wicket/ajax/AjaxRequestHandler.java
index a226ca7..0cad83b 100644
--- a/wicket-core/src/main/java/org/apache/wicket/ajax/AjaxRequestHandler.java
+++ b/wicket-core/src/main/java/org/apache/wicket/ajax/AjaxRequestHandler.java
@@ -44,6 +44,7 @@ import org.apache.wicket.request.mapper.parameter.PageParameters;
 import org.apache.wicket.response.StringResponse;
 import org.apache.wicket.response.filter.IResponseFilter;
 import org.apache.wicket.util.lang.Args;
+import org.apache.wicket.util.lang.Classes;
 import org.apache.wicket.util.string.AppendingStringBuffer;
 import org.apache.wicket.util.string.Strings;
 import org.apache.wicket.util.visit.IVisit;
@@ -472,8 +473,7 @@ public class AjaxRequestHandler implements AjaxRequestTarget
 	{
 		if (frozen)
 		{
-			throw new IllegalStateException(clazz.getSimpleName() + "s can no " +
-				" longer be added");
+			throw new IllegalStateException(Classes.simpleName(clazz) + "s can no longer be added");
 		}
 	}
 

http://git-wip-us.apache.org/repos/asf/wicket/blob/89b14a67/wicket-core/src/main/java/org/apache/wicket/markup/head/ResourceAggregator.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/head/ResourceAggregator.java b/wicket-core/src/main/java/org/apache/wicket/markup/head/ResourceAggregator.java
index 353892b..bce6a11 100644
--- a/wicket-core/src/main/java/org/apache/wicket/markup/head/ResourceAggregator.java
+++ b/wicket-core/src/main/java/org/apache/wicket/markup/head/ResourceAggregator.java
@@ -32,6 +32,7 @@ import org.apache.wicket.behavior.Behavior;
 import org.apache.wicket.markup.html.DecoratingHeaderResponse;
 import org.apache.wicket.request.cycle.RequestCycle;
 import org.apache.wicket.resource.CircularDependencyException;
+import org.apache.wicket.util.lang.Classes;
 
 /**
  * {@code ResourceAggregator} implements resource dependencies, resource bundles and sorting of
@@ -101,7 +102,7 @@ public class ResourceAggregator extends DecoratingHeaderResponse
 		@Override
 		public String toString()
 		{
-			return (renderBase == null ? "null" : renderBase.getClass().getSimpleName()) + "@" +
+			return (renderBase == null ? "null" : Classes.simpleName(renderBase.getClass())) + '@' +
 				indexInRenderBase;
 		}
 	}

http://git-wip-us.apache.org/repos/asf/wicket/blob/89b14a67/wicket-core/src/main/java/org/apache/wicket/markup/html/basic/EnumLabel.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/html/basic/EnumLabel.java b/wicket-core/src/main/java/org/apache/wicket/markup/html/basic/EnumLabel.java
index 706336e..f4f48fa 100644
--- a/wicket-core/src/main/java/org/apache/wicket/markup/html/basic/EnumLabel.java
+++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/basic/EnumLabel.java
@@ -22,6 +22,7 @@ import org.apache.wicket.markup.html.WebComponent;
 import org.apache.wicket.markup.parser.XmlTag.TagType;
 import org.apache.wicket.model.IModel;
 import org.apache.wicket.model.Model;
+import org.apache.wicket.util.lang.Classes;
 
 /**
  * A Label component that is used to render an enum value. The value renderered will be the result
@@ -100,7 +101,7 @@ public class EnumLabel<T extends Enum<T>> extends WebComponent
 	 */
 	protected String resourceKey(T value)
 	{
-		return value.getDeclaringClass().getSimpleName() + "." + value.name();
+		return Classes.simpleName(value.getDeclaringClass()) + '.' + value.name();
 	}
 
 	/**

http://git-wip-us.apache.org/repos/asf/wicket/blob/89b14a67/wicket-core/src/main/java/org/apache/wicket/markup/html/form/EnumChoiceRenderer.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/EnumChoiceRenderer.java b/wicket-core/src/main/java/org/apache/wicket/markup/html/form/EnumChoiceRenderer.java
index cacd0ef..3ae1e9e 100644
--- a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/EnumChoiceRenderer.java
+++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/form/EnumChoiceRenderer.java
@@ -18,6 +18,7 @@ package org.apache.wicket.markup.html.form;
 
 import org.apache.wicket.Application;
 import org.apache.wicket.Component;
+import org.apache.wicket.util.lang.Classes;
 import org.apache.wicket.util.string.Strings;
 
 /**
@@ -95,7 +96,7 @@ public class EnumChoiceRenderer<T extends Enum<T>> implements IChoiceRenderer<T>
 	 */
 	protected String resourceKey(T object)
 	{
-		return object.getDeclaringClass().getSimpleName() + "." + object.name();
+		return Classes.simpleName(object.getDeclaringClass()) + '.' + object.name();
 	}
 
 	/**

http://git-wip-us.apache.org/repos/asf/wicket/blob/89b14a67/wicket-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java b/wicket-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
index 8d010c6..c94fa8c 100644
--- a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
+++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/form/FormComponent.java
@@ -44,6 +44,7 @@ import org.apache.wicket.model.Model;
 import org.apache.wicket.util.convert.ConversionException;
 import org.apache.wicket.util.convert.IConverter;
 import org.apache.wicket.util.lang.Args;
+import org.apache.wicket.util.lang.Classes;
 import org.apache.wicket.util.string.StringList;
 import org.apache.wicket.util.string.StringValue;
 import org.apache.wicket.util.string.Strings;
@@ -658,7 +659,7 @@ public abstract class FormComponent<T> extends LabeledWebMarkupContainer
 		{
 			StringBuilder buffer = new StringBuilder();
 			buffer.append("Could not locate error message for component: ");
-			buffer.append(getClass().getSimpleName());
+			buffer.append(Classes.simpleName(getClass()));
 			buffer.append("@");
 			buffer.append(getPageRelativePath());
 			buffer.append(" and error: ");
@@ -1171,7 +1172,7 @@ public abstract class FormComponent<T> extends LabeledWebMarkupContainer
 				}
 				if (e.getTargetType() != null)
 				{
-					error.addKey("ConversionError." + e.getTargetType().getSimpleName());
+					error.addKey("ConversionError." + Classes.simpleName(e.getTargetType()));
 				}
 				error.addKey("ConversionError");
 				reportValidationError(e, error);
@@ -1192,7 +1193,7 @@ public abstract class FormComponent<T> extends LabeledWebMarkupContainer
 				{
 					error.addKey(e.getResourceKey());
 				}
-				String simpleName = getType().getSimpleName();
+				String simpleName = Classes.simpleName(getType());
 				error.addKey("IConverter." + simpleName);
 				error.addKey("IConverter");
 				error.setVariable("type", simpleName);

http://git-wip-us.apache.org/repos/asf/wicket/blob/89b14a67/wicket-core/src/main/java/org/apache/wicket/markup/html/form/validation/AbstractFormValidator.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/validation/AbstractFormValidator.java b/wicket-core/src/main/java/org/apache/wicket/markup/html/form/validation/AbstractFormValidator.java
index fe3cd52..1c15f61 100644
--- a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/validation/AbstractFormValidator.java
+++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/form/validation/AbstractFormValidator.java
@@ -22,6 +22,7 @@ import java.util.Map;
 import org.apache.wicket.behavior.Behavior;
 import org.apache.wicket.markup.html.form.FormComponent;
 import org.apache.wicket.model.IModel;
+import org.apache.wicket.util.lang.Classes;
 import org.apache.wicket.validation.ValidationError;
 
 
@@ -109,7 +110,7 @@ public abstract class AbstractFormValidator extends Behavior implements IFormVal
 
 
 		ValidationError error = new ValidationError().addKey(resourceKey);
-		final String defaultKey = getClass().getSimpleName();
+		final String defaultKey = Classes.simpleName(getClass());
 		if (!resourceKey.equals(defaultKey))
 		{
 			error.addKey(defaultKey);
@@ -173,6 +174,6 @@ public abstract class AbstractFormValidator extends Behavior implements IFormVal
 	 */
 	protected String resourceKey()
 	{
-		return getClass().getSimpleName();
+		return Classes.simpleName(getClass());
 	}
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/wicket/blob/89b14a67/wicket-core/src/main/java/org/apache/wicket/markup/html/panel/AbstractMarkupSourcingStrategy.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/html/panel/AbstractMarkupSourcingStrategy.java b/wicket-core/src/main/java/org/apache/wicket/markup/html/panel/AbstractMarkupSourcingStrategy.java
index 0a916c3..c7fe735 100644
--- a/wicket-core/src/main/java/org/apache/wicket/markup/html/panel/AbstractMarkupSourcingStrategy.java
+++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/panel/AbstractMarkupSourcingStrategy.java
@@ -25,6 +25,7 @@ import org.apache.wicket.markup.MarkupStream;
 import org.apache.wicket.markup.html.internal.HtmlHeaderContainer;
 import org.apache.wicket.markup.parser.XmlTag.TagType;
 import org.apache.wicket.markup.resolver.IComponentResolver;
+import org.apache.wicket.util.lang.Classes;
 
 /**
  * Implements boilerplate as needed by many markup sourcing strategies.
@@ -108,9 +109,9 @@ public abstract class AbstractMarkupSourcingStrategy implements IMarkupSourcingS
 					"Close tag not found for tag: " +
 						openTag.toString() +
 						". For " +
-						component.getClass().getSimpleName() +
-						" Components only raw markup is allow in between the tags but not other Wicket Component." +
-						". Component: " + component.toString());
+							Classes.simpleName(component.getClass()) +
+								" Components only raw markup is allow in between the tags but not other Wicket Component." +
+								". Component: " + component.toString());
 			}
 		}
 	}

http://git-wip-us.apache.org/repos/asf/wicket/blob/89b14a67/wicket-core/src/main/java/org/apache/wicket/protocol/http/RequestLogger.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/protocol/http/RequestLogger.java b/wicket-core/src/main/java/org/apache/wicket/protocol/http/RequestLogger.java
index cbcee9a..e932645 100644
--- a/wicket-core/src/main/java/org/apache/wicket/protocol/http/RequestLogger.java
+++ b/wicket-core/src/main/java/org/apache/wicket/protocol/http/RequestLogger.java
@@ -18,6 +18,7 @@ package org.apache.wicket.protocol.http;
 
 import org.apache.wicket.request.ILoggableRequestHandler;
 import org.apache.wicket.request.IRequestHandler;
+import org.apache.wicket.util.lang.Classes;
 import org.apache.wicket.util.string.AppendingStringBuffer;
 import org.apache.wicket.util.string.Strings;
 import org.slf4j.Logger;
@@ -114,9 +115,10 @@ public class RequestLogger extends AbstractRequestLogger
 		AppendingStringBuffer sb = new AppendingStringBuffer(128);
 		if (handler != null)
 		{
+			Class<? extends IRequestHandler> handlerClass = handler.getClass();
 			sb.append("handler=");
-			sb.append(handler.getClass().isAnonymousClass() ? handler.getClass().getName()
-				: handler.getClass().getSimpleName());
+			sb.append(handlerClass.isAnonymousClass() ? handlerClass.getName()
+					: Classes.simpleName(handlerClass));
 			if (handler instanceof ILoggableRequestHandler)
 			{
 				sb.append(",data=");

http://git-wip-us.apache.org/repos/asf/wicket/blob/89b14a67/wicket-core/src/main/java/org/apache/wicket/request/resource/AbstractResource.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/request/resource/AbstractResource.java b/wicket-core/src/main/java/org/apache/wicket/request/resource/AbstractResource.java
index b857cc6..b59c505 100644
--- a/wicket-core/src/main/java/org/apache/wicket/request/resource/AbstractResource.java
+++ b/wicket-core/src/main/java/org/apache/wicket/request/resource/AbstractResource.java
@@ -34,6 +34,7 @@ import org.apache.wicket.request.resource.caching.IStaticCacheableResource;
 import org.apache.wicket.settings.IResourceSettings;
 import org.apache.wicket.util.io.Streams;
 import org.apache.wicket.util.lang.Args;
+import org.apache.wicket.util.lang.Classes;
 import org.apache.wicket.util.time.Duration;
 import org.apache.wicket.util.time.Time;
 
@@ -528,7 +529,7 @@ public abstract class AbstractResource implements IResource
 		{
 			throw new IllegalArgumentException("you are not allowed to directly access header [" +
 				name + "], " + "use one of the other specialized methods of " +
-				getClass().getSimpleName() + " to get or modify its value");
+					Classes.simpleName(getClass()) + " to get or modify its value");
 		}
 	}
 

http://git-wip-us.apache.org/repos/asf/wicket/blob/89b14a67/wicket-core/src/main/java/org/apache/wicket/resource/bundles/ConcatResourceBundleReference.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/resource/bundles/ConcatResourceBundleReference.java b/wicket-core/src/main/java/org/apache/wicket/resource/bundles/ConcatResourceBundleReference.java
index d7f9bae..f274a1a 100644
--- a/wicket-core/src/main/java/org/apache/wicket/resource/bundles/ConcatResourceBundleReference.java
+++ b/wicket-core/src/main/java/org/apache/wicket/resource/bundles/ConcatResourceBundleReference.java
@@ -32,6 +32,7 @@ import org.apache.wicket.request.resource.JavaScriptResourceReference;
 import org.apache.wicket.request.resource.PackageResourceReference;
 import org.apache.wicket.request.resource.ResourceReference;
 import org.apache.wicket.util.lang.Args;
+import org.apache.wicket.util.lang.Classes;
 
 /**
  * A resource bundle that automatically concatenates the given resources. These resources should all
@@ -126,7 +127,7 @@ public class ConcatResourceBundleReference<T extends HeaderItem & IReferenceHead
 				throw new IllegalArgumentException(
 					"ConcatResourceBundleReference only works with CssResourceReference and JavaScriptResourceReference, " +
 						curProvidedResource + " provides a " +
-						reference.getClass().getSimpleName());
+						Classes.simpleName(reference.getClass()));
 			}
 		}
 	}

http://git-wip-us.apache.org/repos/asf/wicket/blob/89b14a67/wicket-core/src/main/java/org/apache/wicket/validation/ValidationError.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/validation/ValidationError.java b/wicket-core/src/main/java/org/apache/wicket/validation/ValidationError.java
index 61e82e9..c9736b1 100644
--- a/wicket-core/src/main/java/org/apache/wicket/validation/ValidationError.java
+++ b/wicket-core/src/main/java/org/apache/wicket/validation/ValidationError.java
@@ -27,6 +27,7 @@ import java.util.Map.Entry;
 
 import org.apache.wicket.markup.html.form.ValidationErrorFeedback;
 import org.apache.wicket.util.lang.Args;
+import org.apache.wicket.util.lang.Classes;
 import org.apache.wicket.util.string.Strings;
 
 /**
@@ -155,7 +156,7 @@ public final class ValidationError implements IValidationError
 	public ValidationError addKey(IValidator<?> validator)
 	{
 		Args.notNull(validator, "validator");
-		addKey(validator.getClass().getSimpleName());
+		addKey(Classes.simpleName(validator.getClass()));
 		return this;
 	}
 
@@ -175,7 +176,7 @@ public final class ValidationError implements IValidationError
 	public ValidationError addKey(IValidator<?> validator, String variation)
 	{
 		Args.notNull(validator, "validator");
-		String key = validator.getClass().getSimpleName();
+		String key = Classes.simpleName(validator.getClass());
 		if (!Strings.isEmpty(variation))
 		{
 			key = key + "." + variation.trim();
@@ -322,7 +323,7 @@ public final class ValidationError implements IValidationError
 	public String toString()
 	{
 		StringBuilder tostring = new StringBuilder();
-		tostring.append("[").append(getClass().getSimpleName());
+		tostring.append('[').append(Classes.simpleName(getClass()));
 
 		tostring.append(" message=[").append(message);
 

http://git-wip-us.apache.org/repos/asf/wicket/blob/89b14a67/wicket-core/src/main/java/org/apache/wicket/validation/validator/AbstractValidator.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/validation/validator/AbstractValidator.java b/wicket-core/src/main/java/org/apache/wicket/validation/validator/AbstractValidator.java
index bf9c525..ef8d434 100755
--- a/wicket-core/src/main/java/org/apache/wicket/validation/validator/AbstractValidator.java
+++ b/wicket-core/src/main/java/org/apache/wicket/validation/validator/AbstractValidator.java
@@ -21,6 +21,7 @@ import java.util.Map;
 
 import org.apache.wicket.behavior.Behavior;
 import org.apache.wicket.util.io.IClusterable;
+import org.apache.wicket.util.lang.Classes;
 import org.apache.wicket.validation.INullAcceptingValidator;
 import org.apache.wicket.validation.IValidatable;
 import org.apache.wicket.validation.IValidator;
@@ -174,11 +175,11 @@ public abstract class AbstractValidator<T> extends Behavior
 		}
 
 
-		ValidationError error = new ValidationError().addMessageKey(resourceKey);
-		final String defaultKey = getClass().getSimpleName();
+		ValidationError error = new ValidationError().addKey(resourceKey);
+		final String defaultKey = Classes.simpleName(getClass());
 		if (!resourceKey.equals(defaultKey))
 		{
-			error.addMessageKey(defaultKey);
+			error.addKey(defaultKey);
 		}
 
 		error.setVariables(vars);
@@ -195,7 +196,7 @@ public abstract class AbstractValidator<T> extends Behavior
 	 */
 	protected String resourceKey()
 	{
-		return getClass().getSimpleName();
+		return Classes.simpleName(getClass());
 	}
 
 	/**

http://git-wip-us.apache.org/repos/asf/wicket/blob/89b14a67/wicket-util/src/main/java/org/apache/wicket/util/lang/Classes.java
----------------------------------------------------------------------
diff --git a/wicket-util/src/main/java/org/apache/wicket/util/lang/Classes.java b/wicket-util/src/main/java/org/apache/wicket/util/lang/Classes.java
index 213061e..a702857 100644
--- a/wicket-util/src/main/java/org/apache/wicket/util/lang/Classes.java
+++ b/wicket-util/src/main/java/org/apache/wicket/util/lang/Classes.java
@@ -40,6 +40,35 @@ public final class Classes
 	}
 
 	/**
+	 * Gets the simple name (without the package) of the given class or null if the class is null.
+	 *
+	 * @param c
+	 *            The class
+	 * @return The class simple name
+	 */
+	public static String simpleName(final Class<?> c)
+	{
+		String simpleName;
+		if (c != null)
+		{
+			if (c.isAnonymousClass())
+			{
+				simpleName = c.getSuperclass().getSimpleName();
+			}
+			else
+			{
+				simpleName = c.getSimpleName();
+			}
+		}
+		else
+		{
+			simpleName = null;
+		}
+
+		return simpleName;
+	}
+
+	/**
 	 * Takes a Class and a relative path to a class and returns any class at that relative path. For
 	 * example, if the given Class was java.lang.System and the relative path was "../util/List",
 	 * then the java.util.List class would be returned.

http://git-wip-us.apache.org/repos/asf/wicket/blob/89b14a67/wicket-util/src/test/java/org/apache/wicket/util/lang/ClassesTest.java
----------------------------------------------------------------------
diff --git a/wicket-util/src/test/java/org/apache/wicket/util/lang/ClassesTest.java b/wicket-util/src/test/java/org/apache/wicket/util/lang/ClassesTest.java
new file mode 100644
index 0000000..9977c98
--- /dev/null
+++ b/wicket-util/src/test/java/org/apache/wicket/util/lang/ClassesTest.java
@@ -0,0 +1,41 @@
+/*
+ * 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.wicket.util.lang;
+
+import java.text.SimpleDateFormat;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * @since
+ */
+public class ClassesTest extends Assert
+{
+	@Test
+	public void simpleName() throws Exception
+	{
+
+		assertEquals("String", Classes.simpleName(String.class));
+		assertEquals("String", Classes.simpleName("".getClass()));
+
+		assertEquals("SimpleDateFormat", Classes.simpleName(new SimpleDateFormat() {}.getClass()));
+
+		// anonymous interface impl
+		assertEquals("Object", Classes.simpleName(new Cloneable() {}.getClass()));
+	}
+}