use of org.apache.struts.action.ActionErrors 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;
}
use of org.apache.struts.action.ActionErrors in project head by mifos.
the class RepayLoanActionForm method validate.
@Override
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
String method = request.getParameter("method");
ActionErrors errors = new ActionErrors();
if (!method.equals("loadRepayment") && !method.equals("loadGroupRepayment") && !method.equals("makeRepayment") && !method.equals("validate") && !method.equals("previous") && !method.equals("cancel")) {
errors.add(super.validate(mapping, request));
validateDateOfPayment(errors);
validateTransfer(errors);
}
if (!errors.isEmpty()) {
request.setAttribute(Globals.ERROR_KEY, errors);
request.setAttribute("methodCalled", method);
}
return errors;
}
use of org.apache.struts.action.ActionErrors 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;
}
use of org.apache.struts.action.ActionErrors in project head by mifos.
the class AccountApplyPaymentActionForm method validate.
@Override
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
String methodCalled = request.getParameter(MethodNameConstants.METHOD);
ActionErrors errors = new ActionErrors();
boolean groupLoanWithMembers = AccountingRules.isGroupLoanWithMembers();
if (groupLoanWithMembers) {
if (methodCalled != null && methodCalled.equals("preview")) {
validateTransfer(errors);
validateTransactionDate(errors);
validatePaymentType(errors);
validateReceiptDate(errors);
String accountType = (String) request.getSession().getAttribute(Constants.ACCOUNT_TYPE);
validateAccountType(errors, accountType);
validateAmount(errors);
validateModeOfPaymentSecurity(request, errors);
}
if (!errors.isEmpty()) {
request.setAttribute(Globals.ERROR_KEY, errors);
if (methodCalled.equals("divide")) {
request.setAttribute("methodCalled", "preview");
} else if (methodCalled.equals("preview") && !individualValues.isEmpty()) {
request.setAttribute("methodCalled", "divide");
} else if (methodCalled.equals("preview") && individualValues.isEmpty()) {
request.setAttribute("methodCalled", "preview");
} else {
request.setAttribute("methodCalled", methodCalled);
}
}
} else {
if (methodCalled != null && methodCalled.equals("preview")) {
validateTransfer(errors);
validateTransactionDate(errors);
validatePaymentType(errors);
validateReceiptDate(errors);
String accountType = (String) request.getSession().getAttribute(Constants.ACCOUNT_TYPE);
validateAccountType(errors, accountType);
validateAmount(errors);
validateModeOfPaymentSecurity(request, errors);
}
if (!errors.isEmpty()) {
request.setAttribute(Globals.ERROR_KEY, errors);
request.setAttribute("methodCalled", methodCalled);
}
}
return errors;
}
use of org.apache.struts.action.ActionErrors in project head by mifos.
the class ApplyAdjustmentActionForm method validate.
@Override
public ActionErrors validate(ActionMapping actionMapping, HttpServletRequest request) {
if (null == request.getAttribute(Constants.CURRENTFLOWKEY)) {
request.setAttribute(Constants.CURRENTFLOWKEY, request.getParameter(Constants.CURRENTFLOWKEY));
}
ActionErrors actionErrors = new ActionErrors();
String method = request.getParameter("method");
if (null != method && method.equals("previewAdjustment")) {
/* if (!adjustcheckbox) {
request.setAttribute("method", "loadAdjustment");
actionErrors.add("", new ActionMessage("errors.mandatorycheckbox"));
}*/
if (!adjustcheckbox) {
validateAmount(actionErrors);
validatePaymentType(actionErrors);
validateTransactionDate(actionErrors);
}
if (adjustmentNote == null || adjustmentNote.trim() == "") {
request.setAttribute("method", "loadAdjustment");
actionErrors.add("", new ActionMessage("errors.mandatorytextarea"));
} else if (adjustmentNote.length() > 300) {
request.setAttribute("method", "loadAdjustment");
actionErrors.add("", new ActionMessage("errors.adjustmentNoteTooBig"));
}
if (!actionErrors.isEmpty()) {
request.setAttribute("method", "loadAdjustment");
return actionErrors;
}
}
return actionErrors;
}
Aggregations