public ActionForward execute( ActionMapping mapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) throws javax.servlet.ServletException, java.io.IOException { formErrors = new ArrayList(); MiscCashReceiptsForm form = (MiscCashReceiptsForm) actionForm; ActionErrors errors = new ActionErrors(); HttpSession session = request.getSession(); DbUserSession sessionUser = SessionHelpers.getUserSession(request); DatabaseTransaction t = null; DbHistory dbHistory = null; if (form.getSubmitButton() != null && form.getSubmitButton().equals("exit")) { ActionForward actionForward = mapping.findForward("financial"); return actionForward; } try { t = (DatabaseTransaction) DatabaseTransaction.getTransaction(sessionUser); // AppLog.trace("ProcessMiscCashReceipts submit ="+form.getSubmitButton()); // --- HANDLE PRINTING A RECEIPT --- if (form.getFormId() != null && form.getFormId().trim().length() > 0 && (!form.getFormId().equals("None"))) { // AppLog.trace("ProcessMiscCashReceipts printing receipt form: "+form.getFormId()); if (FormatNumber.parseInteger(form.getFormId()) < 1) { // AppLog.error("ProcessMiscCashReceipts - No receipt type selected."); errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("error.tables.noselect")); formErrors.add("formId"); t.closeConnection(); return (new ActionForward(mapping.getInput())); } } if (form.getSubmitButton().equals("save")) { dbHistory = new DbHistory(); dbHistory.setNew(); validateData(form, errors); if (errors.isEmpty()) { setHistory(t, sessionUser, dbHistory, form, errors); if (errors.isEmpty()) { t.save(); } else { // AppLog.criticalError("Exception in ProcessMiscCashReceipts.setHistory."); } } else { // AppLog.trace("Validation Errors in ProcessMiscCashReceipts; returning to // MiscCashReceipts form."); } } // --- HANDLE PRINTING A RECEIPT --- if (errors.isEmpty() && FormatNumber.parseInteger(form.getFormId()) > 0) { String crystalFlag = UtilSingleton.getInstance() .getProperty(sessionUser.getConfigID(), "CrystalServer.useReportingService"); String pageName = null; if (crystalFlag != null && "true".equals(crystalFlag)) { CrystalReportManagerBean crystalServerReport = new CrystalReportManagerBean(sessionUser.getConfigID()); pageName = crystalServerReport.printReport( sessionUser, FormatNumber.parseInteger(form.getFormId()), "", "", null, "", Integer.toString(dbHistory.getId()), true); } else { ExportReport crystal = new ExportReport(); crystal.setRecordIdSelParam(dbHistory.getId()); // selection parameter pageName = crystal.printForm( sessionUser, FormatNumber.parseInteger(form.getFormId()), "", "", null, "", request, response, servlet.getServletContext()); } form = new MiscCashReceiptsForm(); setNewForm(request, sessionUser, session, form, errors); form.setPreviewFile(pageName); // AppLog.trace("Setting miscCashReceipts collection arrays into session scope."); session.setAttribute("miscCashReceipts", form); ActionForward actionForward = mapping.findForward("showMiscCashReceipts"); return actionForward; } } catch (PersistenceException pe) { logger.error("Persistence Exception in ProcessMiscCashReceipts.doPerform. " + pe); errors.add( ActionErrors.GLOBAL_ERROR, new ActionError("error.PersistenceException", pe.getCause())); } catch (Exception pe) { logger.error("Exception in ProcessMiscCashReceipts.doPerform. ", pe); errors.add( ActionErrors.GLOBAL_ERROR, new ActionError("error.GeneralException", pe.getMessage())); } finally { if (t != null) { t.closeConnection(); } } // Action Forward Logic ActionForward actionForward = mapping.findForward("showMiscCashReceiptsGlobal"); if (!errors.isEmpty()) { // AppLog.info("ProcessMiscCashReceipts Invoking forward mapping getInput() "); saveErrors(request, errors); request.setAttribute("formErrors", formErrors); actionForward = new ActionForward(mapping.getInput()); } logger.debug("Leaving ProcessMiscCashReceipts."); return actionForward; }