How to display html content in a datatable

Asked

Viewed 86 times

0

I have the message field in an Editor that after inclusion is shown in a datatable.

<rich:editor value="#{solicitacaoImpressaoBean.solicitacao.mensagem}" toolbar="full"  style="margin-bottom: 1em">

Datatable:

<rich:dataTable id="tabelaSolicitacoes" value="#{solicitacaoImpressaoBean.peg.solicitacoes}" var="solicitacao"
            iterationStatusVar="it" rowClasses="linhaPar, linhaImpar"
            style="width: 100%;"
            >

            <rich:column style="text-align: center;">
                <f:facet name="header">Data</f:facet>
            <h:outputText value="#{solicitacao.dataEnvio}" converter="dataHoraConverter"  />
            </rich:column>

            <rich:column style="text-align: center;">
                <f:facet name="header">Siape do Cadastrador</f:facet>
            <h:outputText value="#{solicitacao.siapeCadastrador.siape}" />
            </rich:column>

            <rich:column style="text-align: center;">
                <f:facet name="header">Assunto</f:facet>
            <h:outputText value="#{solicitacao.assunto}" />
            </rich:column>

            <rich:column style="text-align: center;">
                <f:facet name="header">Mensagem</f:facet>
            <h:outputText value="#{solicitacao.mensagem}" />
            </rich:column>

The problem is that the editor inserts the code of the html message and after included will display the inserted html.

Ex of the message field :<h1>Teste de inclusao na <span style="font-family:arial,helvetica,sans-serif">Mensagem Enviar Solicita&ccedil;&atilde;o</span> para a peg 4415</h1>

Test for Inclusion in Message Send Request to Peg 4415

How can I show this content in the datatable the same way I wrote in the Editor, ie without the html tags?

1 answer

0


The pattern of JSF is to escape tags from HTML and XML, what you need to do is disable it.

To the tag outputText just set the attribute escape for false:

<h:outputText escape="false" value="#{solicitacao.mensagem}" />
  • And how to keep formatting ? for example <span style="font-family:Arial,Helvetica,sans-Serif"

Browser other questions tagged

You are not signed in. Login or sign up in order to post.