It was easy enough to get to the "parent" View Object in the hierarchy by using the Iterator binding as in the code sniplet below:
// get reference to the parent view object via the iterator bindingDCIteratorBinding iter = ADFUtils.findIterator("IteratorName");
ViewObject parentVO = iter.getViewObject();// set bind parameter value on parent view object
parentVO.ensureVariableManager().setVariableValue("BindParameterName", "BindParameterValue");
However, the "child" View Object in the hierarchy remained without its bind parameters set. Eventually, I got to the following solution (PLEASE NOTE: You have to use the destination view object accessor name as it is defined in the View Link you've created):
// get reference to the child view object via the parent view object bindingViewObject childVO = ADFUtils.getChildViewObjectFromParent(parentVO, "ChildVOAccessorName");// set bind parameter value on child view oibjectchildVO.ensureVariableManager().setVariableValue("BindParameterName", "BindParameterValue");
The ADFUtils utility methods used above were implemented as follow:
public static DCIteratorBinding findIterator(String name) {
DCIteratorBinding iter = getDCBindingContainer().findIteratorBinding(name);
if(iter == null) {
throw new RuntimeException("Iterator '" + name + "' not found");
}
return iter;}public static ViewObject getChildViewObjectFromParent(ViewObject parentVO, String childAccessorName) {
AttributeDef attrDef = parentVO.findAttributeDef(childAccessorName);
if(attrDef == null) {
throw new RuntimeException("Attribute Definition '" + childAccessorName + "' not found on parent view object");
}
return attrDef.getAccessorVO(parentVO);
}
Your solution works pretty good, but it seems that during passivation the child bind variable loose its value.
ReplyDeleteI had to fill the bind every time the disclosure occurs.
Thank you!