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;
}
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);
}
}
}
use of org.apache.struts.action.ActionMessage in project head by mifos.
the class LoanPrdActionForm method vaildateDecliningInterestSvcChargeDeductedAtDisbursement.
private void vaildateDecliningInterestSvcChargeDeductedAtDisbursement(ActionErrors errors, HttpServletRequest request) {
logger.debug("start Loan prd Action Form vaildateDecliningInterestSvcChargeDeductedAtDisbursement :" + getInterestTypes() + "---" + getIntDedDisbursementFlag());
if (getInterestTypes() != null && (getInterestTypes().equals(InterestType.DECLINING.getValue().toString()) || getInterestTypes().equals(InterestType.DECLINING_EPI.getValue().toString()))) {
if (null != getIntDedDisbursementFlag() && getIntDedDisbursementFlag().equals("1")) {
errors.add(ProductDefinitionConstants.DECLINEINTERESTDISBURSEMENTDEDUCTION, new ActionMessage(ProductDefinitionConstants.DECLINEINTERESTDISBURSEMENTDEDUCTION));
}
}
logger.debug("Loan prd Action Form vaildateDecliningInterestSvcChargeDeductedAtDisbursement called ");
}
use of org.apache.struts.action.ActionMessage 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;
}
use of org.apache.struts.action.ActionMessage in project head by mifos.
the class SavingsClosureActionForm method validateDate.
private ActionErrors validateDate(String date, String fieldName) {
ActionErrors errors = new ActionErrors();
java.sql.Date sqlDate = null;
if (date != null && !date.equals("")) {
try {
sqlDate = DateUtils.getDateAsSentFromBrowser(date);
if (DateUtils.whichDirection(sqlDate) > 0) {
errors = new ActionErrors();
errors.add(AccountConstants.ERROR_FUTUREDATE, new ActionMessage(AccountConstants.ERROR_FUTUREDATE, fieldName));
}
} catch (InvalidDateException e) {
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;
}
Aggregations