Search in sources :

Example 11 with ActionErrors

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

the class MultipleLoanAccountsCreationActionForm method validate.

@Override
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
    logger.debug("Inside validate method");
    String method = request.getParameter(Methods.method.toString());
    ActionErrors errors = new ActionErrors();
    try {
        if (method.equals(Methods.get.toString())) {
            request.setAttribute(Constants.CURRENTFLOWKEY, request.getParameter(Constants.CURRENTFLOWKEY));
            checkValidationForLoad(errors, getUserContext(request), (Short) SessionUtils.getAttribute(CollectionSheetEntryConstants.ISCENTERHIERARCHYEXISTS, request));
        } else if (method.equals(Methods.create.toString())) {
            request.setAttribute(Constants.CURRENTFLOWKEY, request.getParameter(Constants.CURRENTFLOWKEY));
            validateLoanAmounts(errors, this.getUserContext(request).getPreferredLocale(), clientDetails);
            checkValidationForCreate(errors, request);
        } else if (method.equals(Methods.getLoanOfficers.toString())) {
            checkValidationForBranchOffice(errors, getUserContext(request));
        } else if (method.equals(Methods.getCenters.toString())) {
            checkValidationForBranchOffice(errors, getUserContext(request));
            checkValidationForLoanOfficer(errors);
        } else if (method.equals(Methods.getPrdOfferings.toString())) {
            request.setAttribute(Constants.CURRENTFLOWKEY, request.getParameter(Constants.CURRENTFLOWKEY));
            checkValidationForBranchOffice(errors, getUserContext(request));
            checkValidationForLoanOfficer(errors);
            checkValidationForCenter(errors, getUserContext(request), (Short) SessionUtils.getAttribute(CollectionSheetEntryConstants.ISCENTERHIERARCHYEXISTS, request));
        }
    } catch (PageExpiredException e) {
        errors.add(ExceptionConstants.PAGEEXPIREDEXCEPTION, new ActionMessage(ExceptionConstants.PAGEEXPIREDEXCEPTION));
    } catch (ServiceException e) {
        errors.add(ExceptionConstants.SERVICEEXCEPTION, new ActionMessage(ExceptionConstants.SERVICEEXCEPTION));
    }
    if (!errors.isEmpty()) {
        request.setAttribute("methodCalled", method);
    }
    logger.debug("outside validate method");
    return errors;
}
Also used : ServiceException(org.mifos.framework.exceptions.ServiceException) PageExpiredException(org.mifos.framework.exceptions.PageExpiredException) ActionMessage(org.apache.struts.action.ActionMessage) ActionErrors(org.apache.struts.action.ActionErrors)

Example 12 with ActionErrors

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

the class RepayLoanActionForm method validate.

@Override
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
    String method = request.getParameter("method");
    ActionErrors errors = new ActionErrors();
    if (!method.equals("loadRepayment") && !method.equals("loadGroupRepayment") && !method.equals("makeRepayment") && !method.equals("validate") && !method.equals("previous") && !method.equals("cancel")) {
        errors.add(super.validate(mapping, request));
        validateDateOfPayment(errors);
        validateTransfer(errors);
    }
    if (!errors.isEmpty()) {
        request.setAttribute(Globals.ERROR_KEY, errors);
        request.setAttribute("methodCalled", method);
    }
    return errors;
}
Also used : ActionErrors(org.apache.struts.action.ActionErrors)

Example 13 with ActionErrors

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

the class AccountApplyPaymentActionForm method validatePaymentDate.

//exposed for testing
public ActionErrors validatePaymentDate(String transactionDate, String fieldName) {
    ActionErrors errors = null;
    try {
        if (lastPaymentDate != null && dateFallsBeforeDate(getDateAsSentFromBrowser(transactionDate), lastPaymentDate)) {
            errors = new ActionErrors();
            errors.add(AccountConstants.ERROR_PAYMENT_DATE_BEFORE_LAST_PAYMENT, new ActionMessage(AccountConstants.ERROR_PAYMENT_DATE_BEFORE_LAST_PAYMENT, fieldName));
        }
    } catch (InvalidDateException ide) {
        //dont add a message, since it was already added in validateDate()
        errors = new ActionErrors();
    }
    return errors;
}
Also used : InvalidDateException(org.mifos.application.admin.servicefacade.InvalidDateException) ActionMessage(org.apache.struts.action.ActionMessage) ActionErrors(org.apache.struts.action.ActionErrors)

Example 14 with ActionErrors

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

the class AccountApplyPaymentActionForm method validate.

@Override
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
    String methodCalled = request.getParameter(MethodNameConstants.METHOD);
    ActionErrors errors = new ActionErrors();
    boolean groupLoanWithMembers = AccountingRules.isGroupLoanWithMembers();
    if (groupLoanWithMembers) {
        if (methodCalled != null && methodCalled.equals("preview")) {
            validateTransfer(errors);
            validateTransactionDate(errors);
            validatePaymentType(errors);
            validateReceiptDate(errors);
            String accountType = (String) request.getSession().getAttribute(Constants.ACCOUNT_TYPE);
            validateAccountType(errors, accountType);
            validateAmount(errors);
            validateModeOfPaymentSecurity(request, errors);
        }
        if (!errors.isEmpty()) {
            request.setAttribute(Globals.ERROR_KEY, errors);
            if (methodCalled.equals("divide")) {
                request.setAttribute("methodCalled", "preview");
            } else if (methodCalled.equals("preview") && !individualValues.isEmpty()) {
                request.setAttribute("methodCalled", "divide");
            } else if (methodCalled.equals("preview") && individualValues.isEmpty()) {
                request.setAttribute("methodCalled", "preview");
            } else {
                request.setAttribute("methodCalled", methodCalled);
            }
        }
    } else {
        if (methodCalled != null && methodCalled.equals("preview")) {
            validateTransfer(errors);
            validateTransactionDate(errors);
            validatePaymentType(errors);
            validateReceiptDate(errors);
            String accountType = (String) request.getSession().getAttribute(Constants.ACCOUNT_TYPE);
            validateAccountType(errors, accountType);
            validateAmount(errors);
            validateModeOfPaymentSecurity(request, errors);
        }
        if (!errors.isEmpty()) {
            request.setAttribute(Globals.ERROR_KEY, errors);
            request.setAttribute("methodCalled", methodCalled);
        }
    }
    return errors;
}
Also used : ActionErrors(org.apache.struts.action.ActionErrors)

Example 15 with ActionErrors

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

the class ApplyAdjustmentActionForm method validate.

@Override
public ActionErrors validate(ActionMapping actionMapping, HttpServletRequest request) {
    if (null == request.getAttribute(Constants.CURRENTFLOWKEY)) {
        request.setAttribute(Constants.CURRENTFLOWKEY, request.getParameter(Constants.CURRENTFLOWKEY));
    }
    ActionErrors actionErrors = new ActionErrors();
    String method = request.getParameter("method");
    if (null != method && method.equals("previewAdjustment")) {
        /*            if (!adjustcheckbox) {
                request.setAttribute("method", "loadAdjustment");
                actionErrors.add("", new ActionMessage("errors.mandatorycheckbox"));
            }*/
        if (!adjustcheckbox) {
            validateAmount(actionErrors);
            validatePaymentType(actionErrors);
            validateTransactionDate(actionErrors);
        }
        if (adjustmentNote == null || adjustmentNote.trim() == "") {
            request.setAttribute("method", "loadAdjustment");
            actionErrors.add("", new ActionMessage("errors.mandatorytextarea"));
        } else if (adjustmentNote.length() > 300) {
            request.setAttribute("method", "loadAdjustment");
            actionErrors.add("", new ActionMessage("errors.adjustmentNoteTooBig"));
        }
        if (!actionErrors.isEmpty()) {
            request.setAttribute("method", "loadAdjustment");
            return actionErrors;
        }
    }
    return actionErrors;
}
Also used : ActionMessage(org.apache.struts.action.ActionMessage) 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