0

I am working with ADF master detail concept.

 Header form (master page)
 Detail form (Detail page of Header (master page))
 SubDetail form (Detail page of Detail (master page))

So:

 Header page has h_id as primary key.
 Detail page has d_id(Detail) and h_id(Header) as primary key.
 SubDetail page has s_id (subDetail),d_id(Detail) and h_id(Header) as a primary key.

Once I will navigate from header page to detail page and after doing any insert or update, the table will be refreshed and will fetch details of first row of the table.

I tried two approaches:

First one, get the binding of the header VO and set the rowkey of setCurrentRowWithKeyValue with header h_id value:

    BindingContainer parent_binding =getBindingsContOfOtherPage("view_headerPageDef");
    OperationBinding opt =parent_binding.getOperationBinding("setCurrentRowWithKeyValue");
    opt.getParamsMap().put("rowKey",h_Id);
    opt.execute();

As it is finding h_id only for detail (d_id), this will work.

But From detail, when I am navigating to subdetail page, the above concept is not working. It's not fetching the subdetail for current row of detail. It's fetching for first row only.

I assumed, that here subdetail requires both detail (d_id) and header (h_id). But I don't know how to put both values together in rowKey attribute.

Another approach I tried is to get the key of the currentRow in VO and set it programmatically:

    BindingContainer bindings = getBindings();
    BindingContainer parent_binding =getBindingsContOfOtherPage("view_DetailPageDef");
    DCIteratorBinding child_dciter = (DCIteratorBinding)bindings.get("SubDetail_VO2Iterator");
    DCIteratorBinding parent_dciter = (DCIteratorBinding)parent_binding.get("detail_VO2Iterator");
    Key DetailKey=dciter1.getCurrentRow().getKey();
    Key parentKey=parent_dciter.getCurrentRow().getKey();
    parent_dciter.setCurrentRowWithKey(parentKey.toStringFormat(true));
    dciter1.setCurrentRowWithKey(DetailKey.toStringFormat(true));

But this concept will also work at header and detail level. It is not working for detail and subdetail level.

I am getting Null Pointer Exception at getCurrentRow().getKey().

How can I achieve this?

pnuts
  • 58,317
  • 11
  • 87
  • 139
YLG
  • 855
  • 2
  • 14
  • 36

1 Answers1

0

I have got understanding of the master - detail relationship in ADF. Basically it works with setCurrentRowKey concept. Whenever, we will create master detail relationship, it will also create view link and association with it. This view link and association will point to the primary - foreign key relationship of the respective parent - child table.

Whenever, we are dealing with 3 level master - detail - subdetail concept,we need to get all 3 row keys programmatically.

So the solution that worked for me is :

//Current Page Binding Object (SubDetail)
BindingContainer subdetail_binding = getBindings();
//Detail Page Binding Object (Detail)
BindingContainer detail_binding =getBindingsContOfOtherPage("view_DetailPageDef");
//Master Page Binding Object (Master)
BindingContainer master_binding =getBindingsContOfOtherPage("view_MasterPageDef");
//Subdetail VO Iterator
DCIteratorBinding subdetail_dciter = (DCIteratorBinding)subdetail_binding.get("SubDetail_VO2Iterator");
//Detail VO Iterator
 DCIteratorBinding detail_dciter = (DCIteratorBinding)parent_binding.get("detail_VO2Iterator");
//Master VO Iterator
 DCIteratorBinding master_dciter = (DCIteratorBinding)master_binding.get("master_VO2Iterator");  

//get Row Key of all 3 level Iterators  

Key MasterKey=master_dciter.getCurrentRow().getKey();
Key DetailKey=detail_dciter.getCurrentRow().getKey();
Key SubDetailKey=subdetail_dciter.getCurrentRow().getKey();

//set Master Page Row Key
master_dciter.setCurrentRowWithKey(MasterKey.toStringFormat(true));
//set Detail Page Row Key
detail_dciter.setCurrentRowWithKey(DetailKey.toStringFormat(true));
//set SubDetail Page Row Key
subdetail_dciter.setCurrentRowWithKey(SubDetailKey.toStringFormat(true));

To get SubDetail level details both Master and Detail must be set,then only you are able to get SubDetail level details, otherwise It will throw NullPointerException.

YLG
  • 855
  • 2
  • 14
  • 36