How to create VO s and VLs dynamically in OAF

时间:2022-06-28 20:17:04

I have to create 2 VO objects dynamicaly and created 2 VL's dynamically .I have a static HGrid.and iam setting viewlinks dynamically.It is working for 1 level but not another leve..For Example.. Grid id displaying projects to Tasks but not tasks to subtasks.

here is my code

public void createViewLink(){
OADBTransaction dbTransaction=getOADBTransaction();
OAViewObject obj = (OAViewObject)this.findViewObject("TestProjects1VO1"); 
OAViewObject obj1 = (OAViewObject)this.findViewObject("TestTasks1VO1");

AttributeDef] prjLinkAttrs = new AttributeDef[ { obj.findAttributeDef("ProjectId") };
AttributeDef] taskLinkAttrs = new AttributeDef[ { obj1.findAttributeDef("ProjectId") };
ViewLink vl = createViewLinkBetweenViewObjects("TestPrjToTestTasksVL","TestPrjToTasksAcc",
obj,prjLinkAttrs,obj1,taskLinkAttrs,null);

//OAViewObject obj3 = (OAViewObject)this.findViewObject("TestTasks1VO1"); 
OAViewObject obj2 = (OAViewObject)this.findViewObject("TestRecTasks1VO1");

AttributeDef] taskAttrs = new AttributeDef[ { obj1.findAttributeDef("TaskId") };
AttributeDef] parentTaskAttrs = new AttributeDef[ { obj2.findAttributeDef("ParentTaskId") };

ViewLink vl1 = createViewLinkBetweenViewObjects("TaskToTestTasksVL","TaskToTasksAcc",
obj1,taskAttrs,obj2,parentTaskAttrs,null);
}

OAHGridBean hgrid=(OAHGridBean)webBean.findChildRecursive("HGridRN");
OAHGridHierarchyBean hgridHierarchy = (OAHGridHierarchyBean)hgrid.findChildRecursive("TreeRN");
OATreeLevelBean treeChild = (OATreeLevelBean)hgridHierarchy.findChildRecursive("TreeRN");

OAWebBean nodeDef1 = (OAWebBean)treeChild.findChildRecursive("nodeDef1"); 
nodeDef1.setViewUsageName("TestProjects1VO1");
nodeDef1.setViewAttributeName("ProjectName");

OATreeChildBean childNode1 = (OATreeChildBean)treeChild.findChildRecursive("childNode1"); 
childNode1.setAttributeValue(VIEW_LINK_NAME,"TestPrjToTestTasksVL");
childNode1.setAttributeValue(VL_ACCESSOR_NAME_ATTR,"TestPrjToTasksAcc");

OAWebBean nodeDef2 = (OAWebBean)childNode1.findIndexedChild(childNode1,"nodeDef2"); 
nodeDef2.setAttributeValue(VIEW_USAGE_NAME, "TestTasks1VO1");
nodeDef2.setAttributeValue(VIEW_ATTRIBUTE_NAME,"TaskName");

%%%%%%%%%%%%%%%Till Here grid is getting data%%%%%%%%%%%%

This node is not getting data............i.e sub tasks are not getting data

OATreeChildBean childNode2 = (OATreeChildBean)childNode1.findIndexedChildRecursive("childNode2"); 
childNode2.setAttributeValue(VIEW_LINK_NAME,"TaskToTestTasksVL1");
childNode2.setAttributeValue(VL_ACCESSOR_NAME_ATTR,"TaskToTasksAcc"); 
OAWebBean nodeDef3 = (OAWebBean)childNode2.findIndexedChild(childNode2,"nodeDef3"); 
nodeDef3.setAttributeValue(VIEW_USAGE_NAME, "TestRecTasks1VO1");
nodeDef3.setAttributeValue(VIEW_ATTRIBUTE_NAME,"TaskName");

Please help me ..
Thanks
Rama