VigilantGroupBean bean = (VigilantGroupBean) RenderUtils.getViewState() .getMetaObject().getObject(); VigilantGroup vigilantGroup = bean.getSelectedVigilantGroup(); List<Employee> employees = bean.getEmployees(); List<Person> people = new ArrayList<Person>(); for (Employee employee : employees) { people.add(employee.getPerson());
Map<VigilantGroup,List<Person>> peopleToAdd = new HashMap<VigilantGroup,List<Person>>(); Map<VigilantGroup,List<Vigilant>> vigilantsToRemove  = new HashMap<VigilantGroup,List<Vigilant>>();  List<VigilantBoundBean> beans = (List<VigilantBoundBean>) RenderUtils.getViewState("bounds").getMetaObject().getObject(); List<VigilantBoundBean> externalBeans = (List<VigilantBoundBean>) RenderUtils.getViewState("externalBounds").getMetaObject().getObject();   beans.addAll(externalBeans);  for(VigilantBoundBean bean : beans) { Vigilant vigilant = bean.getPerson().getCurrentVigilant(); if(bean.isBounded()) { if(vigilant==null || !vigilant.hasVigilantGroup(bean.getVigilantGroup())) { VigilantGroup group = bean.getVigilantGroup(); if(peopleToAdd.containsKey(group)) { peopleToAdd.get(group).add(bean.getPerson()); } else { List<Person> people = new ArrayList<Person>(); people.add(bean.getPerson()); peopleToAdd.put(bean.getVigilantGroup(), people); }  } } else { if(vigilant!=null && vigilant.hasVigilantGroup(bean.getVigilantGroup())) { VigilantGroup group = bean.getVigilantGroup(); if(vigilantsToRemove.containsKey(group)) { vigilantsToRemove.get(group).add(vigilant); } else { List<Vigilant> vigilants = new ArrayList<Vigilant>(); vigilants.add(vigilant); vigilantsToRemove.put(group,vigilants); }  } }
	public ActionForward addVigilantsToGroup(ActionMapping mapping,			ActionForm form, HttpServletRequest request,			HttpServletResponse response) throws Exception {		VigilantGroupBean bean = (VigilantGroupBean) RenderUtils.getViewState()				.getMetaObject().getObject();		VigilantGroup vigilantGroup = bean.getSelectedVigilantGroup();		List<Employee> employees = bean.getEmployees();		List<Person> people = new ArrayList<Person>();		for (Employee employee : employees) {			people.add(employee.getPerson());		}		Object[] args = { people, vigilantGroup };		executeService(request, "AddVigilantsToGroup", args);		prepareBeanForVigilantGroupEdition(request, vigilantGroup);		RenderUtils.invalidateViewState("addVigilants");		return mapping.findForward("vigilants");	}