我正在尝试使用 Seam 的一个孩子ExtendedDataModelClass
作为rich:dataTable
组件的数据源:
<rich:dataTable id="docPackList" var="pack" width="100%" rows="25"
value="#{specDocPackageList.dataModel}">
...
</rich:table>
在这个孩子的walk
方法中,我调用了getResultList
从 Seam 派生的控制器方法EntityQUery
。这个控制器有一些用 Seam 注入的字段:
@Name("specDocPackageList")
@Scope(ScopeType.CONVERSATION)
public class SpecDocPackageList extends EntityQuery<DocPackage> {
@In(create = true, value = "orgunitList")
private OrgUnitList orgUnitListController;
public OrgUnitList getOrgUnitListController() {
return orgUnitListController;
}
public void setOrgUnitListController(OrgUnitList orgUnitListController) {
this.orgUnitListController = orgUnitListController;
}
private SelectableQueryDataModel entityQueryDataModel;
@Override
public DataModel getDataModel() {
if (entityQueryDataModel == null) {
entityQueryDataModel = SelectableQueryDataModel.getInstance(this);
}
return entityQueryDataModel;
}
...
}
public class SelectableQueryDataModel<T, K> extends ExtendedDataModel {
private EntityQuery<T> dataProvider;
public SelectableQueryDataModel(EntityQuery<T> query) {
dataProvider = query;
...
}
public static SelectableQueryDataModel getInstance(EntityQuery query) {
return new SelectableQueryDataModel(query);
}
public void walk(FacesContext facesContext, DataVisitor dataVisitor, Range range, Object o) throws IOException {
...
for (T item : this.dataProvider.getResultList()) {
...
}
...
}
}
问题是我null
在specDocPackageList.orgUnitListController
何时从方法specDocPackageList.getResultList()
调用。SelectableQueryDataModel.walk
那时不会抛出任何异常。getResultList()
但是,当被调用以获取以下数据时,该字段以正确的方式注入rich:dataTable
:
<rich:dataTable id="docPackList" var="pack" width="100%" rows="25"
value="#{specDocPackageList.resultList}">
...
</rich:table>
为什么Seam不在第一种情况下注入这个字段而在第二种情况下这样做呢?