Package org.apache.wicket.feedback
Class FeedbackMessages
- java.lang.Object
-
- org.apache.wicket.feedback.FeedbackMessages
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Iterable<FeedbackMessage>,org.apache.wicket.util.io.IClusterable
public final class FeedbackMessages extends java.lang.Object implements org.apache.wicket.util.io.IClusterable, java.lang.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
Constructors Constructor Description FeedbackMessages()Construct.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(Component reporter, java.io.Serializable message, int level)Adds a messagevoidadd(FeedbackMessage message)Adds a message.intclear()Clears any existing messages.intclear(IFeedbackMessageFilter filter)Clears all messages that are accepted by the filter.voiddebug(Component reporter, java.io.Serializable message)Adds a new ui message with level DEBUG to the current messages.voiddetach()Detaches each stored messagevoiderror(Component reporter, java.io.Serializable message)Adds a new ui message with level ERROR to the current messages.voidfatal(Component reporter, java.io.Serializable message)Adds a new ui message with level FATAL to the current messages.FeedbackMessagefirst()Retrieves the first messageFeedbackMessagefirst(int level)Retrieves the first message that level is greater than or equal to the given levelbooleanhasMessage(int level)Checks if a message of the specifiedlevelor greater was registered.
To check for a preciselevelusehasMessage(IFeedbackMessageFilter)and pass it a reference toExactLevelFeedbackMessageFilter.booleanhasMessage(IFeedbackMessageFilter filter)voidinfo(Component reporter, java.io.Serializable message)Adds a new ui message with level INFO to the current messages.booleanisEmpty()Gets whether there are no messages.java.util.Iterator<FeedbackMessage>iterator()Gets an iterator over stored messagesjava.util.List<FeedbackMessage>messages(IFeedbackMessageFilter filter)Gets a list of messages from the page using a filter.intsize()Gets the number of messagesintsize(IFeedbackMessageFilter filter)Gets the number of messages.voidsuccess(Component reporter, java.io.Serializable message)Adds a new ui message with level SUCCESS to the current messages.java.util.List<FeedbackMessage>toList()Retrieves all stored messages as an unmodifiable listjava.lang.StringtoString()voidwarn(Component reporter, java.io.Serializable message)Adds a new ui message with level WARNING to the current messages.
-
-
-
Method Detail
-
add
public final void add(FeedbackMessage message)
Adds a message.- Parameters:
message- the message
-
add
public final void add(Component reporter, java.io.Serializable message, int level)
Adds a message- Parameters:
reporter-message-level-
-
debug
public final void debug(Component reporter, java.io.Serializable message)
Adds a new ui message with level DEBUG to the current messages.- Parameters:
reporter- the reporting componentmessage- the actual message
-
info
public final void info(Component reporter, java.io.Serializable message)
Adds a new ui message with level INFO to the current messages.- Parameters:
reporter- The reporting componentmessage- The actual message
-
success
public final void success(Component reporter, java.io.Serializable message)
Adds a new ui message with level SUCCESS to the current messages.- Parameters:
reporter- The reporting componentmessage- The actual message
-
warn
public final void warn(Component reporter, java.io.Serializable message)
Adds a new ui message with level WARNING to the current messages.- Parameters:
reporter- the reporting componentmessage- the actual message
-
error
public final void error(Component reporter, java.io.Serializable message)
Adds a new ui message with level ERROR to the current messages.- Parameters:
reporter- the reporting componentmessage- the actual message
-
fatal
public final void fatal(Component reporter, java.io.Serializable message)
Adds a new ui message with level FATAL to the current messages.- Parameters:
reporter- the reporting componentmessage- the actual message
-
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
-
hasMessage
public final boolean hasMessage(IFeedbackMessageFilter filter)
- Parameters:
filter- Filter for selecting messages- Returns:
- True if one or more messages matches the filter
-
hasMessage
public final boolean hasMessage(int level)
Checks if a message of the specifiedlevelor greater was registered.
To check for a preciselevelusehasMessage(IFeedbackMessageFilter)and pass it a reference toExactLevelFeedbackMessageFilter.- Parameters:
level- The level of the message- Returns:
trueif a message with the specifiedlevelor greater was registered
-
first
public final FeedbackMessage first()
Retrieves the first message- Returns:
- message or
nullif none
-
first
public final FeedbackMessage first(int level)
Retrieves the first message that level is greater than or equal to the given level- Parameters:
level- The minimum level of the message- Returns:
- a message with the same or a higher level, or
nullif none
-
iterator
public final java.util.Iterator<FeedbackMessage> iterator()
Gets an iterator over stored messages- Specified by:
iteratorin interfacejava.lang.Iterable<FeedbackMessage>- Returns:
- iterator over stored messages
-
messages
public final java.util.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
-
isEmpty
public final boolean isEmpty()
Gets whether there are no messages.- Returns:
- True when there are no messages
-
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 java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object- See Also:
Object.toString()
-
toList
public java.util.List<FeedbackMessage> toList()
Retrieves all stored messages as an unmodifiable list- Returns:
- stored messages as unmodifiable list
-
detach
public void detach()
Detaches each stored message
-
-