Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
The moose likes JSF and the fly likes how to change style of h:messages in code Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "how to change style of h:messages in code" Watch "how to change style of h:messages in code" New topic

how to change style of h:messages in code

Balaji Kadam
Ranch Hand

Joined: Apr 27, 2010
Posts: 31

Hi all,

in my jsf page i have added message using h:messages which will show message for all component including info and error messages.

but i want info messages to be display as blue and error as red.

i was trying to apply css class but it shows same for all messages

anybody know how to do this?

Louis Bros
Ranch Hand

Joined: Jun 03, 2011
Posts: 54


The '<h:messages />' component has the attributes 'infoClass' and 'errorClass' class you could use.


Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17280

As a general rule, anything that affects appearances in JSF is handled by CSS. JSF figured that there was already something that worked, so why re-invent it?

Of course, JSF View Definition Language is a higher-level VDL than raw HTML is, so there are often specialized sub-component CSS attributes such as the ones that Louis mentioned.

An IDE is no substitute for an Intelligent Developer.
I agree. Here's the link:
subject: how to change style of h:messages in code
It's not a secret anymore!