0

I have the following problem: The "value"-Attribute of my "h:outbuttext" is set dynamically as follows:

    <h:outputText value="#{bean.getText()}" style="position: relative;" escape="false"/>

So the "value"-Attribute of "h:outbuttext" looks like this:

    1. Cars<br/>2. Busses<br/>3. Plains

And my expected result is:

  1. Cars
  2. Busses
  3. Plains

But the <'br/'>s are not recognized as word wrap and my actual result looks like this:

1. Cars<br/>2. Busses<br/>3. Plains

When I set the "value"-Attribute of my "h:outputtext" as a raw string like this:

    <h:outputText value="1. Cars&lt;br/&gt;2. Busses&lt;br/&gt;3. Plains" style="position: relative;" escape="false"/>

then I get the expected result.

So my question is, how do I get the <'br'/> work for dynamically set "value"-Attributes?

Thanks in advance!!!!

Kukeltje
  • 12,223
  • 4
  • 24
  • 47
  • Problem suggests that the string returned by `getText()` is already escaped by itself. I.e. it already contains `<` instead of `<` and so on. To confirm that, log/print it to stdout instead of printing it via HTML (in a JSF page). In that case you would need to take a step back and solve over there where it actually got escaped. – BalusC Nov 18 '16 at 09:43
  • @BalusC, thank you very much!!!The problem was, that I used "<br/&gt" bean side and I think your suggestion, that the string was already escaped is true. I rplaced "<br/&gt" with "
    " and now it just works fine!!! Thank you very much again!!!
    – shaolinmonkabbot Nov 18 '16 at 10:38

0 Answers0