如何在使用 adf 业务组件时从托管 bean 填充 jsf table?
How to populate a jsf table from a managed bean while using adf business components?
我是 ADF 的新手,我似乎遗漏了什么。我正在使用 Oracle 人力资源数据库。我使用业务组件作为模型。我有针对国家、位置和部门的 ViewObjects。以及 FK 在 Country-Location 和 Location-Department 之间的 ViewLinks。我暴露了一个 DataControl Country-> Location -> Deperatments.
所以现在我可以构建一个包含三个区域的 JSF,每个区域都显示在其中。如果我点击一个国家,我会得到位置。如果我然后单击位置,我会得到部门。行得通。
但我只想显示国家和部门。因此,我实现了一个托管 bean 以利用迭代器并通过该 bean 将部门 table 绑定到 table 的值属性来填充部门 table。但是我只有 return 的 Row 对象,并且由于使用 BC 没有 Class 定义,我可以将我的行映射回对象。
那么我怎样才能只显示一个国家/地区的所有部门?执行此操作的 ADF 方法是什么?
我的托管 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){
}
}
调用了 getPopulate 方法并且 return 得到了我想要的行,但是返回行似乎是错误的方法?
在这种情况下使用托管 bean 本身就是一种错误的方式。
您只需要创建符合您期望的 viewObject。
创建一个连接 Location + Department 表的 viewObject。通过 viewLink 使其成为 Country viewObject 的子对象。
现在您可以在页面上拖放主从表。
我是 ADF 的新手,我似乎遗漏了什么。我正在使用 Oracle 人力资源数据库。我使用业务组件作为模型。我有针对国家、位置和部门的 ViewObjects。以及 FK 在 Country-Location 和 Location-Department 之间的 ViewLinks。我暴露了一个 DataControl Country-> Location -> Deperatments.
所以现在我可以构建一个包含三个区域的 JSF,每个区域都显示在其中。如果我点击一个国家,我会得到位置。如果我然后单击位置,我会得到部门。行得通。
但我只想显示国家和部门。因此,我实现了一个托管 bean 以利用迭代器并通过该 bean 将部门 table 绑定到 table 的值属性来填充部门 table。但是我只有 return 的 Row 对象,并且由于使用 BC 没有 Class 定义,我可以将我的行映射回对象。
那么我怎样才能只显示一个国家/地区的所有部门?执行此操作的 ADF 方法是什么?
我的托管 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){
}
}
调用了 getPopulate 方法并且 return 得到了我想要的行,但是返回行似乎是错误的方法?
在这种情况下使用托管 bean 本身就是一种错误的方式。
您只需要创建符合您期望的 viewObject。
创建一个连接 Location + Department 表的 viewObject。通过 viewLink 使其成为 Country viewObject 的子对象。
现在您可以在页面上拖放主从表。