Ejemplo n.º 1
0
 public String remove() {
   try {
     listToDisplay = (List) request.getSession(true).getAttribute("StatusList");
     Status theStatus = listToDisplay.get(index);
     statusService.delete(theStatus);
     listToDisplay.remove(theStatus);
     request.getSession(true).setAttribute("StatusList", listToDisplay);
     tableCount = listToDisplay.size();
   } catch (Exception err) {
     addActionError(err.getCause().getMessage());
   }
   return SUCCESS;
 }
Ejemplo n.º 2
0
 /* **********************************************************************************************
  * *    Database Access
  * **********************************************************************************************/
 public List
     getStatuses() { // Notify the service to issue the query; catch any errors here, and display
                     // them in the errorField
   try {
     List<Status> theList = statusService.getStatusesWithCriteria(selectStatement);
     request.getSession(true).setAttribute("StatusList", theList);
     tableCount = theList.size();
     return theList;
   } catch (Exception err) {
     addActionError(err.getCause().getMessage());
   }
   return null;
 }
Ejemplo n.º 3
0
 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";
 }