0

What I have is <h:outputLabel value="#{userInfo.totalExp}" />

Below is what I want as output

Total - 10 Years 2 Months
U.A.E - 5 Years 0 Months
India - 5 Years 2 Months

For this in bean, I was passing data as

totalExp = "Total - 10 Years 2 Months<br />U.A.E - 5 Years 0 Months<br />India - 5 Years 2 Months"

However I see output as Total - 10 Years 2 Months<br />U.A.E - 5 Years 0 Months<br />India - 5 Years 2 Months instead of above. This gives output U.A.E in same line instead of next line.

Any idea how to get the data in next line?


Edit 1

When I use \n instead of <br />, I still get data in one line as ``.

When I view source of page, I see it as below.

<label dir="LTR">
Total - 10 years &amp; 7 months 
Ok OK
Teset</label>

means enter is present... Does that mean label is not allowing enter?

Fahim Parkar
  • 30,974
  • 45
  • 160
  • 276

1 Answers1

1

JSF escapes by default XML entites like < and > into &lt; and &gt; in order to prevent XSS attack holes being introduced by ignorant starters.

You can turn off XML escaping on a per-component basis using the escape attribute.

<h:outputLabel ... escape="false" />

The same attribute is also present in <h:outputText> and a few others.

Actually, I believe that you're currently abusing the <h:outputLabel> for the wrong purpose. It generates namely a HTML <label> element which is supposed to be associated with a HTML input element via for attribute. But the text as you've there does not seem to represent a valid label, also the for attribute is absent. Rather use <h:outputText> instead then.

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555