Search in sources :

Example 21 with ActionMessage

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

the class LoanAccountActionForm method validateMaxPayableAmount.

private void validateMaxPayableAmount(HttpServletRequest request, ActionErrors errors) throws InvalidDateException {
    Money totalAmount = Money.zero(getCurrencyFromLoanOffering(request));
    Money paymentAmount = Money.zero(getCurrencyFromLoanOffering(request));
    for (PaymentDataHtmlBean paymentDataHtmlBean : getPaymentDataBeans()) {
        totalAmount = totalAmount.add(paymentDataHtmlBean.totalAsMoney());
        paymentAmount = paymentAmount.add(paymentDataHtmlBean.paymentAmountAsMoney());
    }
    if (paymentAmount.isGreaterThan(totalAmount)) {
        errors.add(LoanExceptionConstants.EXCESS_PAYMENT, new ActionMessage(LoanExceptionConstants.EXCESS_PAYMENT));
    }
}
Also used : Money(org.mifos.framework.util.helpers.Money) PaymentDataHtmlBean(org.mifos.accounts.loan.struts.uihelpers.PaymentDataHtmlBean) ActionMessage(org.apache.struts.action.ActionMessage)

Example 22 with ActionMessage

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

the class LoanDisbursementActionForm method validate.

@Override
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
    ActionErrors errors = new ActionErrors();
    ActionErrors errors1 = super.validate(mapping, request);
    if (errors1 != null) {
        errors.add(errors1);
    }
    String method = request.getParameter(MethodNameConstants.METHOD);
    if (isPreviewMethod(method) && getPaymentAmountGreaterThanZero() && StringUtils.isBlank(paymentModeOfPayment)) {
        String errorMessage = this.getLocalizedMessage("loan.paymentid");
        errors.add(AccountConstants.ERROR_MANDATORY, new ActionMessage(AccountConstants.ERROR_MANDATORY, errorMessage));
    }
    if (isPreviewMethod(method) && getPaymentAmountGreaterThanZero() && !StringUtils.isBlank(paymentModeOfPayment) && Short.valueOf(paymentModeOfPayment).equals(transferPaymentTypeId) && StringUtils.isBlank(accountForTransfer)) {
        String errorMessage = this.getLocalizedMessage("loan.accountForTransfer");
        errors.add(AccountConstants.ERROR_MANDATORY, new ActionMessage(AccountConstants.ERROR_MANDATORY, errorMessage));
    }
    if (!errors.isEmpty()) {
        request.setAttribute(Globals.ERROR_KEY, errors);
        request.setAttribute("methodCalled", method);
    }
    return errors;
}
Also used : ActionMessage(org.apache.struts.action.ActionMessage) ActionErrors(org.apache.struts.action.ActionErrors)

Example 23 with ActionMessage

use of org.apache.struts.action.ActionMessage 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 24 with ActionMessage

use of org.apache.struts.action.ActionMessage 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 25 with ActionMessage

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

the class AccountApplyPaymentActionForm method validateModeOfPaymentSecurity.

private void validateModeOfPaymentSecurity(HttpServletRequest request, ActionErrors errors) {
    UserContext userContext = (UserContext) SessionUtils.getAttribute(Constants.USER_CONTEXT_KEY, request.getSession());
    AccountBO account = null;
    Short personnelId = userContext.getId();
    try {
        if (accountId != null) {
            account = new AccountBusinessService().getAccount(Integer.valueOf(accountId));
            if (account.getPersonnel() != null) {
                personnelId = account.getPersonnel().getPersonnelId();
            }
        }
    } catch (NumberFormatException e) {
        throw new MifosRuntimeException(e);
    } catch (ServiceException e) {
        throw new MifosRuntimeException(e);
    }
    if (getPaymentTypeId().equals("4") && !ActivityMapper.getInstance().isModeOfPaymentSecurity(userContext, personnelId)) {
        errors.add(AccountConstants.LOAN_TRANSFER_PERMISSION, new ActionMessage(AccountConstants.LOAN_TRANSFER_PERMISSION, getLocalizedMessage("accounts.mode_of_payment_permission")));
    }
}
Also used : AccountBO(org.mifos.accounts.business.AccountBO) AccountBusinessService(org.mifos.accounts.business.service.AccountBusinessService) ServiceException(org.mifos.framework.exceptions.ServiceException) UserContext(org.mifos.security.util.UserContext) ActionMessage(org.apache.struts.action.ActionMessage) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Aggregations

ActionMessage (org.apache.struts.action.ActionMessage)166 ActionErrors (org.apache.struts.action.ActionErrors)70 ActionMessages (org.apache.struts.action.ActionMessages)45 ResourceBundle (java.util.ResourceBundle)29 JspException (javax.servlet.jsp.JspException)22 InvalidDateException (org.mifos.application.admin.servicefacade.InvalidDateException)22 Iterator (java.util.Iterator)21 Locale (java.util.Locale)19 List (java.util.List)9 ActionForward (org.apache.struts.action.ActionForward)9 AbstractContest (cn.edu.zju.acm.onlinejudge.bean.AbstractContest)8 ArrayList (java.util.ArrayList)8 Problem (cn.edu.zju.acm.onlinejudge.bean.Problem)7 DoubleConversionResult (org.mifos.framework.util.helpers.DoubleConversionResult)7 UserProfile (cn.edu.zju.acm.onlinejudge.bean.UserProfile)6 IOException (java.io.IOException)6 Date (java.sql.Date)6 PageExpiredException (org.mifos.framework.exceptions.PageExpiredException)6 ApplicationException (org.mifos.framework.exceptions.ApplicationException)5 UserPersistence (cn.edu.zju.acm.onlinejudge.persistence.UserPersistence)4