简体   繁体   English

具有延迟加载,过滤和排序的jsf数据表

[英]jsf datatable with lazy loading, filtering and sorting

I have worked on several projects with a lot of data tables. 我参与了几个包含大量数据表的项目。 The tables had sorting, filtering and paging of course on server side and with help of the db (all databases have implemented sorting, filtering -where and limit the returned results). 这些表当然在服务器端和db的帮助下进行了排序,过滤和分页(所有数据库都实现了排序,过滤 - 并限制返回的结果)。

When workig on real application there are a thousands of even a millions rows. 在真正的应用程序上工作时,有数千甚至数百万行。

But I have seen several JSF datatable components. 但我见过几个JSF数据表组件。
They implement pagination, sorting and filtering on client side! 他们在客户端实现分页,排序和过滤! According to me this is very silly. 据我说这是非常愚蠢的。 This technology is called enterprise and they sort the data on the client side with java script! 这项技术称为企业,他们使用java脚本在客户端对数据进行排序!

I have not seen any good JSF data grid that has build in features for sorting, filtering and lazy loading on the server side. 我还没有看到任何好的JSF数据网格,它在服务器端构建了用于排序,过滤和延迟加载的功能。

Why is that? 这是为什么? Am I looking in wrong direction or really there in no build support for this. 我是在寻找错误的方向还是真的没有建立支持。 Lately I am testing primefaces and lazy loading datatable. 最近我正在测试primefaces和延迟加载数据表。 It really works fine, but the table I can only lazy load. 它确实工作正常,但我只能懒加载表。 If you add sort and filter, then the problems begin. 如果添加排序和过滤器,则问题就会开始。

Conclusion: Is there any datatable JSF component than can perform lazy load pagination, and filtering and sorting on server side? 结论:是否有任何可数据化的JSF组件可以执行延迟加载分页,以及在服务器端进行过滤和排序? If I need to implement my own solution thanks to the teams that made client side sorting and filtering, they are useless. 如果我需要实现自己的解决方案,这要归功于进行客户端排序和过滤的团队,它们是无用的。

No, there isn't. 不,没有。 Because the component library cannot know what will be the persistence mechanism. 因为组件库无法知道什么是持久性机制。

However, many data tables offer options for presenting this. 但是,许多数据表提供了显示此选项的选项。 For example richfaces's datatable has the so called DataModel. 例如,richfaces的数据表具有所谓的DataModel。 For example what we did was: 例如我们做的是:

public class CustomDataProvider implements DataProvider<ClassToShow>,
        Sortable2, Filterable { .. }


public class PagingExtendedTableDataModel<T> extends ExtendedDataModel implements
        Serializable, Modifiable {

    private DataProvider dataProvider;
    private Object rowKey;
    private List wrappedKeys;
    private Map wrappedData;
    private Integer rowCount;
    private Integer rowIndex;
    private List<FilterField> filterFields;
    private List<SortField2> sortFields;

    public PagingExtendedTableDataModel(DataProvider<T> dataProvider) { .. }

}

You will have to implement all the methods in a way that suits your persistence mechanism 您必须以适合您的持久性机制的方式实现所有方法

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM