Search in sources :

Example 76 with ActionMessage

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

the class MeetingActionForm method validateMeeting.

private ActionErrors validateMeeting() {
    ActionErrors errors = new ActionErrors();
    if (getRecurrenceType() == null) {
        errors.add(MeetingConstants.INVALID_RECURRENCETYPE, new ActionMessage(MeetingConstants.INVALID_RECURRENCETYPE));
    } else if (getRecurrenceType().equals(RecurrenceType.WEEKLY)) {
        validateWeeklyMeeting(errors);
    } else if (getRecurrenceType().equals(RecurrenceType.MONTHLY)) {
        validateMonthlyMeeting(errors);
    } else if (getRecurrenceType().equals(RecurrenceType.DAILY)) {
        validateDailyMeeting(errors);
    }
    if (StringUtils.isBlank(getMeetingPlace())) {
        errors.add(MeetingConstants.INVALID_MEETINGPLACE, new ActionMessage(MeetingConstants.INVALID_MEETINGPLACE));
    }
    validateMeetingStartDate(errors);
    return errors;
}
Also used : ActionMessage(org.apache.struts.action.ActionMessage) ActionErrors(org.apache.struts.action.ActionErrors)

Example 77 with ActionMessage

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

the class EditStatusActionForm 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));
            }
        } 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) Date(java.sql.Date)

Example 78 with ActionMessage

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

the class AccountApplyPaymentActionForm 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));
            }
        } 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) Date(java.sql.Date)

Example 79 with ActionMessage

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

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

the class ApplyChargeActionForm method validateRate.

protected void validateRate(ActionErrors errors, HttpServletRequest request) {
    Double chargeAmountDoubleValue;
    try {
        chargeAmountDoubleValue = getDoubleValue(chargeAmount);
    } catch (NumberFormatException e) {
        return;
    }
    if (chargeAmountDoubleValue != null) {
        //FIXME Do not use hard coded values for properties local.properties
        if (chargeAmountDoubleValue > Double.valueOf("999")) {
            errors.add(AccountConstants.RATE, new ActionMessage(AccountConstants.RATE_ERROR));
            request.setAttribute("selectedChargeFormula", selectedChargeFormula);
        }
    }
}
Also used : ActionMessage(org.apache.struts.action.ActionMessage)

Aggregations

ActionMessage (org.apache.struts.action.ActionMessage)146 ActionErrors (org.apache.struts.action.ActionErrors)68 ActionMessages (org.apache.struts.action.ActionMessages)31 ResourceBundle (java.util.ResourceBundle)29 InvalidDateException (org.mifos.application.admin.servicefacade.InvalidDateException)22 Locale (java.util.Locale)18 JspException (javax.servlet.jsp.JspException)11 Iterator (java.util.Iterator)10 ActionForward (org.apache.struts.action.ActionForward)9 AbstractContest (cn.edu.zju.acm.onlinejudge.bean.AbstractContest)8 List (java.util.List)8 Problem (cn.edu.zju.acm.onlinejudge.bean.Problem)7 ArrayList (java.util.ArrayList)7 DoubleConversionResult (org.mifos.framework.util.helpers.DoubleConversionResult)7 UserProfile (cn.edu.zju.acm.onlinejudge.bean.UserProfile)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 UserSecurity (cn.edu.zju.acm.onlinejudge.security.UserSecurity)4