我似乎为我的SelectItemGroup
设置了值,但是无法选择分组选项,并且在我的selectedValue
中没有设置值
<p:selectOneMenu value="#{controller.selectedValue}">
<f:selectItem itemLabel="#{bundle.defautlItem}"/>
<f:selectItems value="#{controller.findAll()}" var="gs" itemLabel="#{gs.name}" itemValue="#{gs}"/>
</p:selectOneMenu>
public List<SelectItem> findAll() {
List<Company> companies = companyFacade.findAllWithSelfTrue();
Map<Company, List<Branch>> companiesMap = new HashMap<>();
for(Company c : companies) {
List<Branch> branches = branchFacade.findWithCompany(c);
companiesMap.put(c, branches);
}
List<SelectItem> resultList = new ArrayList<>();
companiesMap.forEach((key,value) -> {
SelectItemGroup sig = new SelectItemGroup();
SelectItem[] selectItems = new SelectItem[value.size()];
for(int i = 0; i < value.size(); i++) {
selectItems[i] = new SelectItem(value.get(i), value.get(i).getActorName());
}
sig.setSelectItems(selectItems);
sig.setValue(key); \\set value for grouping options?
sig.setLabel(key.getName());
resultList.add(sig);
});
return resultList;
}