I am using PrimeFaces' dataTable. I get "No records found." when table has no element. I want to change this message to something like "No result" and make this message i18n type.
I don't want to use
<p:dataTable id="idTable" ... emptyMessage="#{messages['general.message.EmptyList']}" >
for every table.
How can I change p:dataTable default emptyMessage
message?
From the PrimeFaces 3.5 DataTable
source code:
210 public java.lang.String getEmptyMessage() { 211 return (java.lang.String) getStateHelper().eval(PropertyKeys.emptyMessage, "No records found."); 212 }
So, it's hard coded and there's no way to change it in a single place other way than hacking the PrimeFaces source or creating a tagfile (not composite!) <my:dataTable>
which wraps the <p:dataTable>
with the desired message set.
<ui:composition ...> <p:dataTable id="#{id}" value="#{value}" var="item" emptyMessage="#{messages['general.message.EmptyList']}"> <ui:insert /> </p:dataTable> </ui:composition>
<my:dataTable id="foo" value="#{bean.items}"> <p:column>#{item.foo}</p:column> <p:column>#{item.bar}</p:column> </my:dataTable>
If you actually don't want to change the message, but merely want to hide it altogether, then you could also opt for a pure CSS solution:
.ui-datatable-empty-message { display: none; }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With