public String execute() throws Exception { if (deleteSelectedButtonPressed) { // selectedItems contains the indices of the items that were // checked. // delete all records in the selectedItems list. List<Status> theList = (List) request.getSession(true).getAttribute("StatusList"); try { statusService.deleteItems(selectedItems, theList); } catch (Exception err) { addActionError(err.getCause().getMessage()); return "refresh"; } // Now spin through the saved list, find the Statuses we deleted, // and just remove them from the list. List<Status> copiedList = new ArrayList(); copiedList.addAll(theList); for (Integer each : selectedItems) { Status aStatus = copiedList.get(each); theList.remove(aStatus); } request.getSession(true).setAttribute("StatusList", theList); tableCount = theList.size(); return "refresh"; } if (queryButtonPressed) { listToDisplay = this.getStatuses(); return "refresh"; } if (addNewButtonPressed) { // Create an empty Status object, stuff it into the session, and // invoke the Editor on it Status status = new Status(); request.getSession(true).setAttribute("Status", status); return "editSingle"; } if (returnButtonPressed) { // If return was hit, remove the list of items from the session. // Save some memory this way. request.getSession(true).removeAttribute("StatusList"); return "returnToMainApp"; } return "refresh"; }