5

I am showing a (language specific) label for values in a column. The column is sortable and the JSF label is different from the database value. I am using a primefaces datatable with pagination.

How can I sort by label and not by the database value? Is there any kind of translation possible so my JPA criteria knows about the different value?

Sorting it in-memory is not an option since the dataset might be huge and I only want to display a subset (pagination size is e.g. 10 items per page)

4

2 回答 2

0

我相信不可能实现您正在寻找的东西。

除非它知道值是什么,否则您的数据库无法排序。您可以在从数据库加载后翻译标签和排序,但由于资源限制,您不希望在内存中排序。

最好的解决方案是在数据库中实施本地化解决方案。然后您的数据库可以查找每个标签的翻译并应用排序。我个人认为这是本地化任何应用程序时要走的路,因为它允许最终用户轻松翻译。您甚至可以编写进行数据库查找而不是引用文件系统包的 Java 资源包提供程序。

于 2013-01-30T21:22:53.597 回答
0

这里有一个延迟加载的例子:

您可以按照该链接中的方法编写自定义排序。

于 2013-04-13T03:41:18.767 回答