html - jsf messages: adding link -


Currently in JSF, all the HTML contained in a message ( rich: message tag) ran For example, in my backing bean, I have:

  createMessage ("The title is successfully created with the product number: & lt; a href = \ "Http: //www.example.com \" & gt; "+ Product.getProductNumber (+) +" & lt; / a & gt ;.);  

Where createMessage () is just a helpful function that adds a new message in the context of the face, and then my rich: message Tag

When this message is created, my message only appears with the hidden HTML:

  Successfully created with the title product number: & lt; A href = "http://www.example.com" & gt; 1234 & lt; / A & gt;  

Is there any way to avoid this and instead provide the actual link in the message?

Thanks in advance

~ Jack

A quick solution To create a new renderer

I did this for h: message because I have different messages in different divs If you do not want to use the default renderer anytime, it is a good choice.

The standard class that you will overwrite / expand:

  public class messageender extends HtmlBasicRenderer  

You only have one ResponseWriter Which will not survive the text. Solid square is HtmlResponseWriter which escapes the text. You can increase it and overwrite

  public void writing (object text, string componentproperty name)  

so that it does not use HtmlUtils do.

Then just face-config.xml

  & lt; Render-kit & gt; Add your new renderer to & Lt; Renderer & gt; & Lt; Component-Family & gt; Javax.faces.Messages & lt; / Component-family & gt; & Lt; Renderer type & gt; Javax.faces.Messages & lt; / Renderer type & gt; & Lt; Renderer Category & gt; Com.mypackage.MessagesRenderer & lt; / Renderer category & gt; & Lt; / Renderer & gt; & Lt; / Render kit & gt;  

Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -