Get the tools you need to learn Java skills fast!
Video tutorials, eBooks, hands-on lab exercises, sample code.
Get started
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 Badass: Making Users Awesome this week in the Game Development 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: 16535

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.

Customer surveys are for companies who didn't pay proper attention to begin with.
I agree. Here's the link:
subject: how to change style of h:messages in code