org.apache.wicket.feedback
Class FeedbackMessages

java.lang.Object
  extended by org.apache.wicket.feedback.FeedbackMessages
All Implemented Interfaces:
Serializable, Iterable<FeedbackMessage>, IClusterable

public final class FeedbackMessages
extends Object
implements IClusterable, Iterable<FeedbackMessage>

Holds list of feedback messages. The list can be added to, cleared, queried and filtered.

WARNING: This class should typically NOT be used directly.

Author:
Eelco Hillenius, Jonathan Locke
See Also:
Serialized Form

Constructor Summary
FeedbackMessages()
          Construct.
 
Method Summary
 void add(Component reporter, String message, int level)
          Adds a message
 void add(FeedbackMessage message)
          Adds a message.
 int clear()
          Clears any existing messages.
 int clear(IFeedbackMessageFilter filter)
          Clears all messages that are accepted by the filter.
 void debug(Component reporter, String message)
          Adds a new ui message with level DEBUG to the current messages.
 void error(Component reporter, Serializable message)
          Adds a new ui message with level ERROR to the current messages.
 void fatal(Component reporter, String message)
          Adds a new ui message with level FATAL to the current messages.
 boolean hasErrorMessageFor(Component component)
          Convenience method that looks up whether the given component registered a message with this list with the level ERROR.
 boolean hasMessage(IFeedbackMessageFilter filter)
           
 boolean hasMessageFor(Component component)
          Looks up whether the given component registered a message with this list.
 boolean hasMessageFor(Component component, int level)
          Looks up whether the given component registered a message with this list with the given level.
 void info(Component reporter, String message)
          Adds a new ui message with level INFO to the current messages.
 boolean isEmpty()
          Gets whether there are no messages.
 Iterator<FeedbackMessage> iterator()
          Gets an iterator over stored messages
 FeedbackMessage messageForComponent(Component component)
          Looks up a message for the given component.
 List<FeedbackMessage> messages(IFeedbackMessageFilter filter)
          Gets a list of messages from the page using a filter.
 int size()
          Gets the number of messages
 int size(IFeedbackMessageFilter filter)
          Gets the number of messages.
 String toString()
           
 void trimToSize()
          Deprecated. because messages is actually CopyOnWriteArrayList and cannot be trimmed. Will be removed in Wicket 1.5
 void warn(Component reporter, String message)
          Adds a new ui message with level WARNING to the current messages.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FeedbackMessages

public FeedbackMessages()
Construct.

Method Detail

add

public final void add(Component reporter,
                      String message,
                      int level)
Adds a message

Parameters:
reporter -
message -
level -

clear

public final int clear()
Clears any existing messages.

Returns:
The number of messages deleted

clear

public final int clear(IFeedbackMessageFilter filter)
Clears all messages that are accepted by the filter.

Parameters:
filter - Filter for selecting messages. If null, all messages will be returned
Returns:
The number of messages deleted

debug

public final void debug(Component reporter,
                        String message)
Adds a new ui message with level DEBUG to the current messages.

Parameters:
reporter - the reporting component
message - the actual message

error

public final void error(Component reporter,
                        Serializable message)
Adds a new ui message with level ERROR to the current messages.

Parameters:
reporter - the reporting component
message - the actual message

fatal

public final void fatal(Component reporter,
                        String message)
Adds a new ui message with level FATAL to the current messages.

Parameters:
reporter - the reporting component
message - the actual message

hasErrorMessageFor

public final boolean hasErrorMessageFor(Component component)
Convenience method that looks up whether the given component registered a message with this list with the level ERROR.

Parameters:
component - the component to look up whether it registered a message
Returns:
whether the given component registered a message with this list with level ERROR

hasMessage

public final boolean hasMessage(IFeedbackMessageFilter filter)
Parameters:
filter - Filter for selecting messages
Returns:
True if one or more messages matches the filter

hasMessageFor

public final boolean hasMessageFor(Component component)
Looks up whether the given component registered a message with this list.

Parameters:
component - the component to look up whether it registered a message
Returns:
whether the given component registered a message with this list

hasMessageFor

public final boolean hasMessageFor(Component component,
                                   int level)
Looks up whether the given component registered a message with this list with the given level.

Parameters:
component - The component to look up whether it registered a message
level - The level of the message
Returns:
Whether the given component registered a message with this list with the given level

info

public final void info(Component reporter,
                       String message)
Adds a new ui message with level INFO to the current messages.

Parameters:
reporter - The reporting component
message - The actual message

isEmpty

public final boolean isEmpty()
Gets whether there are no messages.

Returns:
True when there are no messages

iterator

public final Iterator<FeedbackMessage> iterator()
Gets an iterator over stored messages

Specified by:
iterator in interface Iterable<FeedbackMessage>
Returns:
iterator over stored messages

messageForComponent

public final FeedbackMessage messageForComponent(Component component)
Looks up a message for the given component. TODO: 1.5 This should be deprecated and return a Collection.

Parameters:
component - the component to look up the message for
Returns:
the message that is found for the given component (first match) or null if none was found

messages

public final List<FeedbackMessage> messages(IFeedbackMessageFilter filter)
Gets a list of messages from the page using a filter.

Parameters:
filter - Filter for selecting messages. If null, all messages will be returned
Returns:
The messages or an empty list if no messages are found

size

public final int size()
Gets the number of messages

Returns:
the number of messages

size

public final int size(IFeedbackMessageFilter filter)
Gets the number of messages.

Parameters:
filter - Filter for counting messages. If null, the count of all messages will be returned
Returns:
the number of messages

toString

public String toString()
Overrides:
toString in class Object
See Also:
Object.toString()

trimToSize

@Deprecated
public final void trimToSize()
Deprecated. because messages is actually CopyOnWriteArrayList and cannot be trimmed. Will be removed in Wicket 1.5

Frees any unnecessary internal storage


warn

public final void warn(Component reporter,
                       String message)
Adds a new ui message with level WARNING to the current messages.

Parameters:
reporter - the reporting component
message - the actual message

add

public final void add(FeedbackMessage message)
Adds a message.

Parameters:
message - the message


Copyright © 2004-2011 Apache Software Foundation. All Rights Reserved.