SeamFramework.orgCommunity Documentation

Chapter 39. Messages

39.1. Message Creation
39.2. Properties Files

There are currently two ways to create a message within the module.

The first would mostly be used when you don't want to add the generated message directly to the UI, but want to log it out, or store it somewhere else


private MessageFactory factory;
public String getMessage() {
    MessageBuilder builder ="There are {0} cars, and they are all {1}; {1} is the best color.", 5, "green");

The second is to add the message to a list that will be returned to the UI for display.


private Messages messages;
public void setMessage() {"There are {0} cars, and they are all {1}; {1} is the best color.", 5, "green");

Either of these methods supports the four message levels which are info, warning, error and fatal.

Both MessageFactory and Messages support four ways in which to create a Message:

Examples for each of these are:

The examples in the previous section on how to create a message from a properties file made the assumption that you had already created it! Now we tell you how to actually do that.

When creating a BundleKey in the previous section, we were passing it a bundle name of "". This name is essentially the path to the properties file! Let me explain. As we all know properties files need to be on the classpath for our code to find them, so "" is telling our code that on the classpath there is a file located at a path of org/jboss/international/seam/test.

To create a property file for another language, it's simply a case of appending the name of the locale to the end of the file name. Such as for French or for American English.