org.loom.i18n
Class Messages

java.lang.Object
  extended by org.loom.i18n.Messages
All Implemented Interfaces:
java.io.Serializable

public class Messages
extends java.lang.Object
implements java.io.Serializable

The collection of messages to the user. This class puts together any error, warning or informational message for the user. Note that messages can be bound to a concrete property or not. Messages are shown in the same order as they are produced, which usually is the same order in which validations are defined in the annotations.

See Also:
Serialized Form

Constructor Summary
Messages()
           
 
Method Summary
 Messages addAll(Messages messages)
          Add all messages from another Messages instance
 Message addMessage(Message message)
          Adds a new Message
 Message addMessage(java.lang.String messageKey)
          Deprecated. use error(messageKey) instead
 Message addMessage(java.lang.String propertyPath, java.lang.String messageKey)
          Deprecated. use error(propertyPath, messageKey) instead
 Message error(java.lang.String messageKey)
           
 Message error(java.lang.String propertyPath, java.lang.String messageKey)
           
 Message get(java.lang.String propertyName)
           
 java.util.List<Message> getAllMessages()
           
 java.util.Collection<Message> getBoundMessages()
           
 java.util.Collection<Message> getBoundMessages(MessageLevel level)
           
 java.util.Collection<Message> getUnboundMessages()
           
 java.util.Collection<Message> getUnboundMessages(MessageLevel level)
           
 boolean hasAnyError(java.lang.String name)
           
 Message info(java.lang.String messageKey)
           
 boolean isEmpty()
           
 void logUnrenderedMessages(MessagesRepository repository)
          If there are messages that have not been included in the HTML response, log about this as an error.
 void restoreFromRedirect(LoomServletRequest request)
          restore the Messages instance from flash context after a redirect.
 void saveForRedirect(LoomServletRequest request)
          Saves this Messages instance to the flash context for a redirect.
 int size()
           
 java.lang.String toString()
           
 Message warn(java.lang.String messageKey)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Messages

public Messages()
Method Detail

addMessage

public Message addMessage(Message message)
Adds a new Message


addAll

public Messages addAll(Messages messages)
Add all messages from another Messages instance


error

public Message error(java.lang.String propertyPath,
                     java.lang.String messageKey)

error

public Message error(java.lang.String messageKey)

info

public Message info(java.lang.String messageKey)

warn

public Message warn(java.lang.String messageKey)

addMessage

public Message addMessage(java.lang.String propertyPath,
                          java.lang.String messageKey)
Deprecated. use error(propertyPath, messageKey) instead

Adds a message

Parameters:
propertyPath - the non-normalized property path. Can be null.

addMessage

public Message addMessage(java.lang.String messageKey)
Deprecated. use error(messageKey) instead

Add a unbound message


get

public Message get(java.lang.String propertyName)
Returns:
the Message for that property, null if none

isEmpty

public boolean isEmpty()

size

public int size()
Returns:
the total number of messages of any priority

getBoundMessages

public java.util.Collection<Message> getBoundMessages()

getBoundMessages

public java.util.Collection<Message> getBoundMessages(MessageLevel level)

getUnboundMessages

public java.util.Collection<Message> getUnboundMessages()

getUnboundMessages

public java.util.Collection<Message> getUnboundMessages(MessageLevel level)

getAllMessages

public java.util.List<Message> getAllMessages()
Returns:
a list with all bound and unbound messages

hasAnyError

public boolean hasAnyError(java.lang.String name)
Parameters:
name - the name of the input tag (the property path)
Returns:
true if the component has any associated error

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

logUnrenderedMessages

public void logUnrenderedMessages(MessagesRepository repository)
If there are messages that have not been included in the HTML response, log about this as an error.

Parameters:
repository - the messagesRepository used to translate the messages before logging.

saveForRedirect

public void saveForRedirect(LoomServletRequest request)
Saves this Messages instance to the flash context for a redirect. If this instance is empty, does nothing.


restoreFromRedirect

public void restoreFromRedirect(LoomServletRequest request)
restore the Messages instance from flash context after a redirect.