我正在使用ADF主细节概念。
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.
所以:
setCurrentRowWithKeyValue
一旦我从标题页导航到详细页面,在进行任何插入或更新后,表格将被刷新,并将获取表格第一行的详细信息。
我尝试了两种方法:
首先,获取标头VO的绑定并将h_id
的rowkey设置为标头 BindingContainer parent_binding =getBindingsContOfOtherPage("view_headerPageDef");
OperationBinding opt =parent_binding.getOperationBinding("setCurrentRowWithKeyValue");
opt.getParamsMap().put("rowKey",h_Id);
opt.execute();
值:
h_id
由于它仅针对细节(d_id)发现 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));
,这将起作用。
但是从细节来看,当我导航到subdetail页面时,上述概念不起作用。它没有获取当前细节行的子细节。它只取得第一排。
我假设,这里的子细节需要细节(d_id)和标题(h_id)。但我不知道如何将两个值放在rowKey属性中。
我尝试的另一种方法是在VO中获取currentRow的密钥并以编程方式设置它:
getCurrentRow().getKey()
但是这个概念也适用于标题和细节层面。它不适用于细节和细节级别。
我在{{1}}获得空指针异常。
我怎样才能做到这一点?
答案 0 :(得分:0)
我已经理解了ADF中的主 - 细节关系。基本上它适用于setCurrentRowKey概念。每当我们创建主细节关系时,它也会创建视图链接并与之关联。此视图链接和关联将指向相应父 - 子表的主 - 外键关系。
每当我们处理3级master - detail - subdetail概念时,我们需要以编程方式获取所有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));
要获得SubDetail级别的详细信息,必须设置Master和Detail,然后只能获得SubDetail级别的详细信息,否则会抛出NullPointerException。