Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create custom severity messages in JSF

Tags:

jsf

primefaces

I'm using JSF messages to show the error/warning/info messages into my web application. Also I use <p:messages> to render them in the browser with different styles.

Nevertheless, I need to create a new style for some of my messages, keeping the rest of them as they are right now. In other words, I need to create an ok severity for my JSF messages, which will display the info in a green box with a tick.

Although I've been looking at library classes, it seems not to be an straight forwarded way to achieve that. Severities are stored into FacesMessages$Severity class as an enumeration and have a private constructor. Do I have to override the source code directly?

like image 380
Xtreme Biker Avatar asked Mar 14 '13 12:03

Xtreme Biker


1 Answers

That's not possible without hacking the JSF API/impl, no.

Just reuse the INFO severity, or abuse the one apparently unused by you: FATAL. Or, if the functional requirement is purely presentational, throw in some JS/jQuery/CSS to achieve it.

A drastic alternative would be reinventing the JSF message system with custom message wrappers and custom message components.

like image 127
BalusC Avatar answered Sep 21 '22 15:09

BalusC