Prepopulating selectmanycheckbox from database,
September 16, 2009 at 6:21 PM
Say I have 4 roles and this player has 2 of those roles when I present his data. How to I check the checkboxes of the two roles he alreay has when I'm loading from a database using a list. Here's an example:
public ArrayList<SelectItem> getRolesList() { ArrayList<SelectItem> al = new ArrayList<SelectItem>(); Role role = null; List<Role> lst = rolePersistenceLayer.findAll(); Iterator<Role> it = lst.iterator(); int iCount = 0; while(it.hasNext()) { role = it.next(); al.add(new SelectItem(role.getRoleId(), role.getRoleName())); } return al; }