Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

h:outputText with line break from resource bundle (properties files)

Tags:

jsf-2

I'm trying to break the text that is displayed inside the value attribute of the <h:outputText , that works fine if i place the text directly inside the value attribute of the <h:outputText , but if I place the same text inside the property file , it stop working

here is an example of the text

A&lt;br /&gt;B&lt;br /&gt;C

this works fine:

<h:outputText value="A&lt;br /&gt;B&lt;br /&gt;C" escape="false"/>

does not work:

<h:outputText value="#{text.someText}" escape="false"/>

code from property file:

someText = A&lt;br /&gt;B&lt;br /&gt;C

the only way i found is wrap the <h:outputText with a <pre> tag , but that's not good enough cause it changes the font of the text , it look weird , and any way I hope that there is a JSF way to achieve the line breaks when working with a property file

b.t.w I looked at the following links , but they are no good for me

JSF h:outputText line break for long words within strings

Insert a line break inside p:commandButton

Thanks ahead!

like image 839
Daniel Avatar asked Feb 14 '12 08:02

Daniel


2 Answers

The properties files doesn't need to contain XML-escaped HTML. Properties files are not parsed by a XML parser like Facelets files. Just put the HTML plain in the properties file.

someText = A<br />B<br />C

Then you can use <h:outputText value="#{text.someText}" escape="false" /> the usual way.

like image 196
BalusC Avatar answered Nov 10 '22 17:11

BalusC


Try using <:outputText escape="false" ... /> with the properties, if you want to use the formatting.

like image 1
premma Avatar answered Nov 10 '22 18:11

premma