I'm creating a List of javax.faces.model.SelectItem
(in a bean) for use with a h:selectManyCheckbox
but I cannot figure out how to make a SelectItem
selected.
Does anyone know how to do this? Must be possible, right?...
public List<SelectItem> getPlayerList(String teamName) {
List<SelectItem> list = new ArrayList<SelectItem>();
TeamPage team = (TeamPage) pm.findByName(teamName);
List<PlayerPage> players = pm.findAllPlayerPages();
for (PlayerPage player : players) {
boolean isMember = false;
if (team.getPlayerPages().contains(player)) {
isMember = true;
}
SelectItem item;
if (isMember) {
// TODO: Make SelectItem selected???
item = null;
} else {
item = new SelectItem(player.getId(), createListItemLabel(player), "", false, false);
}
list.add(item);
}
return list;
}