sâmbătă, 23 mai 2015

[OmniFaces utilities 2.0] Add a parameterized global FATAL faces message


[OmniFaces utilities] The addGlobalFatal() method adds a global FATAL faces message, with the given message body which is formatted with the given parameters.

Method:
Usage:

private static final String USER_FATAL = "The database at {0} does not respond on port {1} !";

import org.omnifaces.util.Messages;
...
Object[] params = new Object[]{"89.38.122.5", "5432"};
Messages.addGlobalFatal(USER_FATAL, params);
// or
Messages.addGlobalFatal(USER_FATAL,  "89.38.122.5", "5432");

Output:
The database at 89.38.122.5 does not respond on port 5432 !

Note Don't forget to use in page where the messages are displayed the <h:messages>, or any other approach capable to display global messages.

Note By default, this example uses the OmniFaces default message resolver, but you can use your own message resolver as in Working with OmniFaces Message Resolvers.

Niciun comentariu:

Trimiteți un comentariu