You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by iv...@apache.org on 2007/08/17 23:06:24 UTC

svn commit: r567145 - /wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/Localizer.java

Author: ivaynberg
Date: Fri Aug 17 14:06:24 2007
New Revision: 567145

URL: http://svn.apache.org/viewvc?view=rev&rev=567145
Log:
WICKET-850 added warning to prevent possible component#getstring() abuse

Modified:
    wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/Localizer.java

Modified: wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/Localizer.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/Localizer.java?view=diff&rev=567145&r1=567144&r2=567145
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/Localizer.java (original)
+++ wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/Localizer.java Fri Aug 17 14:06:24 2007
@@ -27,6 +27,8 @@
 import org.apache.wicket.settings.IResourceSettings;
 import org.apache.wicket.util.string.AppendingStringBuffer;
 import org.apache.wicket.util.string.interpolator.PropertyVariableInterpolator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 
 /**
@@ -49,6 +51,9 @@
  */
 public class Localizer
 {
+	private static final Logger logger = LoggerFactory.getLogger(Localizer.class);
+
+
 	/** Cache properties */
 	private Map cache = new HashMap();
 
@@ -173,6 +178,16 @@
 			final String defaultValue) throws MissingResourceException
 	{
 		final IResourceSettings resourceSettings = Application.get().getResourceSettings();
+
+		if (component.findParent(Page.class) == null)
+		{
+			logger
+					.warn(
+							"Tried to retrieve a localized string for a component that has not yet been added to the page. "
+									+ "This can sometimes lead to an invalid localized resource returned. "
+									+ "Make sure you are not calling Component#getString() inside your Component's constructor. "
+									+ "Offeding component: {}", component);
+		}
 
 		// Check the cache first
 		String cacheKey = getCacheKey(key, component);