Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add new line Character ( \n ) in message resource bundle in JSF1.2

Tags:

jsf

In my sample JSF application am using rich:dataTable in page to display data.

I have 2 header to display value in rich:dataTable like following

--------------------------------
| UserDetails | EmpoyeeDetails |
--------------------------------

In message resource bundle file having key and value like

usrDet = UserDetails empDet = EmpoyeeDetails

I need to display like User in one line and Details in next line of that particular header

----------------------
|  User   |  Empoyee |
| Details |  Details |
---------------------

How to add new line character in message bundle between words? I tried by adding Hexadecimal code, Numerical Code for \n like , \u000A but its not working for me! Any Idea?

like image 595
Jagan Avatar asked Feb 09 '12 07:02

Jagan


1 Answers

JSF generates HTML. Newlines in HTML are not represented by the \n character, but by the <br> element.

In order to have the HTML client to interpret \n too, you need to throw in CSS white-space: pre or pre-wrap:

key = Lorem ipsum.\nDolor sit amet.
<h:outputText value="#{bundle.key}" style="white-space: pre-wrap" />

Alternatively, use <br> instead and have JSF unescape it. E.g.

key = Lorem ipsum.<br/>Dolor sit amet.
<h:outputText value="#{bundle.key}" escape="false" />
like image 173
BalusC Avatar answered Oct 20 '22 04:10

BalusC