Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 450
Ketan Avatar asked May 09 '12 13:05

Ketan


2 Answers

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.

like image 51
javatutorial Avatar answered Oct 18 '22 17:10

javatutorial


Just set it to not escape.

<h:outputText id="warningDose" escape="false" styleClass="redText" value="#{templatePrescriptionMaintenanceBackingBean.doseWarningText}"></h:outputText>
like image 45
adarshr Avatar answered Oct 18 '22 16:10

adarshr