Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multi-line value in Resource.properties file?

Tags:

java

jsf

jsf-2

I have a multi-line value in Resource.properties file:

TXT_ABOUT = first line \
second line \n \
third line. 

I am displaying this in the About box:

<h:outputText value="#{txt.TXT_ABOUT}"/> 

(The txt is defined via faces-config.xml:

<resource-bundle>
  <base-name>com.compayn.etcetc.Resources</base-name>
    <var>txt</var>
</resource-bundle>

but this is not important for the question.)

The problem is: new line marks in the variable definition are not shown on the rendered page, it's all in one row. Is this syntax above OK? Is \n OK?

like image 704
Danijel Avatar asked Mar 21 '23 12:03

Danijel


1 Answers

You have to use backslash (\) at the end of the line. This question was already asked here.

Your problem is probably because HTML doesn't care about new line. If you want to display a new line you have to use the <br /> tag.

You can include HTML code in your properties file and the use the escape="false" to avoid escaping the HTML tags when generating the HTML.

TXT_ABOUT = first line<br />\
    second line<br />\
    third line.

JSF code:

<h:outputText value="#{txt.TXT_ABOUT}" escape="false" /> 
like image 164
LaurentG Avatar answered Mar 23 '23 01:03

LaurentG