package dk.hansen; import javax.servlet.http.*; import org.apache.log4j.Logger; import org.apache.struts.action.*; public final class DeleteDVDAction extends CommonDVDAction { private static Logger logger = Logger.getLogger(DeleteDVDAction.class.getName()); public ActionForward commonExecute( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { ActionErrors errors = new ActionErrors(); // Get the data from the Form bean DetailDVDForm df = (DetailDVDForm) form; String id = df.getId(); // Get the factory class HttpSession session = request.getSession(); DVDManagerFactoryIF factory = (DVDManagerFactoryIF) session.getAttribute("dvdfactory"); DVDManagerIF manager = factory.createDVDManager(); try { // Delete the current DVD manager.deleteDVD(id); } catch (DAOException e) { // Logging the error: String message = "DVD could not be deleted. " + "id=" + id; logger.fatal(message, e); // Message for the user: errors.add("label", new ActionError("error.deletefailed")); saveErrors(request, errors); // Save the chained exceptions: request.setAttribute("MYEXCEPTION", new DAOException(message, e)); // Return to the error page return (mapping.findForward("error")); } // Forward control to the next page return (mapping.findForward("OK")); } }