无法为ADF树的视图对象设置绑定变量

时间:2015-03-04 17:11:21

标签: oracle-adf

我有一个由TreeVO制作的ADF树,它包含两个属性Parent_prod和Prod。此VO具有将其连接到自身的视图链接。 TreeVo还命名了绑定变量,我需要在运行时通过我的托管bean设置它们。我使用以下代码来设置它 -

ViewObject vo = am.findViewObject("Tree_VO1");
VariableValueManager vm = vo.ensureVariableManager();
vm.setVariableValue("a", "Oracle Sales Catalog");
vm.setVariableValue("b",selectedRow.getAttribute("Pillar"));
vm.setVariableValue("c",selectedRow.getAttribute("ProductLine"));
vm.setVariableValue("d", selectedRow.getAttribute("ProductGroup"));
vo.executeQuery();

但是在运行时通过日志(设置为FINEST),我得到的绑定变量没有设置,并且它们正在为它们获取Null值。

2 个答案:

答案 0 :(得分:2)

树绑定为其层次结构子级使用访问器。因此,您的绑定变量仅应用于顶级父视图对象 要将它传递给子实例,您需要覆盖ViewObject的方法createViewLinkAccessorRS,然后在那里重新应用您的变​​量,如下所示:

`@Override
protected ViewRowSetImpl createViewLinkAccessorRS(AssociationDefImpl associationDefImpl, ViewObjectImpl viewObjectImpl, Row row, Object[] object){
  ViewRowSetImpl vrs = super.createViewLinkAccessorRS(associationDefImpl, viewObjectImpl, row, object);

  //Apply variable from parent view object to its leaf
  viewObjectImpl.getVariableManager().setVariableValue("variable_name", getVariableManager().getVariableValue("variable_name"));
  return vrs;
}
`

答案 1 :(得分:0)

当然绑定变量没有设置,因为你假设adf树将使用视图对象实例,这是不正确的。 adf树正在使用视图访问器。

由于您已经以编程方式构建树,因此使用ADF BC毫无意义,因此您可能更喜欢使用基于POJO的编程树,如下所示:http://one-size-doesnt-fit-all.blogspot.hu/2007/05/back-to-programming-programmatic-adf.html