Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

Table of Contents

Table of Contents
indent10px
styledisc
printablefalse

Intro

The bean-validation module allows to use CDI concepts in combination with bean-validation.

Dependencies

The page CODI Modules provides an overview about CODI modules and how to add them to your project.

...

MessageContext

The MessageContext allows using a fluent API for

  • Creating messages
  • Creating message text
  • Processing messages
  • Changing the configuration of the current context
  • Using the current context as template for a new context

Furthermore, the context provides the current locale.

...

The default implementation provides

  • Descriptor (Key or inline-message)
  • Arguments
    • Numbered arguments
    • Named arguments
  • Payload

The Message interface extends Localizable . Therefore it's possible to use a MessageContext to create the final message text based on the message and the current configuration of the MessageContext .

...

... creates a message with the key 'msgKey' as message descriptor.
(The concrete syntax of a key depends on the used MessageResolver. Further details are available in the DevDoc.)

Example 3

Code Block
titleCreating messages with arguments
borderStylesolid
Message message = messageContext.message().text("Hello {0}").argument("MyFaces").create();

...

Code Block
titleCreating the message-text (immediately)
borderStylesolid
String messageText = messageContext.message().text("msgKey").toText();

... creates the message-text based on the constructed messagemessage-text based on the constructed message.

To avoid side-effects with other libs as well as IDEs there is no #toString().

Example 2

Code Block
titleCreating the message-text of a given message
borderStylesolid
//Message message = messageContext.message().text("Hello {name}").namedArgument("name", "MyFaces").create();
String messageText = message.toString(messageContext);

... creates the message-text based on the given message and MessageContext . That's essential if you would like to create the final text with a different/new MessageContext e.g. with a different configuration or with the current MessageContext if you receive a de-serialized message instance.

Processing messages

It's possible to register MessageHandler s which process or forward messages added to the MessageContext .

...