Search in sources :

Example 16 with ActionErrors

use of org.apache.struts.action.ActionErrors in project head by mifos.

the class BaseAction method shutdown.

private ActionForward shutdown(ActionMapping mapping, HttpServletRequest request) {
    request.getSession(false).invalidate();
    ActionErrors error = new ActionErrors();
    error.add(LoginConstants.SHUTDOWN, new ActionMessage(messages.getMessage(LoginConstants.SHUTDOWN, "You have been logged out of the system because Mifos is shutting down.")));
    request.setAttribute(Globals.ERROR_KEY, error);
    return mapping.findForward(ActionForwards.load_main_page.toString());
}
Also used : ActionMessage(org.apache.struts.action.ActionMessage) ActionErrors(org.apache.struts.action.ActionErrors)

Example 17 with ActionErrors

use of org.apache.struts.action.ActionErrors in project head by mifos.

the class LoanDisbursementAction method captureQuestionResponses.

@TransactionDemarcate(joinToken = true)
public ActionForward captureQuestionResponses(final ActionMapping mapping, final ActionForm form, final HttpServletRequest request, @SuppressWarnings("unused") final HttpServletResponse response) throws Exception {
    request.setAttribute(METHODCALLED, "captureQuestionResponses");
    ActionErrors errors = createGroupQuestionnaire.validateResponses(request, (LoanDisbursementActionForm) form);
    if (errors != null && !errors.isEmpty()) {
        addErrors(request, errors);
        return mapping.findForward(ActionForwards.captureQuestionResponses.toString());
    }
    return createGroupQuestionnaire.rejoinFlow(mapping);
}
Also used : ActionErrors(org.apache.struts.action.ActionErrors) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 18 with ActionErrors

use of org.apache.struts.action.ActionErrors in project head by mifos.

the class AccountStatusActionForm method validate.

@Override
public // TODO: use localized strings for error messages rather than hardcoded
ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
    ActionErrors errors = new ActionErrors();
    String method = request.getParameter("method");
    if (method.equals(Methods.searchResults.toString())) {
        String branch = this.getLocalizedMessage("loan.branch");
        String loanOfficer = this.getLocalizedMessage("loan.loanOfficer");
        String currentStatus = this.getLocalizedMessage("loan.currentStatus");
        if (StringUtils.isBlank(getOfficeId())) {
            addError(errors, "officeId", "errors.mandatoryselect", branch);
        }
        if (StringUtils.isBlank(getPersonnelId())) {
            addError(errors, "loanOfficer", "errors.mandatoryselect", loanOfficer);
        }
        if (StringUtils.isBlank(getCurrentStatus())) {
            addError(errors, "currentStatus", "errors.mandatoryselect", currentStatus);
        }
    }
    if (method.equals(Methods.update.toString())) {
        String account = this.getLocalizedMessage("loan.account");
        String notes = this.getLocalizedMessage("loan.notes");
        String note = this.getLocalizedMessage("loan.note");
        if (getApplicableAccountRecords().size() == 0) {
            addError(errors, "records", LoanExceptionConstants.SELECT_ATLEAST_ONE_RECORD, account);
        }
        if (StringUtils.isBlank(getComments())) {
            addError(errors, "comments", "errors.mandatory", notes);
        } else if (getComments().length() > 500) {
            addError(errors, "comments", "errors.maximumlength", note, "500");
        }
    }
    if (!method.equals(Methods.validate.toString())) {
        request.setAttribute("methodCalled", method);
    }
    return errors;
}
Also used : ActionErrors(org.apache.struts.action.ActionErrors)

Example 19 with ActionErrors

use of org.apache.struts.action.ActionErrors in project head by mifos.

the class LoanAccountActionForm method validate.

@Override
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
    String method = request.getParameter(Methods.method.toString());
    ActionErrors errors = new ActionErrors();
    if (null == request.getAttribute(Constants.CURRENTFLOWKEY)) {
        request.setAttribute(Constants.CURRENTFLOWKEY, request.getParameter(Constants.CURRENTFLOWKEY));
    }
    try {
        if (method.equals(Methods.getPrdOfferings.toString())) {
            checkValidationForGetPrdOfferings(errors);
        } else if (method.equals(Methods.load.toString())) {
            checkValidationForLoad(errors);
        } else if (method.equals(Methods.schedulePreview.toString())) {
            checkValidationForSchedulePreview(errors, getCurrencyFromLoanOffering(request), request);
        } else if (method.equals(Methods.managePreview.toString())) {
            checkValidationForManagePreview(errors, getCurrencyFromLoanOffering(request), request);
        } else if (method.equals(Methods.preview.toString())) {
            checkValidationForPreview(errors, getCurrencyFromLoanOffering(request), request);
        }
    } catch (ApplicationException ae) {
        // Discard other errors (is that right?)
        ae.printStackTrace();
        errors = new ActionErrors();
        errors.add(ae.getKey(), new ActionMessage(ae.getKey(), ae.getValues()));
    }
    if (!errors.isEmpty()) {
        request.setAttribute(LoanConstants.METHODCALLED, method);
    }
    return errors;
}
Also used : ApplicationException(org.mifos.framework.exceptions.ApplicationException) ActionMessage(org.apache.struts.action.ActionMessage) ActionErrors(org.apache.struts.action.ActionErrors)

Example 20 with ActionErrors

use of org.apache.struts.action.ActionErrors in project head by mifos.

the class FeeActionForm method validate.

@Override
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
    Locale locale = getUserContext(request).getPreferredLocale();
    ActionErrors errors = new ActionErrors();
    String methodCalled = request.getParameter(Methods.method.toString());
    if (!methodCalled.equals(Methods.validate.toString())) {
        request.setAttribute("methodCalled", methodCalled);
    } else {
        request.setAttribute("methodCalled", request.getAttribute("methodCalled"));
    }
    if (methodCalled.equals(Methods.preview.toString())) {
        // fee creation
        errors.add(super.validate(mapping, request));
        validateForPreview(errors, locale);
    } else if (methodCalled.equalsIgnoreCase(Methods.editPreview.toString())) {
        // editing fees
        validateForEditPreview(errors, locale);
    } else if (methodCalled.equalsIgnoreCase(Methods.update.toString())) {
        validateForUpdaste(errors, locale);
    }
    if (!errors.isEmpty()) {
        request.setAttribute(Globals.ERROR_KEY, errors);
    }
    return errors;
}
Also used : Locale(java.util.Locale) ActionErrors(org.apache.struts.action.ActionErrors)

Aggregations

ActionErrors (org.apache.struts.action.ActionErrors)144 ActionMessage (org.apache.struts.action.ActionMessage)68 InvalidDateException (org.mifos.application.admin.servicefacade.InvalidDateException)20 Locale (java.util.Locale)19 ResourceBundle (java.util.ResourceBundle)13 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)12 Test (org.junit.Test)9 DoubleConversionResult (org.mifos.framework.util.helpers.DoubleConversionResult)7 Date (java.sql.Date)5 ApplicationException (org.mifos.framework.exceptions.ApplicationException)5 PageExpiredException (org.mifos.framework.exceptions.PageExpiredException)4 ReportsPersistence (org.mifos.reports.persistence.ReportsPersistence)4 DateTime (org.joda.time.DateTime)3 PaymentDataHtmlBean (org.mifos.accounts.loan.struts.uihelpers.PaymentDataHtmlBean)3 ReportsCategoryBO (org.mifos.reports.business.ReportsCategoryBO)3 Problem (cn.edu.zju.acm.onlinejudge.bean.Problem)2 ArrayList (java.util.ArrayList)2 ServletContext (javax.servlet.ServletContext)2 HttpServletRequest (javax.servlet.http.HttpServletRequest)2 HttpSession (javax.servlet.http.HttpSession)2