如何更改默认值p:dataTable emptyMessage消息 [英] How to change default p:dataTable emptyMessage message

查看:210
本文介绍了如何更改默认值p:dataTable emptyMessage消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用PrimeFaces的dataTable。我得到找不到记录。当表没有元素时。我想将此消息更改为无结果,并发出此消息i18n类型。



我不想使用

 < p:dataTable 
id =idTable
...
emptyMessage =#{messages ['general .message.EmptyList']}
>

每个表。



我更改p:dataTable默认值 emptyMessage 消息?

解决方案

从PrimeFaces 3.5 DataTable 源代码:

  210 public java.lang.String getEmptyMessage (){
211 return(java.lang.String)getStateHelper()。eval(PropertyKeys.emptyMessage,No records found。);
212}

所以,它是硬编码,没有办法在一个单一的除了攻击PrimeFaces源或创建一个 < p:dataTable> 具有所需的消息集。

 < ui:composition ...> 
< p:dataTable id =#{id}value =#{value}var =item
emptyMessage =#{messages ['general.message.EmptyList']} >
< ui:insert />
< / p:dataTable>
< / ui:composition>





  dataTable id =foovalue =#{bean.items}> 
< p:column>#{item.foo}< / p:column>
< p:column>#{item.bar}< / p:column>
< / my:dataTable>

如果您实际上不想更改消息,而只是想要隐藏它,那么您也可以选择一个纯CSS解决方案:

  .ui-datatable-empty-message {
display:none;
}


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;
}

这篇关于如何更改默认值p:dataTable emptyMessage消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆