tags:

views:

42

answers:

2

By Default , every JSF FacesMessage is added in a single row , I wanted to add a HTML
in the message itself, so that the error is shown neatly. I tried few ways but was not successful.

I am using Facelets, JSF 1.2 without Tomahawk or other libs and XHTML Transitional Doctype

A: 

Use a CSS class to format the message, as BalusC told you in your previous question:

http://stackoverflow.com/questions/3186659/showing-the-jsf-error-messages

pakore
+2  A: 

In theory, you want an escape attribute for the h:messages component like the h:outputText has. You're not the only one who wants this, this is requested before more than often, but it's a WONTFIX according the JSF guys.

You have several options:

  1. Use \n instead of <br> and apply CSS accordingly (easiest).

    #messages td { white-space: pre; }
    
  2. Create a custom renderer which extends MessageRenderer (bit harder, but nice if you want to cover more HTML than only linebreaks).

  3. Gather the messages yourself in some List in a bean and display them using t:dataList (not recommended, prefer a custom renderer).

BalusC