How to show a bold message with Seam 2 StatusMessages?

1.3k Views Asked by At

I have a seam component where I put a message using standard seam annotation:

@In
private StatusMessages statusMessages;

public void myMethod()
{
  statusMessages.add("Welcome, #{user.getName()}, after confirmation you will be able to log in.");
}

and than in the xthml page to show this message:

<h:messages id="mensagensHome" globalOnly="true" styleClass="message"
            errorClass="errormsg" infoClass="infomsg" warnClass="warnmsg"
            rendered="#{showGlobalMessages != 'false'}" />

This is working perfectly, but I have a requirement where the name should be Bold. Than I have already tryed placing standard html tags in my message like:

 statusMessages.add("Welcome, <b> #{user.getName()} </b>, after confirmation you will be able to log in.");

But than it shows the tags on the page and does not turn the name bold.

I have also tried using unicode escape character to render the html tags, but again no success.

Is it possible to use standard html tags from code looking forward to format messages in Seam?

Tx in advance.

1

There are 1 best solutions below

0
On BEST ANSWER

Actually you can't, unlike h:outputText h:messages don't have an escape property where you would be able to do escape="false".

In the link bellow you can find a sample on how to extend h:messages, actually it's not exactly h:messages that is extended but the end result is the same. So you can set escape="false" in h:messages and have the browser parse html tags.

http://balusc.blogspot.com/2010/07/using-html-in-jsf-messages.html

Be careful if you display something that the user inserted because this is is prone to html injection.

Note: The link is not mine, but it did work for me.