use of org.apache.struts.action.ActionErrors in project head by mifos.
the class AccountApplyPaymentActionForm method validateTransactionDate.
private void validateTransactionDate(ActionErrors errors) {
String fieldName = "accounts.date_of_trxn";
ActionErrors validationErrors = validateDate(getTransactionDate(), getLocalizedMessage(fieldName));
if (null != validationErrors && !validationErrors.isEmpty()) {
errors.add(validationErrors);
}
if (null != getTransactionDate()) {
validationErrors = validatePaymentDate(getTransactionDate(), getLocalizedMessage(fieldName));
if (validationErrors != null && !validationErrors.isEmpty()) {
errors.add(validationErrors);
}
}
}
use of org.apache.struts.action.ActionErrors 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;
}
use of org.apache.struts.action.ActionErrors in project head by mifos.
the class ApplyAdjustmentActionForm method validateTransactionDate.
private void validateTransactionDate(ActionErrors errors) {
String fieldName = "accounts.date_of_trxn";
ActionErrors validationErrors = validateDate(getTransactionDate(), getLocalizedMessage(fieldName));
if (null != validationErrors && !validationErrors.isEmpty()) {
errors.add(validationErrors);
}
}
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;
}
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;
}
Aggregations