Author: jonl
Date: Wed Jun  6 00:36:11 2007
New Revision: 544753

URL: http://svn.apache.org/viewvc?view=rev&rev=544753
Log:
ExternalLabel label model was not being HTML escaped correctly.  Factored out a 
getModelObjectAsString(Object) method that can be used by components which have 
auxilliary models.

Modified:
    
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/Component.java
    
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/link/ExternalLink.java

Modified: 
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/Component.java
URL: 
http://svn.apache.org/viewvc/incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/Component.java?view=diff&rev=544753&r1=544752&r2=544753
==============================================================================
--- 
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/Component.java
 (original)
+++ 
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/Component.java
 Wed Jun  6 00:36:11 2007
@@ -1149,25 +1149,30 @@
         */
        public final String getModelObjectAsString()
        {
-               final Object modelObject = getModelObject();
-               if (modelObject != null)
-               {
-                       // Get converter
-                       final IConverter converter = 
getConverter(modelObject.getClass());
+               return getModelObjectAsString(getModelObject());
+       }
+       
+       /**
+        * @param modelObject Model object to convert to string
+        * @return The string
+        */
+       public final String getModelObjectAsString(final Object modelObject)
+       {
+               // Get converter
+               final IConverter converter = 
getConverter(modelObject.getClass());
 
-                       // Model string from property
-                       final String modelString = 
converter.convertToString(modelObject, getLocale());
+               // Model string from property
+               final String modelString = 
converter.convertToString(modelObject, getLocale());
 
-                       if (modelString != null)
+               if (modelString != null)
+               {
+                       // If we should escape the markup
+                       if (getFlag(FLAG_ESCAPE_MODEL_STRINGS))
                        {
-                               // If we should escape the markup
-                               if (getFlag(FLAG_ESCAPE_MODEL_STRINGS))
-                               {
-                                       // Escape it
-                                       return 
Strings.escapeMarkup(modelString, false, true).toString();
-                               }
-                               return modelString;
+                               // Escape it
+                               return Strings.escapeMarkup(modelString, false, 
true).toString();
                        }
+                       return modelString;
                }
                return "";
        }

Modified: 
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/link/ExternalLink.java
URL: 
http://svn.apache.org/viewvc/incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/link/ExternalLink.java?view=diff&rev=544753&r1=544752&r2=544753
==============================================================================
--- 
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/link/ExternalLink.java
 (original)
+++ 
incubator/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/markup/html/link/ExternalLink.java
 Wed Jun  6 00:36:11 2007
@@ -221,7 +221,7 @@
                this.checkComponentTag(openTag, "a");
                if ((label != null) && (label.getObject() != null))
                {
-                       replaceComponentTagBody(markupStream, openTag, 
label.getObject().toString());
+                       replaceComponentTagBody(markupStream, openTag, 
getModelObjectAsString(label.getObject()));
                }
                else
                {


Reply via email to