Aliuk Aliuk - 4 months ago 14
HTML Question

Interpreting EL expression containing HTML in JSF page

I am trying to use Froala Editor, however I have a problem when trying to display something I have saved before (https://www.froala.com/wysiwyg-editor/docs#frontend)

The problem is that, having

#{article.body}
with the value
<p>aaaa</p>
:


  • if I put in my facelets page
    <div class="fr-view">#{article.body}</div>
    I see on screen the text
    <p>aaaa</p>
    (which is incorrect)

  • however if I put in my facelets page
    <div class="fr-view"><p>aaaa</p></div>
    I see
    aaaa
    (which is the correct text)



Any idea of why is this happening?

Answer

You need to tell JSF EL not to escape Bean's field value using <h:outputText> tag.

<div class="fr-view"><h:outputText value="#{article.body}" escape="false"/></div>