【问题标题】:Set rows in extendedDataTable as selected from backing bean将扩展数据表中的行设置为从支持 bean 中选择的行
【发布时间】:2011-11-19 07:41:03
【问题描述】:
我想知道如何以编程方式将 ExtendedDataTable 中的行设置为从我的支持 bean 中选择的行。我需要在我的网络应用程序中编辑用户。用户有一些角色,所以我想要的是在加载页面时,在扩展数据表中选择用户拥有的组。
我将 Spring3 与 JSF 2 和 Richfaces 4 一起使用。
我想我需要将表绑定到请求范围内的支持 bean。我可以为此使用 Spring 请求范围吗?之后我需要在我猜的数据表上实现 walk() 。我不知道从那里去哪里,有人可以指出正确的方向或给我一个例子吗?
问候,
德克
【问题讨论】:
标签:
spring
jsf
richfaces
selectedvalue
richdatatable
【解决方案1】:
这是我的一段代码。这行得通,我看到“行数据等于对象”日志语句,但现在我需要对“选定”行说,但据我所知,没有一种方法......我该如何完成这个?
public void selectRows(){
Collection<Object> s = new ArrayList<Object>(getGroups());
log.debug("set the selection to the table");
table.getTable().walk(FacesContext.getCurrentInstance(), new DataVisitor() {
@Override
public DataVisitResult process(FacesContext context, Object rowKey,
Object argument) {
log.debug("entered walk");
Collection<Object> selection = (Collection<Object>) argument;
for(Object o : selection){
table.getTable().setRowKey(rowKey);
if(table.getTable().getRowData().equals(o)){
log.debug("rowdata equals object");
table.getTable().getSelection().add(o);
log.debug("size of selection is: " + table.getTable().getSelection().size());
}
}
table.getTable().setRowKey(rowKey);
return null;
}
}, s );
}