sâmbătă, 23 mai 2015

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


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

Method:
Usage:

private static final String USER_WARN = "The {0} user has reached the maximum number, {1}, of submissions !";

import org.omnifaces.util.Messages;
...
Object[] params = new Object[]{"Mark Rightwer", 5};
Messages.addGlobalWarn(USER_WARN, params);
// or
Messages.addGlobalWarn(USER_WARN, "Mark Rightwer", 5);

Output:
The Mark Rightwer user has reached the maximum number, 5, of submissions !

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