mrjimoy_05
mrjimoy_05

Reputation: 3568

Display html formatting on liferay

I know it's a simple question, but I've got stuck here. How to display html formatting on liferay? I have tried to use outputText or outputLabel, but on the page view, it still display as is. For example (supposed backing.val value is output <b>text</b>):

<h:outputText value="#{backing.val}" />
  --> output <b>text</b>

<p:outputLabel value="#{backing.val}" />
  --> output <b>text</b>

I want the text is bold. How to do that? Thank you very much.

Upvotes: 0

Views: 221

Answers (2)

Vikas V
Vikas V

Reputation: 3186

Adding escape="false" is vulnerable for Cross Site Scripting.

Why don't you use style or styleClass instead?

In this case, your output from the bean should be just text and not <b>text</b>

<h:outputText value="#{backing.val}" style="font-weight:bold;"/>

OR

<h:outputText value="#{backing.val}" styleClass="boldTextClass"/>

.boldTextClass
{
  font-weight: bold;
}

Upvotes: 2

Andrey Adamovich
Andrey Adamovich

Reputation: 20663

Add escape="false" attribute:

<h:outputText value="#{backing.val}" escape="false"/>

More information can be found here: http://www.jsftoolbox.com/documentation/help/12-TagReference/html/h_outputText.html

Upvotes: 2

Related Questions