简体   繁体   English

使用adf业务组件时如何从托管bean填充jsf表?

[英]How to populate a jsf table from a managed bean while using adf business components?

I am new to ADF and it seems I am missing something. 我是ADF的新手,似乎丢失了一些东西。 I am using the Oracle HR database. 我正在使用Oracle HR数据库。 I am using Business Components as the Model. 我正在使用业务组件作为模型。 I have ViewObjects for Country, Location and Department. 我有用于国家,位置和部门的ViewObjects。 As well as ViewLinks by FK between Country-Location and Location-Department. 以及国家/地区位置和位置部门之间的FK ViewLinks。 I exposed a DataControl Country-> Location -> Deperatments. 我暴露了一个DataControl国家->位置->绝望。

So now I can build a JSF with three areas in which each is shown. 因此,现在我可以构建一个包含三个区域的JSF,每个区域都在其中显示。 If I click on a country I get the locations. 如果我单击一个国家,我会得到位置。 If I then click on location I get the departments. 如果然后单击位置,我会找到部门。 That works. 这样可行。

But I want to show only Country and Departments. 但我只想显示国家和部门。 So I implemented a managed bean to make use of the iterators and populate the department table throught that bean, by binding it to the value attribute of the table. 因此,我实现了一个托管bean来利用迭代器,并通过将bean绑定到表的value属性来填充部门表。 But I only have Row objects to return and due to use of BC no Class definitions which I could map my rows back to objects. 但是我只有Row对象要返回,并且由于使用了BC,所以没有可以将行映射回对象的Class定义。

So how can I just show all Departments in a Country? 那我怎样才能显示一个国家的所有部门呢? What is the ADF way to do this? ADF执行此操作的方法是什么?

My managed bean: 我的托管bean:

public class CountryDepartmensBean {

public CountryDepartmensBean() {
    super();
}

private ArrayList<Row> populate;

public ArrayList<Row> getPopulate() {
    DCBindingContainer bindings = (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
    DCIteratorBinding countriesView1Iterator = bindings.findIteratorBinding("CountriesView1Iterator");

    DCIteratorBinding locationsView2Iterator = bindings.findIteratorBinding("LocationsView2Iterator");
    DCIteratorBinding departmentsView3Iterator = bindings.findIteratorBinding("DepartmentsView3Iterator");
    Row[] locations =  locationsView2Iterator.getAllRowsInRange();
    ArrayList<Row> employees = new ArrayList<Row>();
    for(int i = 0; i < locations.length; i++){
        locationsView2Iterator.setCurrentRowIndexInRange(i);
        departments.addAll(Arrays.asList(departmentsView3Iterator.getAllRowsInRange()));
    }

    return departments;
}

public void setPopulate(Row[] rows){

}
}

the getPopulate Method is called and returns the rows that I want, but returing rows seems to be the wrong way to go? 调用getPopulate方法并返回我想要的行,但是重新显示行似乎是错误的方法?

Using managed bean for this case is a wrong way itself. 在这种情况下使用托管bean本身是错误的方式。
All you need is to create viewObject that will match your expectation. 您需要做的就是创建符合您期望的viewObject。
Create a viewObject joining Location + Department tables. 创建一个连接Location + Department表的viewObject。 Make it child to Country viewObject through viewLink. 通过viewLink使其成为Country viewObject的子级。
Now you can drag&drop master-detail tables on the page. 现在,您可以在页面上拖放主从表。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM