0 Replies Latest reply on Jan 8, 2013 11:07 PM by user756323

    ADF:Dynamic viewLink for self referential dynamic ViewObject jdev11.

      Hi, I'm using jdeveloper studio version, because of my requirement I am creating a View Object programatically in the Application Module since I will not know how many colums will I have until the User has done some selections... Hence I am generating a Read only Dynamic View Object on the fly, I am able to display this in a table in ADF and do dynamic binding as well...

      Now the problem is that the data is actually hierarchical data, and I have constructed a parent and children atributes in the View Object to basically sort this view and build the hierarchy, I am trying to change the way this is displayed from a Table to a TreeTable in ADF... And for that I need to create a ViewLink... now I read how to do this programatically but never against the same View Object, I did found some examples on how to do this but against two different View Objects, but I want to use the same View Object which has been created on the fly (at run time)

      I have been trying to do this using createViewLinkBetweenViewObjects by passing the same VO as master and detail (self referential View Link), but it fails as the documentation says with
      InvalidParamException which says : (1) if master or detail is null (2) if master and detail represent the same view object (circular view link is disallowed)

      The odd thing here is that you can do this declaratively
      meaning you can create a View Link to the same View Object if you have a previously defined View Object at design time... (not at run time) using Expression Language... so I am puzzled to understand why this cannot be done programatically...

      1. How could this be done programatically?

      This is the code I was trying:
          public static final String DYNAMIC_BOM_VO_INSTANCE = "DynamicBomVO";
          public void createSQLBasedDynamicBomViewObject(){
              //Define the View Object Instance name
              inputElement[] inputElementsVO;
              int numberOfItems = inputElementsVO.length;
              System.out.println("Inside VO creation");
              ViewObject vo = findViewObject(DYNAMIC_BOM_VO_INSTANCE);
              //Check if view object exist and remove it if it does
              if (vo!= null)
              //Create view definition
              ViewDefImpl dynamicBomViewDef = new ViewDefImpl("com.CST.DynamicBomView");
              //Define names and types of atributes of the View
              dynamicBomViewDef.addViewAttribute("EffectAssemblyId", "EFFECT_ASSEMBLY_ID", Integer.class);
              dynamicBomViewDef.addViewAttribute("EffectCompId", "EFFECT_COMP_ID", Integer.class);
              for(int i = 0; i < numberOfItems; i++){
                  dynamicBomViewDef.addViewAttribute("RollupId"+(i+1), "ROLLUP_ID"+(i+1), Integer.class);
              dynamicBomViewDef.addViewAttribute("RollupId", "ROLLUP_ID", Integer.class);
              dynamicBomViewDef.addViewAttribute("BomLevel", "BOM_LEVEL", Integer.class);
              //Define the SQL for th eview object
              String    querytoUse = createSQLJoin(inputElementsVO); 
              //Assign query to VO
              //Create an instance of the dynamic view definition 
              vo = createViewObject(DYNAMIC_BOM_VO_INSTANCE,dynamicBomViewDef);
              AttributeDef[] parentAttrs = new AttributeDef[] {vo.findAttributeDef("EffectAssemblyId")};
              AttributeDef[] childAttrs = new AttributeDef[] {vo.findAttributeDef("EffectCompId")}; 
              ViewLink v1 = createViewLinkBetweenViewObjects("AssemblyLink", "Children", vo, parentAttrs, vo, childAttrs, null);
      I also tried creating a second instance of the same view object, and adding a view criteria but it failed saying that:

      Definition EFFECT_ASSEMBLY_ID of type Attribute is not found in DynamicBomVO, I tried using

      The code was added after createViewObject
               vo = createViewObject(DYNAMIC_BOM_VO_INSTANCE,dynamicBomViewDef);
               ViewCriteria vc = vo.createViewCriteria();
               ViewCriteriaRow vcr1 = vc.createViewCriteriaRow();
               vcr1.setAttribute("EFFECT_ASSEMBLY_ID", "=-1");
      When I used
               vcr1.setAttribute("EffectAssemblyId", "=-1"); 
      I got
      ORA-00904: "EFFECTASSEMBLYID": invalid identifier

      Please let me know if you know how could this be achieved so that I can use a treeTable once that viewLink has been stabled and the hierarchy can be constructed.


      Edited by: user756323 on Jan 8, 2013 2:58 PM

      Edited by: user756323 on Jan 8, 2013 3:03 PM

      Edited by: user756323 on Jan 8, 2013 3:07 PM