package dk.hansen; import javax.servlet.http.*; import org.apache.log4j.Logger; import org.apache.struts.action.*; public final class DeleteVhsAction extends CommonVhsAction { private static Logger logger = Logger.getLogger(DeleteVhsAction.class.getName()); public ActionForward commonExecute( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { ActionErrors errors = new ActionErrors(); // Get the data from the Form bean DetailVhsForm df = (DetailVhsForm) form; String id = df.getId(); // Get the factory class HttpSession session = request.getSession(); VhsManagerFactoryIF factory = (VhsManagerFactoryIF) session.getAttribute("vhsfactory"); VhsManagerIF manager = factory.createVhsManager(); try { // Delete the current Vhs manager.deleteVhs(id); } catch (DAOException e) { // Logging the error: String message = "Vhs 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")); } }