问题描述
我的 ADF 页面中有一个 af:treeTable
控件,该控件的 af:selectBooleanCheckbox
列绑定到瞬态布尔 VO 属性。目的是指示选择了树的哪些节点。
当用户选择(或取消选择)一个节点时,我希望将相同的更改应用于树层次结构中的所有后代节点。
所以,我有 af:selectBooleanCheckbox
一个值更改侦听器指向下面的代码。
public void moTreeValueChangeListener(final ValueChangeEvent valueChangeEvent) {
final UIComponent cbCmp = valueChangeEvent.getComponent();
Map<String,Object> clientAttributeMap = cbCmp.getAttributes();
final String nodeKey = (String) clientAttributeMap.get("nodeKey");
// Find all descendent nodes in tree table,using the invariant that child nodes will have node keys starting
// with the ancestor's node key value.
DCIteratorBinding itr = ADFUtils.findIterator("AddSupplyModelHierVO1Iterator");
ViewObjectImpl vo = (ViewObjectImpl) itr.getViewObject();
final Consumer<Row> rowProcessor = new Consumer<Row>() {
@Override
public void accept(Row row) {
String rowNodeKey = (String) row.getAttribute("NodeKey");
if ( rowNodeKey.startsWith(nodeKey) ) {
// This is a child. Set it to the ancestor's new value!
row.setAttribute("Selector",valueChangeEvent.getNewValue());
}
}
};
// Process the rows,applying the change to each child
// NOTE: developer -- make sure value change listener is not firing for each recursive change
processRowSetHierarchy(vo,"ChildNodeVOA",rowProcessor);
// Tell the UI control to update since it's been changed
AdfFacesContext.getCurrentInstance().addPartialTarget(JSFUtils.findComponentInRoot("tt1"));
}
/**
* Traverses a hierarchical row set and applies a set of processing logic to each row
* @param rowSet starting row set
* @param childAccessorName name of attribute in row implementation that accesses child rows
* @param rowProcessor logic to apply to each row
*/
private void processRowSetHierarchy ( RowSet rowSet,String childAccessorName,Consumer<Row> rowProcessor ) {
final RowSetIterator rit = rowSet.createRowSetIterator(null);
rit.reset();
while ( rit.hasNext() ) {
final Row r = rit.next();
rowProcessor.accept(r); // process the node
// Get child nodes
final RowSet childRowSet = (RowSet) r.getAttribute(childAccessorName);
// Process all descendent nodes,recursively
processRowSetHierarchy(childRowSet,childAccessorName,rowProcessor);
}
rit.closeRowSetIterator();
}
我从日志消息中知道代码正在触发并且正在访问 VO 行对象并设置 Selector
属性(这是 af:selectBooleanCheckbox
适当绑定的内容。
但是,当我运行它时,它不起作用。选择或取消选择节点对树中的子节点没有明显影响。
我觉得我在这里遗漏了一些基本的东西。谁能提供见解?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)