6

I get a String from < p:editor> like this : < b>This is bold text< /b>. I want to show <b>This is bold text</b> in xhtml page. What tag can i use to do that ?

Andy Brown
  • 18,961
  • 3
  • 52
  • 62
xuanhung2401
  • 311
  • 1
  • 5
  • 15

1 Answers1

19

Use an outputText with escape="true":

<h:outputText escape="true" value="<b>This is bold</b>"/>

As stated in the answer to this question:

...Facelets implicitly wraps inline [emphasis added] content in a component as represented by <h:outputText>

So, if you don't use an outputText tag with the escape attribute set to true Facelets will add one for you which will escape the html tags.

Edit: I am completely wrong about the escape attribute. Please forgive my ignorance as I am still learning as well. According to the documentation the escape attribute:

Flag indicating that characters that are sensitive in HTML and XML markup must be escaped. This flag is set to "true" by default.

Please see the answer to this OS question for a correct example.

Community
  • 1
  • 1
Jonathan Spooner
  • 7,682
  • 2
  • 34
  • 41