Search in sources :

Example 81 with ActionErrors

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

the class ApplyAdjustmentActionForm method validateDate.

protected ActionErrors validateDate(String date, String fieldName) {
    ActionErrors errors = null;
    java.sql.Date sqlDate = null;
    if (date != null && !date.equals("")) {
        try {
            sqlDate = getDateAsSentFromBrowser(date);
            if (DateUtils.whichDirection(sqlDate) > 0) {
                errors = new ActionErrors();
                errors.add(AccountConstants.ERROR_FUTUREDATE, new ActionMessage(AccountConstants.ERROR_FUTUREDATE, fieldName));
            } else if (previousPaymentDate != null && sqlDate.compareTo(previousPaymentDate) < 0) {
                errors = new ActionErrors();
                errors.add(AccountConstants.ERROR_ADJUSTMENT_PREVIOUS_DATE, new ActionMessage(AccountConstants.ERROR_ADJUSTMENT_PREVIOUS_DATE, fieldName));
            } else if (nextPaymentDate != null && sqlDate.compareTo(nextPaymentDate) > 0) {
                errors = new ActionErrors();
                errors.add(AccountConstants.ERROR_ADJUSTMENT_NEXT_DATE, new ActionMessage(AccountConstants.ERROR_ADJUSTMENT_NEXT_DATE, fieldName));
            }
        } catch (InvalidDateException ide) {
            errors = new ActionErrors();
            errors.add(AccountConstants.ERROR_INVALIDDATE, new ActionMessage(AccountConstants.ERROR_INVALIDDATE, fieldName));
        }
    } else {
        errors = new ActionErrors();
        errors.add(AccountConstants.ERROR_MANDATORY, new ActionMessage(AccountConstants.ERROR_MANDATORY, fieldName));
    }
    return errors;
}
Also used : InvalidDateException(org.mifos.application.admin.servicefacade.InvalidDateException) ActionMessage(org.apache.struts.action.ActionMessage) ActionErrors(org.apache.struts.action.ActionErrors)

Example 82 with ActionErrors

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

the class LoanPrdActionForm method validate.

@Override
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
    ActionErrors errors = new ActionErrors();
    Locale locale = getUserContext(request).getPreferredLocale();
    String method = request.getParameter(ProductDefinitionConstants.METHOD);
    logger.debug("validate method of Savings Product Action form method called :" + method);
    if (method != null && method.equals(Methods.preview.toString())) {
        errors.add(super.validate(mapping, request));
        validateForPreview(request, errors, locale);
    }
    if (method != null && method.equals(Methods.editPreview.toString())) {
        errors.add(super.validate(mapping, request));
        validateForEditPreview(request, errors, locale);
    }
    if (method != null && !method.equals(Methods.validate.toString())) {
        request.setAttribute(ProductDefinitionConstants.METHODCALLED, method);
    }
    logger.debug("validate method of Savings Product Action form called and error size:" + errors.size());
    return errors;
}
Also used : Locale(java.util.Locale) ActionErrors(org.apache.struts.action.ActionErrors)

Example 83 with ActionErrors

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

the class ReverseLoanDisbursalActionForm 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();
    if (method.equals(Methods.load.toString())) {
        checkValidationForLoad(errors, getUserContext(request));
    } else if (method.equals(Methods.preview.toString())) {
        checkValidationForPreview(errors, getUserContext(request).getPreferredLocale());
    }
    if (!errors.isEmpty()) {
        request.setAttribute("methodCalled", method);
    }
    logger.debug("outside validate method");
    return errors;
}
Also used : ActionErrors(org.apache.struts.action.ActionErrors)

Example 84 with ActionErrors

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

the class LoanAccountAction method getActionErrors.

private ActionErrors getActionErrors(Errors errors) {
    ActionErrors actionErrors = new ActionErrors();
    if (errors.hasErrors()) {
        for (ErrorEntry errorEntry : errors.getErrorEntries()) {
            ActionMessage actionMessage;
            if (errorEntry.hasErrorArgs()) {
                actionMessage = new ActionMessage(errorEntry.getErrorCode(), errorEntry.getArgs().toArray());
            } else {
                actionMessage = new ActionMessage(errorEntry.getErrorCode(), errorEntry.getFieldName());
            }
            actionErrors.add(errorEntry.getErrorCode(), actionMessage);
        }
    }
    return actionErrors;
}
Also used : ActionMessage(org.apache.struts.action.ActionMessage) ErrorEntry(org.mifos.platform.validations.ErrorEntry) ActionErrors(org.apache.struts.action.ActionErrors)

Example 85 with ActionErrors

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

the class SavingsAction 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, (SavingsActionForm) 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)

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