2017-07-17 35 views
1

我正在使用ADF主細節概念。ADF主細節如何適用於三級結構

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

所以

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. 

有一次,我將頭頁面,詳細信息頁面和做任何插入或更新後的導航,該表將被刷新,將獲取表的第一行的細節。

我試圖2點的方法:

首先之一,得到的標題VO的結合並設置setCurrentRowWithKeyValue與頭h_id值rowkey。

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

因爲它只爲詳細信息(d_id)找到h_id,所以這將起作用。

但是從詳細信息來看,當我導航到subdetail頁面時,上述概念不起作用。它不會爲當前的細節行獲取子細節。它僅提取第一行。

我認爲,這裏的subdetail需要詳細信息(d_id)和標題(h_id)。但我不知道,如何將兩個值放在一起在rowKey屬性中。

另一種方法我試過了,就是以VO的currentRow的關鍵,並將其設置編程

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)); 

但是這個概念也將在標題和細節層次上工作。它不適用於細節和細分級別。

getCurrentRow()。getKey()會得到空指針異常。

請建議我如何才能做到這一點。

回答

1

我已經理解了ADF中的主 - 細節關係。基本上它與setCurrentRowKey概念一起工作。每當我們創建主細節關係時,它也會創建視圖鏈接並與之關聯。該視圖鏈接和關聯將指向相應父 - 子表的主 - 外鍵關係。每當我們處理3級主細節 - 細尾概念時,我們需要以編程方式獲得所有3行鍵。

所以這對我工作的解決方案是:

//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)); 

要獲得的子細節層次的細節在主服務器和細節都必須設置,那麼只有你能得到的子細節層次的細節,否則將拋出NullPointerException。