Search code examples
htmldatatableprimefacesjsf-2

Primefaces 10 HTML styling in DataTable emptyMessage


I want to add html styled message for empty datatable in Primefaces 10 (emptyMessage property). Something like "Hello world!" (notice bold word world!) I use PropertyResourceBundle with message.properties properties file to load message. I tried something like this in message.properties:

grap.noData.text=Hello <b>world!</b>

but it didn't work

<p:dataTable id="grapTable" var="row"
            value="#{grController.graphics}"
            emptyMessage="#{grController.editAllowed ? msg['grap.noData.text'] : msg['grap.noData.readOnly.text']}"></p:dataTable>

Solution

  • You can do it instead with emptyMessage facet and escape="false" like this...

    <f:facet name="emptyMessage">
      <h:outputText 
         escape="false" 
         value="#{grController.editAllowed ? msg['grap.noData.text'] : msg['grap.noData.readOnly.text']}" />
    </f:facet>