Search in sources :

Example 11 with ReportsCategoryActionForm

use of org.mifos.reports.struts.actionforms.ReportsCategoryActionForm in project head by mifos.

the class ReportsCategoryAction method preview.

public ActionForward preview(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    logger.debug("In ReportsCategoryAction:preview Method: ");
    ReportsCategoryActionForm defineCategoryForm = (ReportsCategoryActionForm) form;
    String categoryName = defineCategoryForm.getCategoryName();
    request.setAttribute("categoryName", categoryName);
    for (ReportsCategoryBO category : new ReportsPersistence().getAllReportCategories()) {
        if (categoryName.equals(category.getReportCategoryName())) {
            ActionErrors errors = new ActionErrors();
            errors.add(ReportsConstants.ERROR_CATEGORYNAMEALREADYEXIST, new ActionMessage(ReportsConstants.ERROR_CATEGORYNAMEALREADYEXIST));
            request.setAttribute(Globals.ERROR_KEY, errors);
            return mapping.findForward(ActionForwards.preview_failure.toString());
        }
    }
    return mapping.findForward(ActionForwards.preview_success.toString());
}
Also used : ReportsPersistence(org.mifos.reports.persistence.ReportsPersistence) ReportsCategoryActionForm(org.mifos.reports.struts.actionforms.ReportsCategoryActionForm) ReportsCategoryBO(org.mifos.reports.business.ReportsCategoryBO) ActionMessage(org.apache.struts.action.ActionMessage) ActionErrors(org.apache.struts.action.ActionErrors)

Example 12 with ReportsCategoryActionForm

use of org.mifos.reports.struts.actionforms.ReportsCategoryActionForm in project head by mifos.

the class ReportsCategoryAction method edit.

public ActionForward edit(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    logger.debug("In ReportsCategoryAction:edit Method: ");
    ReportsCategoryActionForm reportsCategoryActionForm = (ReportsCategoryActionForm) form;
    String reportCategoryId = request.getParameter("categoryId");
    ReportsCategoryBO reportCategory = new ReportsPersistence().getReportCategoryByCategoryId(Short.valueOf(reportCategoryId));
    reportsCategoryActionForm.setCategoryName(reportCategory.getReportCategoryName());
    return mapping.findForward(ActionForwards.edit_success.toString());
}
Also used : ReportsPersistence(org.mifos.reports.persistence.ReportsPersistence) ReportsCategoryActionForm(org.mifos.reports.struts.actionforms.ReportsCategoryActionForm) ReportsCategoryBO(org.mifos.reports.business.ReportsCategoryBO)

Aggregations

ReportsCategoryActionForm (org.mifos.reports.struts.actionforms.ReportsCategoryActionForm)12 ReportsCategoryBO (org.mifos.reports.business.ReportsCategoryBO)7 ReportsPersistence (org.mifos.reports.persistence.ReportsPersistence)7 Test (org.junit.Test)5 ActionErrors (org.apache.struts.action.ActionErrors)2 ActionMessage (org.apache.struts.action.ActionMessage)2 ActivityGeneratorException (org.mifos.security.activity.ActivityGeneratorException)1