jsfhtml-escape

<h:outputtext> prints HTML as-is instead of actual HTML


I am using JSF 1.2

I am trying to print text using <h:outputtext>

<h:outputText id="warningDose" styleClass="redText" value="#{templatePrescriptionMaintenanceBackingBean.doseWarningText}"></h:outputText>

Now this variable contains text with html tags. <b>,<i> etc...

But that displays content as it is instead of actual bold or italic html output.

Is there any way we can make this <h:outputText> such that it gives html response?


Solution

  • You should set in the h:outputText tag:

    escape="false"
    

    But remember that mixing "view" construction (i.e., creating a string with HTML tags) between the JSF view page and the underlying bean is kinda bad practice. All the "view production" should be in the view page.