简体   繁体   English

ExtendedDataModel的遍历方法的SequenceRange在哪里定义?

[英]Where is the SequenceRange from the walk-method from ExtendedDataModel defined?

The ExtendedDataModel from ajax4jsf uses a method called walk , looking like this: 来自ajax4jsf的ExtendedDataModel使用名为walk的方法,如下所示:

public void walk(FacesContext ctx, DataVisitor dv, Range range, Object argument){}

This method is called several times in my application. 在我的应用程序中多次调用此方法。 Some topics on internet seem to say that it the latter is defined by the rows="x" in the xhtml. 互联网上的一些主题似乎在说,后者是由xhtml中的rows="x"定义的。 However, for me range is always defined as 0 (firstRow) - -1 (getRows) . 但是,对我来说, range始终定义为0 (firstRow) -- -1 (getRows)

So I was wondering where this range is defined, so I can figure out why the wrong parameters are passed to it. 因此,我想知道此range的定义位置,因此可以弄清楚为什么将错误的参数传递给该范围。 Debugging and googling hasn't helped me so far. 到目前为止,调试和谷歌搜索并没有帮助我。

Range represents visible part of data displayed in table. 范围代表表中显示的数据的可见部分。 If you have paginator, then paginator display which page (= from which row to which row) data is presented. 如果您有分页器,则分页器将显示呈现哪一页(=从哪一行到哪一行)的数据。

Problem can be in incorrect value of rows attribute of data table (for example rows attribute is missing). 问题可能出在数据表的rows属性值不正确(例如缺少rows属性)。

Other place can be in incorrect implementation of data model. 其他地方可能是数据模型的错误实现。 Object of data model class can be used as storage for data displayed in rich:dataTable . 数据模型类的对象可用作存储在rich:dataTable数据的存储。

Real example: 真实的例子:

public class VSDataModel<RecordType> extends ExtendedDataModel<RecordType> implements Arrangeable {

    private final FetchList<RecordType> list;

    @Override
    public void walk(FacesContext ctx, DataVisitor visitor, Range range, Object obj) {
        try {
            int firstRow = ((SequenceRange) range).getFirstRow();
            int numberOfRows = ((SequenceRange) range).getRows();
            if(list == null) {
                throw new RuntimeException("Underlying list is null!");
            }
            if(list.getList() == null || firstRow != list.getFirstRow()) {
                list.fetch(firstRow, numberOfRows);
            }
            for (RecordType elem : list.getList()) {
                visitor.process(ctx, list.getPK(elem), obj);
            }
        } catch(Exception e) {
            throw new RuntimeException(e);
        }
    }
}

It is used in Java private VSDataModel<Record> dependentList; 它用于Java private VSDataModel<Record> dependentList; and html <rich:dataTable value="#{bean.dependentList}" rows="#{referenceData.recordsPerPage}"> 和html <rich:dataTable value="#{bean.dependentList}" rows="#{referenceData.recordsPerPage}">

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

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