Vaadin Container.Filter using variable number of criterias

寵の児 提交于 2019-12-11 07:23:55

问题


Just implemented the new Container.Filter using this code:

Filter f  = 
new Or(new SimpleStringFilter(Columns.SEARCH.id(), "rpm-diastolic", true, false),  
new Or(new SimpleStringFilter(Columns.SEARCH.id(), "rpm-systolic", true, false)),
new Or(new SimpleStringFilter(Columns.SEARCH.id(), "rpm-weight", true, false))) ;
container.addContainerFilter(f);

and works fine.

Now I would like to use the following in order to build as many criterias I would need by building dynamically the filter:

List<String> filters;
for(String filter : filters) {
    Filter f  = new Or(new SimpleStringFilter(Columns.SEARCH.id(), filter, true, false) );
    container.addContainerFilter(f);
}

How can I do this for this code doesn't work...


回答1:


OK,

I was able to do this by simply passing an array to the Or constructor this way:

Filter[] filtersToAdd = new Filter[filters.size()];
for(String filterString : filters) {
filtersToAdd[i++] = 
    new Or(new SimpleStringFilter(Columns.SEARCH.id(), filterString, true, false));
}
Filter f = new Or(filtersToAdd);
container.addContainerFilter(f);


来源:https://stackoverflow.com/questions/11524495/vaadin-container-filter-using-variable-number-of-criterias

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!