Author: pete
Date: Thu May 12 14:00:37 2011
New Revision: 1102312

URL: http://svn.apache.org/viewvc?rev=1102312&view=rev
Log:
WICKET-3707 add FeedbackMessages#messagesForComponent

Modified:
    wicket/trunk/wicket-core/src/main/java/org/apache/wicket/Component.java
    
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/feedback/FeedbackMessages.java

Modified: 
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/Component.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket-core/src/main/java/org/apache/wicket/Component.java?rev=1102312&r1=1102311&r2=1102312&view=diff
==============================================================================
--- wicket/trunk/wicket-core/src/main/java/org/apache/wicket/Component.java 
(original)
+++ wicket/trunk/wicket-core/src/main/java/org/apache/wicket/Component.java Thu 
May 12 14:00:37 2011
@@ -198,8 +198,8 @@ import org.slf4j.LoggerFactory;
  * {@link Component#info(Serializable)}, {@link Component#warn(Serializable)},
  * {@link Component#error(java.io.Serializable)} and {@link 
Component#fatal(Serializable)} methods
  * associate feedback messages with a Component. It is generally not necessary 
to use these methods
- * directly since Wicket validators automatically register feedback messages 
on Components. Any
- * feedback message for a given Component can be retrieved with {@link 
Component#getFeedbackMessage}.
+ * directly since Wicket validators automatically register feedback messages 
on Components. 
+ * Feedback message for a given Component can be retrieved with {@link 
Component#getFeedbackMessages}.
  * 
  * <li><b>Versioning </b>- Pages are the unit of versioning in Wicket, but 
fine-grained control of
  * which Components should participate in versioning is possible via the
@@ -1403,6 +1403,14 @@ public abstract class Component
        }
 
        /**
+        * @return All feedback messages for this component
+        */
+       public final List<FeedbackMessage> getFeedbackMessages()
+       {
+               return 
Session.get().getFeedbackMessages().messagesForComponent(this);
+       }
+
+       /**
         * Gets the id of this component.
         * 
         * @return The id of this component

Modified: 
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/feedback/FeedbackMessages.java
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket-core/src/main/java/org/apache/wicket/feedback/FeedbackMessages.java?rev=1102312&r1=1102311&r2=1102312&view=diff
==============================================================================
--- 
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/feedback/FeedbackMessages.java
 (original)
+++ 
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/feedback/FeedbackMessages.java
 Thu May 12 14:00:37 2011
@@ -294,7 +294,7 @@ public final class FeedbackMessages impl
        }
 
        /**
-        * Looks up a message for the given component.
+        * Looks up a single message for the given component.
         * 
         * @param component
         *            the component to look up the message for
@@ -305,14 +305,9 @@ public final class FeedbackMessages impl
         */
        public final FeedbackMessage messageForComponent(final Component 
component)
        {
-               for (FeedbackMessage message : messages)
-               {
-                       if (message.getReporter() == component)
-                       {
-                               return message;
-                       }
-               }
-               return null;
+               final List<FeedbackMessage> list = 
messagesForComponent(component);
+
+               return list.isEmpty() ? null : list.get(0);
        }
 
        /**


Reply via email to