带LazyQueryContainer的Vaadin树型

带LazyQueryContainer的Vaadin树型,vaadin,treetable,Vaadin,Treetable,有人能给我解释一件事吗?可以将Vaadin TreeTable与LazyQueryContainer一起使用吗?我已经试过了,但没用。实际上,没有任何延迟加载。调用org.vaadin.addons.lazyquerycontainer.Query的方法loadItems,直到加载所有数据。例如,如果容器的批大小=100,并且我有500行,那么这个方法将被调用5次。这是我的密码: public class LazyHierarchicalQueryContainer extends LazyQu

有人能给我解释一件事吗?可以将Vaadin TreeTable与LazyQueryContainer一起使用吗?我已经试过了,但没用。实际上,没有任何延迟加载。调用org.vaadin.addons.lazyquerycontainer.Query的方法loadItems,直到加载所有数据。例如,如果容器的批大小=100,并且我有500行,那么这个方法将被调用5次。这是我的密码:

public class LazyHierarchicalQueryContainer extends LazyQueryContainer implements Container.Hierarchical {

    private String parentProperty = "parent";

    public LazyHierarchicalQueryContainer(QueryFactory queryFactory, Object idPropertyId, int batchSize,
        boolean compositeItems) {
        super(queryFactory, idPropertyId, batchSize, compositeItems);
    }

    public LazyHierarchicalQueryContainer(QueryDefinition queryDefinition, QueryFactory queryFactory) {
        super(queryDefinition, queryFactory);
    }

    public LazyHierarchicalQueryContainer(QueryView queryView) {
        super(queryView);
    }

    public String getParentProperty() {
        return parentProperty;
    }

    public void setParentProperty(String parentProperty) {
        this.parentProperty = parentProperty;
    }

    @Override
    public Collection<?> getChildren(Object itemId) {
        return Collections.emptyList();
    }

    @Override
    public Object getParent(Object itemId) {
        return null;
    }

    @Override
    public Collection<?> rootItemIds() {
        ArrayList arrayList = new ArrayList();
        for (Object workItem : getItemIds()) {
            if (isRoot(workItem)) {
                arrayList.add(workItem);
            }
        }
        return arrayList;
    }

    @Override
    public boolean setParent(Object itemId, Object newParentId) throws UnsupportedOperationException {
        if (getItem(newParentId) != null) {
            getItem(itemId).getItemProperty(getParentProperty()).setValue(newParentId);
        } else {
            getItem(itemId).getItemProperty(getParentProperty()).setValue(null);
        }
        return true;
    }

    @Override
    public boolean areChildrenAllowed(Object itemId) {
        return true;
    }

    @Override
    public boolean setChildrenAllowed(Object itemId, boolean areChildrenAllowed) throws UnsupportedOperationException {
        return false;
    }

    @Override
    public boolean isRoot(Object itemId) {
        return getItem(itemId).getItemProperty(parentProperty).getValue() == null;
    }

    @Override
    public boolean hasChildren(Object itemId) {
        return false;
    }
}
公共类LazyQueryContainer扩展LazyQueryContainer实现容器。分层{
私有字符串parentProperty=“parent”;
公共LazyHierarchyQueryContainer(QueryFactory QueryFactory,对象idPropertyId,int batchSize,
布尔复合项){
超级(queryFactory、idPropertyId、批次大小、复合项);
}
公共LazyHierarchyQueryContainer(QueryDefinition QueryDefinition,QueryFactory QueryFactory){
超级(查询定义,查询工厂);
}
公共LazyHierarchyQueryContainer(QueryView QueryView){
超级(queryView);
}
公共字符串getParentProperty(){
归还父母财产;
}
公共void setParentProperty(字符串parentProperty){
this.parentProperty=parentProperty;
}
@凌驾
公共集合getChildren(对象itemId){
返回集合。emptyList();
}
@凌驾
公共对象getParent(对象itemId){
返回null;
}
@凌驾
公共集合rootItemId(){
ArrayList ArrayList=新的ArrayList();
对于(对象工作项:GetItemId()){
if(isRoot(工作项)){
arrayList.add(工作项);
}
}
返回数组列表;
}
@凌驾
公共布尔setParent(对象itemId,对象newParentId)引发UnsupportedOperationException{
if(getItem(newParentId)!=null){
getItem(itemId).getItemProperty(getParentProperty()).setValue(newParentId);
}否则{
getItem(itemId).getItemProperty(getParentProperty()).setValue(null);
}
返回true;
}
@凌驾
允许使用公共布尔值(对象项ID){
返回true;
}
@凌驾
public boolean setChildrenAllowed(Object itemId,boolean areChildrenAllowed)抛出UnsupportedOperationException{
返回false;
}
@凌驾
公共布尔isRoot(对象项ID){
返回getItem(itemId).getItemProperty(parentProperty).getValue()==null;
}
@凌驾
公共布尔hasChildren(对象项ID){
返回false;
}
}

提前感谢。

您的rootItemId()实现似乎加载了所有项以过滤掉根项。这可能会导致第一次读取整个容器。

确切的问题是查询不起作用,或者是因为它加载了所有数据,而不是延迟加载?