12.1.3. OAF. How to join 2 View Object which populating programmatically?

1.3k Views Asked by At

I have 2 View Object which populating programmatically, i.e. this objects don't have a SQL query in Query Statement region. There is HeaderVO and LinesVO. My task is display advanced table in advanced table. And this advanced tables based on HeaderVO and LinesVO. If I use View Link than the HeaderVO table displays data but LinesVO table displays only "No search conducted". It's logically and I understand why it is.

enter image description here

But how can I connected this 2 tables (View Objects)?

2

There are 2 best solutions below

0
On

As the VO populates programatically, you can try by creating the View Link between these VOs also programatically. You can use the below method for the same :

Assume Master VO as deptVO and Detail VO as empVO.

  // Build an attribute array, consisting of deptVO.DeptNum for Master VO
  AttributeDef[] deptAttrs = new AttributeDef[1];
  deptAttrs[0] = deptVO.findAttributeDef("DeptNum");

  // Build an attribute array, consisting of empVO.DeptNum for Detail VO
  AttributeDef[] empAttrs = new Attributedef[1];
  empAttrs[0] = empVO.findAttributeDef("DeptNum");

  ViewLink vl = myAM.createViewLinkBetweenViewObjects("yourVLName",
  "VLAccessor", //accessor name
  deptVO, //master VO
  deptAttrs, //master VO attribute
  empVO, //detail VO
  empAttrs, //detail VO attribute
  null); //association clause
0
On

In order to have a Master-Detail relationship in OAF advancedTable component, the detail VO child attribute must be correctly mapped. As you are programmatically defined Master VO and Child VO, please ensure that this step has been completed. Are you creating advancedTable declaratively or programmatically?

createViewLinkBetweenViewObjects API

ViewObject voDept = am.createViewObject("MyDeptVO", "package1.DeptView");
    ViewObject voEmp = am.createViewObject("MyEmpVO", "package1.EmpView");

    AttributeDef[] deptLinkAttrs = new AttributeDef[] { voDept.findAttributeDef("Deptno") };
    AttributeDef[] empLinkAttrs = new AttributeDef[] { voEmp.findAttributeDef("Deptno") };

    ViewLink vl = am.createViewLinkFromEntityAssocName("MyDeptEmpLink",
                        "Employees",
                        voDept, deptLinkAttrs,
                        voEmp, empLinkAttrs,
                        null);