TAPESTRY-258: Have RenderString implement useful toString().


git-svn-id: https://svn.apache.org/repos/asf/jakarta/tapestry/branches/branch-3-0@244092 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/framework/src/org/apache/tapestry/valid/IFieldTracking.java b/framework/src/org/apache/tapestry/valid/IFieldTracking.java
index d7ceb1c..cdf509b 100644
--- a/framework/src/org/apache/tapestry/valid/IFieldTracking.java
+++ b/framework/src/org/apache/tapestry/valid/IFieldTracking.java
@@ -18,75 +18,63 @@
 import org.apache.tapestry.form.IFormComponent;
 
 /**
- *  Defines the interface for an object that tracks input fields.  This 
- *  interface is now poorly named, in that it tracks errors that may <em>not</em>
- *  be associated with a specific field.
+ * Defines the interface for an object that tracks input fields. This interface is now poorly named,
+ * in that it tracks errors that may <em>not</em> be associated with a specific field.
+ * <p>
+ * For each field, a flag is stored indicating if the field is, in fact, in error. The input
+ * supplied by the client is stored so that if the form is re-rendered (as is typically done when
+ * there are input errors), the value entered by the user is displayed back to the user. An error
+ * message renderer is stored; this is an object that can render the error message (it is usually a
+ * {@link org.apache.tapestry.valid.RenderString}wrapper around a simple string).
  * 
- *  <p>For each field, a flag is stored indicating if the field is, in fact, in error.
- *  The input supplied by the client is stored so that if the form is re-rendered
- *  (as is typically done when there are input errors), the value entered by the user
- *  is displayed back to the user.  An error message renderer is stored; this is
- *  an object that can render the error message (it is usually
- *  a {@link org.apache.tapestry.valid.RenderString} wrapper around a simple string).
- *
- *  @author Howard Lewis Ship
- *  @version $Id$
- *  @since 1.0.8
- *
- **/
+ * @author Howard Lewis Ship
+ * @version $Id$
+ * @since 1.0.8
+ */
 
 public interface IFieldTracking
 {
-	/**
-	 *  Returns true if the field is in error (that is,
-	 *  if it has an error message {@link #getErrorRenderer() renderer}.
-	 * 
-	 **/
-	
-	public boolean isInError();
-	
-	
     /**
-     *  Returns the field component.  This may return null if the error
-     *  is not associated with any particular field.
-     * 
-     **/
+     * Returns true if the field is in error (that is, if it has an error message
+     * {@link #getErrorRenderer() renderer}.
+     */
+
+    public boolean isInError();
+
+    /**
+     * Returns the field component. This may return null if the error is not associated with any
+     * particular field.
+     */
 
     public IFormComponent getComponent();
 
     /**
-     *  Returns an object that will render the error message.
+     * Returns an object that will render the error message. Alternately, the
+     * <code>toString()</code> of the renderer can be used as a simple error message.
      * 
-     *  @since 1.0.9
-     * 
-     **/
+     * @since 1.0.9
+     */
 
     public IRender getErrorRenderer();
 
-
     /**
-     *  Returns the invalid input recorded for the field.  This is stored
-     *  so that, on a subsequent render, the smae invalid input can be presented
-     *  to the client to be corrected.
-     * 
-     **/
+     * Returns the invalid input recorded for the field. This is stored so that, on a subsequent
+     * render, the smae invalid input can be presented to the client to be corrected.
+     */
 
     public String getInput();
 
     /**
-     *  Returns the name of the field, that is, the name assigned by the form
-     *  (this will differ from the component's id when any kind of looping operation
-     *  is in effect).
-     * 
-     **/
+     * Returns the name of the field, that is, the name assigned by the form (this will differ from
+     * the component's id when any kind of looping operation is in effect).
+     */
 
     public String getFieldName();
 
     /**
-     *  Returns the validation constraint that was violated by the input.  This
-     *  may be null if the constraint isn't known.
-     * 
-     **/
+     * Returns the validation constraint that was violated by the input. This may be null if the
+     * constraint isn't known.
+     */
 
     public ValidationConstraint getConstraint();
 }
\ No newline at end of file
diff --git a/framework/src/org/apache/tapestry/valid/IValidationDelegate.java b/framework/src/org/apache/tapestry/valid/IValidationDelegate.java
index e6ad166..c869537 100644
--- a/framework/src/org/apache/tapestry/valid/IValidationDelegate.java
+++ b/framework/src/org/apache/tapestry/valid/IValidationDelegate.java
@@ -185,7 +185,10 @@
      * recorder.
      * 
      * @param errorRenderer
-     *            object that will render the error message (@see RenderString}
+     *            object that will render the error message (@see RenderString}. The object should
+     *            implement a reasonable <code>toString()</code> as well, to allow the error
+     *            message to be rendered using an Insert component, or used where full markup is not
+     *            allowed.
      * @param constraint
      *            the constraint that was violated, or null if not known
      */
diff --git a/framework/src/org/apache/tapestry/valid/RenderString.java b/framework/src/org/apache/tapestry/valid/RenderString.java
index 1dfd30f..402aa63 100644
--- a/framework/src/org/apache/tapestry/valid/RenderString.java
+++ b/framework/src/org/apache/tapestry/valid/RenderString.java
@@ -14,24 +14,21 @@
 
 package org.apache.tapestry.valid;
 
-import org.apache.commons.lang.builder.ToStringBuilder;
 import org.apache.tapestry.IMarkupWriter;
 import org.apache.tapestry.IRender;
 import org.apache.tapestry.IRequestCycle;
 
 /**
- *  A wrapper around {@link String} that allows the String to
- *  be renderred.  This is primarily used to present
- *  error messages.
- *
- *  @author Howard Lewis Ship
- *  @version $Id$
- *
- **/
+ * A wrapper around {@link String}that allows the String to be renderred. This is primarily used to
+ * present error messages.
+ * 
+ * @author Howard Lewis Ship
+ */
 
 public class RenderString implements IRender
 {
     private String _string;
+
     private boolean _raw = false;
 
     public RenderString(String string)
@@ -40,11 +37,12 @@
     }
 
     /**
-     *  @param string the string to render
-     *  @param raw if true, the String is rendered as-is, with no filtering.
-     *  If false (the default), the String is filtered.
-     *
-     **/
+     * @param string
+     *            the string to render
+     * @param raw
+     *            if true, the String is rendered as-is, with no filtering. If false (the default),
+     *            the String is filtered.
+     */
 
     public RenderString(String string, boolean raw)
     {
@@ -53,12 +51,9 @@
     }
 
     /**
-     *  Renders the String to the writer.  Does nothing if the string is null.
-     *  If raw is true, uses {@link IMarkupWriter#printRaw(String)}, otherwise
-     *  {@link IMarkupWriter#print(String)}.
-     * 
-     *
-     **/
+     * Renders the String to the writer. Does nothing if the string is null. If raw is true, uses
+     * {@link IMarkupWriter#printRaw(String)}, otherwise {@link IMarkupWriter#print(String)}.
+     */
 
     public void render(IMarkupWriter writer, IRequestCycle cycle)
     {
@@ -83,10 +78,6 @@
 
     public String toString()
     {
-        ToStringBuilder builder = new ToStringBuilder(this);
-        builder.append("string", _string);
-        builder.append("raw", _raw);
-
-        return builder.toString();
+        return _string;
     }
-}
+}
\ No newline at end of file
diff --git a/status.xml b/status.xml
index cbd1d69..72f1708 100644
--- a/status.xml
+++ b/status.xml
@@ -281,7 +281,9 @@
     <action type="fix" dev="HLS" due-to="Dominik Kreutz" fixes-bug="TAPESTRY-167">
       [PATCH] ValidationStrings_de.properties
     </action>
-      
+    <action type="fix" dev="HLS" fixes-bug="TAPESTRY-258">
+      Have RenderString implement useful toString().
+    </action>  
   </release>
 
   <release version="3.0.1" date="Oct 16 2004">